Search is not available for this dataset
text
string
meta
dict
{-# OPTIONS --cubical #-} -- First and second species counterpoint for Frog's song module Frog where open import Data.Fin open import Data.List using (List; []; _∷_; _++_; map) open import Data.Maybe using (fromMaybe) open import Data.Nat open import Data.Product using (_×_; _,_; proj₁; proj₂) open import Function using (_∘_) open import Relation.Binary.PropositionalEquality using (refl) open import Counterpoint open import Note open import Music open import MidiEvent open import Pitch open import Interval open import Util -- First species counterpoint (musical content) first : PitchInterval first = (c 5 , per8) middle : List PitchInterval middle = (d 5 , maj6) ∷ (e 5 , min6) ∷ (f 5 , maj3) ∷ (e 5 , min3) ∷ (d 5 , maj6) ∷ [] middle' : List PitchInterval middle' = (d 5 , per8) ∷ (e 5 , min6) ∷ (f 5 , maj3) ∷ (e 5 , min3) ∷ (d 5 , maj6) ∷ [] last : PitchInterval last = (c 5 , per8) -- Second species counterpoint (musical content) first2 : PitchInterval first2 = (c 5 , per5) middle2 : List PitchInterval2 middle2 = (d 5 , min3 , per5) ∷ (e 5 , min3 , min6) ∷ (f 5 , maj3 , aug4) ∷ (e 5 , min6 , per1) ∷ (d 5 , min3 , maj6) ∷ [] last2 : PitchInterval last2 = (c 5 , per8) -- Correct first species counterpoint fs : FirstSpecies fs = firstSpecies first middle last refl refl refl refl {- -- Parallel octave example from Section 3.3; ill-typed fs' : FirstSpecies fs' = firstSpecies first middle' last refl refl refl refl -} -- Correct second species counterpoint ss : SecondSpecies ss = secondSpecies first2 middle2 last2 refl refl refl refl refl -- Music as list of notes cf cp1 cp2 : List Note cf = tone whole (proj₁ (FirstSpecies.firstBar fs)) ∷ map (tone whole ∘ proj₁ ∘ pitchIntervalToPitchPair) (FirstSpecies.middleBars fs) ++ tone whole (proj₁ (FirstSpecies.lastBar fs)) ∷ [] cp1 = tone whole ((proj₂ ∘ pitchIntervalToPitchPair) (FirstSpecies.firstBar fs)) ∷ map (tone whole ∘ proj₂ ∘ pitchIntervalToPitchPair) (FirstSpecies.middleBars fs) ++ tone whole ((proj₂ ∘ pitchIntervalToPitchPair) (FirstSpecies.lastBar fs)) ∷ [] cp2 = rest half ∷ (tone half ((proj₂ ∘ pitchIntervalToPitchPair) (SecondSpecies.firstBar ss))) ∷ map (tone half ∘ proj₂ ∘ pitchIntervalToPitchPair) (expandPitchIntervals2 (SecondSpecies.middleBars ss)) ++ tone whole ((proj₂ ∘ pitchIntervalToPitchPair) (SecondSpecies.lastBar ss)) ∷ [] ---- -- MIDI generation piano marimba : InstrumentNumber-1 piano = # 0 marimba = # 12 channel1 channel2 : Channel-1 channel1 = # 0 channel2 = # 1 tempo : ℕ tempo = 120 cfVelocity cpVelocity : Velocity cfVelocity = # 60 cpVelocity = # 30 cfTrack : MidiTrack cfTrack = track "Cantus Firmus" piano channel1 tempo (notes→events cfVelocity cf) cpTrack1 : MidiTrack cpTrack1 = track "Counterpoint 1" piano channel2 tempo (notes→events cpVelocity cp1) cfcpTracks1 : List MidiTrack cfcpTracks1 = cpTrack1 ∷ cfTrack ∷ [] cpTrack2 : MidiTrack cpTrack2 = track "Counterpoint 2" piano channel2 tempo (notes→events cpVelocity cp2) cfcpTracks2 : List MidiTrack cfcpTracks2 = cpTrack2 ∷ cfTrack ∷ []
{ "alphanum_fraction": 0.7106203313, "avg_line_length": 26.7739130435, "ext": "agda", "hexsha": "6b480840e1cd69b8a7450ef16f4e6e65c967ddd6", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z", "max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "halfaya/MusicTools", "max_forks_repo_path": "agda/Frog.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z", "max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "halfaya/MusicTools", "max_issues_repo_path": "agda/Frog.agda", "max_line_length": 109, "max_stars_count": 28, "max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "halfaya/MusicTools", "max_stars_repo_path": "agda/Frog.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z", "num_tokens": 977, "size": 3079 }
open import Type module Graph.Properties.Proofs where open import Data.Either.Proofs open import Functional open import Function.Equals open import Lang.Instance open import Logic open import Logic.Propositional open import Logic.Propositional.Theorems import Lvl open import Graph open import Graph.Properties open import Relator.Equals.Proofs.Equiv open import Structure.Setoid.Uniqueness open import Structure.Relator.Properties open import Type.Properties.Singleton module _ {ℓ₁ ℓ₂} {V : Type{ℓ₁}} (_⟶_ : Graph{ℓ₁}{ℓ₂}(V)) where instance undirect-undirected : Undirected(undirect(_⟶_)) Undirected.reversable undirect-undirected = intro [∨]-symmetry Undirected.reverse-involution undirect-undirected = intro (_⊜_.proof swap-involution) -- [++]-visits : ∀{ae be a₁ b₁ a₂ b₂}{e : ae ⟶ be}{w₁ : Walk(_⟶_) a₁ b₁}{w₂ : Walk(_⟶_) a₂ b₂} → (Visits(_⟶_) e w₁) ∨ (Visits(_⟶_) e w₂) → Visits(_⟶_) e (w₁ ++ w₂) complete-singular-is-undirected : ⦃ CompleteWithLoops(_⟶_) ⦄ → ⦃ Singular(_⟶_) ⦄ → Undirected(_⟶_) Undirected.reversable complete-singular-is-undirected = intro(const (completeWithLoops(_⟶_))) Undirected.reverse-involution complete-singular-is-undirected = intro(singular(_⟶_)) -- traceable-is-connected : ⦃ Traceable(_⟶_) ⦄ → Connected(_⟶_)
{ "alphanum_fraction": 0.7307098765, "avg_line_length": 39.2727272727, "ext": "agda", "hexsha": "18010979c3a76485df33a30c3db24bd093d69ab8", "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": "Graph/Properties/Proofs.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": "Graph/Properties/Proofs.agda", "max_line_length": 165, "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": "Graph/Properties/Proofs.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": 412, "size": 1296 }
-------------------------------------------------------------------------------- -- This is part of Agda Inference Systems {-# OPTIONS --sized-types #-} open import Data.Nat open import Data.Vec open import Data.Fin open import Data.Product open import Data.Sum open import Data.Unit open import Data.Empty open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Size open import is-lib.SInfSys open import Examples.Lambda.Lambda module Examples.Lambda.BigStep where data Value∞ : Set where res : Value → Value∞ div : Value∞ U : Set U = Term 0 × Value∞ data BigStepRN : Set where VAL APP L-DIV R-DIV : BigStepRN data BigStepCoRN : Set where COA : BigStepCoRN coa-r : FinMetaRule U coa-r .Ctx = Term 0 coa-r .comp t = [] , ------------------------- (t , div) val-r : FinMetaRule U val-r .Ctx = Value val-r .comp v = [] , ------------------------- (term v , res v) app-r : FinMetaRule U app-r .Ctx = Term 0 × Term 1 × Term 0 × Value × Value∞ app-r .comp (t1 , t , t2 , v , v∞) = (t1 , res (lambda t)) ∷ (t2 , res v) ∷ (subst-0 t (term v) , v∞) ∷ [] , ------------------------- (app t1 t2 , v∞) l-div-r : FinMetaRule U l-div-r .Ctx = Term 0 × Term 0 l-div-r .comp (t1 , t2) = (t1 , div) ∷ [] , ------------------------- (app t1 t2 , div) r-div-r : FinMetaRule U r-div-r .Ctx = Term 0 × Term 0 × Value r-div-r .comp (t1 , t2 , v) = (t1 , res v) ∷ (t2 , div) ∷ [] , ------------------------- (app t1 t2 , div) BigStepIS : IS U BigStepIS .Names = BigStepRN BigStepIS .rules VAL = from val-r BigStepIS .rules APP = from app-r BigStepIS .rules L-DIV = from l-div-r BigStepIS .rules R-DIV = from r-div-r BigStepCOIS : IS U BigStepCOIS .Names = BigStepCoRN BigStepCOIS .rules COA = from coa-r _⇓_ : Term 0 → Value∞ → Size → Set (t ⇓ v∞) i = SFCoInd⟦ BigStepIS , BigStepCOIS ⟧ (t , v∞) i _⇓ᵢ_ : Term 0 → Value∞ → Set t ⇓ᵢ v∞ = Ind⟦ BigStepIS ∪ BigStepCOIS ⟧ (t , v∞) {- Properties -} val-not-reduce⇓ : ∀{v} → ¬ (∀{i} → ((term v) ⇓ div) i) val-not-reduce⇓ {lambda _} bs with bs val-not-reduce⇓ {lambda _} bs | (sfold (VAL , _ , () , _)) val-⇓ᵢ-≡ : ∀{v v'} → term v ⇓ᵢ res v' → v ≡ v' val-⇓ᵢ-≡ {lambda x} {lambda .x} (fold (inj₁ VAL , .(lambda x) , refl , _)) = refl val-⇓ᵢ-≡ {lambda x} {lambda x₁} (fold (inj₁ APP , _ , () , _)) val-⇓ᵢ-≡ {v} {v'} (fold (inj₂ COA , _ , () , _)) val-⇓-≡ : ∀{v v'} → (∀{i} → (term v ⇓ res v') i) → v ≡ v' val-⇓-≡ bs = val-⇓ᵢ-≡ (sfcoind-to-ind bs)
{ "alphanum_fraction": 0.5195852535, "avg_line_length": 26.303030303, "ext": "agda", "hexsha": "020b85631672ef1ee561fb51980761f5a536d861", "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": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "LcicC/inference-systems-agda", "max_forks_repo_path": "Examples/Lambda/BigStep.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "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": "LcicC/inference-systems-agda", "max_issues_repo_path": "Examples/Lambda/BigStep.agda", "max_line_length": 83, "max_stars_count": 3, "max_stars_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "LcicC/inference-systems-agda", "max_stars_repo_path": "Examples/Lambda/BigStep.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-25T15:48:52.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-10T15:53:47.000Z", "num_tokens": 1026, "size": 2604 }
{-# OPTIONS --cubical --safe #-} module Testers where open import Prelude open import Data.List using (List; map; _⋯_) open import Data.List.Sugar using (liftA2) testIso : (fns : A ↔ B) → List A → Type _ testIso (to iff fro) xs = xs ≡ map (fro ∘ to) xs testIsoℕ : (fns : ℕ ↔ A) → ℕ → Type _ testIsoℕ fns n = testIso fns (0 ⋯ n) testUnary : (A → B) → (A → A) → (B → B) → List A → Type _ testUnary to f g xs = map (to ∘ f) xs ≡ map (g ∘ to) xs testBinary : (A → B) → (A → A → A) → (B → B → B) → List A → Type _ testBinary to f g xs = liftA2 (λ x y → to (f x y)) xs xs ≡ liftA2 (λ x y → g (to x) (to y)) xs xs testUnaryℕ : (ℕ → A) → (ℕ → ℕ) → (A → A) → ℕ → Type _ testUnaryℕ to f g n = testUnary to f g (0 ⋯ n) testBinaryℕ : (ℕ → A) → (ℕ → ℕ → ℕ) → (A → A → A) → ℕ → Type _ testBinaryℕ to f g n = testBinary to f g (0 ⋯ n)
{ "alphanum_fraction": 0.5528846154, "avg_line_length": 29.7142857143, "ext": "agda", "hexsha": "01a1f62085bbfa00165f3fa683559e32a00d970b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Testers.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "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/agda-playground", "max_issues_repo_path": "Testers.agda", "max_line_length": 76, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Testers.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 354, "size": 832 }
open import Data.Nat {- This is a test line ∀ , yeah it works ≡ -} ten : ℕ ten = 10
{ "alphanum_fraction": 0.6046511628, "avg_line_length": 12.2857142857, "ext": "agda", "hexsha": "3d0bd547dc1c967a8677d49ad7d35259918f8b01", "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": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "andorp/plfa.github.io", "max_forks_repo_path": "nats.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "andorp/plfa.github.io", "max_issues_repo_path": "nats.agda", "max_line_length": 45, "max_stars_count": null, "max_stars_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "andorp/plfa.github.io", "max_stars_repo_path": "nats.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 30, "size": 86 }
{-# OPTIONS --cubical --safe #-} module Data.Binary.Conversion.Fast.Properties where open import Prelude open import Data.Binary.Conversion open import Data.Binary.Definition open import Data.Binary.Increment import Data.Binary.Conversion.Fast as F open import Data.Binary.Conversion.Fast using (⟦_⇑⟧⟨_⟩) open import Data.Nat.Properties open import Data.Nat.DivMod open import Data.Maybe.Sugar open import Data.Maybe tail𝔹 : 𝔹 → 𝔹 tail𝔹 0ᵇ = 0ᵇ tail𝔹 (1ᵇ xs) = xs tail𝔹 (2ᵇ xs) = xs tail𝔹-inc : ∀ xs → inc (tail𝔹 (inc xs)) ≡ tail𝔹 (inc (inc (inc xs))) tail𝔹-inc 0ᵇ = refl tail𝔹-inc (1ᵇ xs) = refl tail𝔹-inc (2ᵇ xs) = refl tail-homo : ∀ n → tail𝔹 (inc ⟦ n ⇑⟧) ≡ ⟦ n ÷ 2 ⇑⟧ tail-homo n = go n ; cong ⟦_⇑⟧ (sym (div-helper-lemma 0 1 n 1)) where go : ∀ n → tail𝔹 (inc ⟦ n ⇑⟧) ≡ ⟦ div-helper′ 1 n 1 ⇑⟧ go zero = refl go (suc zero) = refl go (suc (suc n)) = sym (tail𝔹-inc ⟦ n ⇑⟧) ; cong inc (go n) head𝔹 : 𝔹 → Maybe Bool head𝔹 0ᵇ = nothing head𝔹 (1ᵇ xs) = just true head𝔹 (2ᵇ xs) = just false head𝔹-inc : ∀ xs → head𝔹 (inc (inc (inc xs))) ≡ head𝔹 (inc xs) head𝔹-inc 0ᵇ = refl head𝔹-inc (1ᵇ xs) = refl head𝔹-inc (2ᵇ xs) = refl head𝔹-homo : ∀ n → head𝔹 (inc ⟦ n ⇑⟧) ≡ just (even n) head𝔹-homo zero = refl head𝔹-homo (suc zero) = refl head𝔹-homo (suc (suc n)) = head𝔹-inc ⟦ n ⇑⟧ ; head𝔹-homo n open import Data.Bool.Properties open import Data.Maybe.Properties head-tail-cong : ∀ xs ys → head𝔹 xs ≡ head𝔹 ys → tail𝔹 xs ≡ tail𝔹 ys → xs ≡ ys head-tail-cong 0ᵇ 0ᵇ h≡ t≡ = refl head-tail-cong 0ᵇ (1ᵇ ys) h≡ t≡ = ⊥-elim (nothing≢just h≡) head-tail-cong 0ᵇ (2ᵇ ys) h≡ t≡ = ⊥-elim (nothing≢just h≡) head-tail-cong (1ᵇ xs) 0ᵇ h≡ t≡ = ⊥-elim (just≢nothing h≡) head-tail-cong (1ᵇ xs) (1ᵇ ys) h≡ t≡ = cong 1ᵇ_ t≡ head-tail-cong (1ᵇ xs) (2ᵇ ys) h≡ t≡ = ⊥-elim (subst (bool ⊥ ⊤) (just-inj h≡) tt) head-tail-cong (2ᵇ xs) 0ᵇ h≡ t≡ = ⊥-elim (just≢nothing h≡) head-tail-cong (2ᵇ xs) (1ᵇ ys) h≡ t≡ = ⊥-elim (subst (bool ⊤ ⊥) (just-inj h≡) tt) head-tail-cong (2ᵇ xs) (2ᵇ ys) h≡ t≡ = cong 2ᵇ_ t≡ div2≤ : ∀ n m → n ≤ m → n ÷ 2 ≤ m div2≤ n m = ≤-trans (n ÷ 2) n m (div-≤ n 1) fast-correct-helper : ∀ n w → n ≤ w → ⟦ n ⇑⟧⟨ w ⟩ ≡ ⟦ n ⇑⟧ fast-correct-helper zero w p = refl fast-correct-helper (suc n) (suc w) p = head-tail-cong _ (inc ⟦ n ⇑⟧) (lemma₁ (even n) ⟦ n ÷ 2 ⇑⟧⟨ w ⟩ ; sym (head𝔹-homo n)) (lemma₂ (even n) ⟦ n ÷ 2 ⇑⟧⟨ w ⟩ ; fast-correct-helper (n ÷ 2) w (div2≤ n w (p≤p n w p)) ; sym (tail-homo n)) where lemma₁ : ∀ x xs → head𝔹 (if x then 1ᵇ xs else 2ᵇ xs) ≡ just x lemma₁ false xs = refl lemma₁ true xs = refl lemma₂ : ∀ x xs → tail𝔹 (if x then 1ᵇ xs else 2ᵇ xs) ≡ xs lemma₂ false xs = refl lemma₂ true xs = refl fast-correct : ∀ n → F.⟦ n ⇑⟧ ≡ ⟦ n ⇑⟧ fast-correct n = fast-correct-helper n n (≤-refl n)
{ "alphanum_fraction": 0.6074154853, "avg_line_length": 33.1445783133, "ext": "agda", "hexsha": "718a690f49fb03061770918409a9a3f73a547027", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Binary/Conversion/Fast/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "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/agda-playground", "max_issues_repo_path": "Data/Binary/Conversion/Fast/Properties.agda", "max_line_length": 115, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Binary/Conversion/Fast/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 1398, "size": 2751 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Homogeneously-indexed binary relations -- -- Indexed structures are laid out in a similar manner as to those -- in Relation.Binary. The main difference is each structure also -- contains proofs for the lifted version of the relation. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Binary.Indexed.Homogeneous where open import Function using (_⟨_⟩_) open import Level using (Level; _⊔_; suc) open import Relation.Binary as B using (_⇒_) open import Relation.Binary.PropositionalEquality as P using (_≡_) open import Relation.Nullary using (¬_) open import Data.Product using (_,_) ------------------------------------------------------------------------ -- Publically export core definitions open import Relation.Binary.Indexed.Homogeneous.Core public ------------------------------------------------------------------------ -- Equivalences record IsIndexedEquivalence {i a ℓ} {I : Set i} (A : I → Set a) (_≈ᵢ_ : IRel A ℓ) : Set (i ⊔ a ⊔ ℓ) where field reflᵢ : Reflexive A _≈ᵢ_ symᵢ : Symmetric A _≈ᵢ_ transᵢ : Transitive A _≈ᵢ_ reflexiveᵢ : ∀ {i} → _≡_ ⟨ _⇒_ ⟩ _≈ᵢ_ {i} reflexiveᵢ P.refl = reflᵢ -- Lift properties reflexive : _≡_ ⇒ (Lift A _≈ᵢ_) reflexive P.refl i = reflᵢ refl : B.Reflexive (Lift A _≈ᵢ_) refl i = reflᵢ sym : B.Symmetric (Lift A _≈ᵢ_) sym x≈y i = symᵢ (x≈y i) trans : B.Transitive (Lift A _≈ᵢ_) trans x≈y y≈z i = transᵢ (x≈y i) (y≈z i) isEquivalence : B.IsEquivalence (Lift A _≈ᵢ_) isEquivalence = record { refl = refl ; sym = sym ; trans = trans } record IndexedSetoid {i} (I : Set i) c ℓ : Set (suc (i ⊔ c ⊔ ℓ)) where infix 4 _≈ᵢ_ _≈_ field Carrierᵢ : I → Set c _≈ᵢ_ : IRel Carrierᵢ ℓ isEquivalenceᵢ : IsIndexedEquivalence Carrierᵢ _≈ᵢ_ open IsIndexedEquivalence isEquivalenceᵢ public Carrier : Set _ Carrier = ∀ i → Carrierᵢ i _≈_ : B.Rel Carrier _ _≈_ = Lift Carrierᵢ _≈ᵢ_ _≉_ : B.Rel Carrier _ x ≉ y = ¬ (x ≈ y) setoid : B.Setoid _ _ setoid = record { isEquivalence = isEquivalence } ------------------------------------------------------------------------ -- Decidable equivalences record IsIndexedDecEquivalence {i a ℓ} {I : Set i} (A : I → Set a) (_≈ᵢ_ : IRel A ℓ) : Set (i ⊔ a ⊔ ℓ) where infix 4 _≟ᵢ_ field _≟ᵢ_ : Decidable A _≈ᵢ_ isEquivalenceᵢ : IsIndexedEquivalence A _≈ᵢ_ open IsIndexedEquivalence isEquivalenceᵢ public record IndexedDecSetoid {i} (I : Set i) c ℓ : Set (suc (i ⊔ c ⊔ ℓ)) where infix 4 _≈ᵢ_ field Carrierᵢ : I → Set c _≈ᵢ_ : IRel Carrierᵢ ℓ isDecEquivalenceᵢ : IsIndexedDecEquivalence Carrierᵢ _≈ᵢ_ open IsIndexedDecEquivalence isDecEquivalenceᵢ public indexedSetoid : IndexedSetoid I c ℓ indexedSetoid = record { isEquivalenceᵢ = isEquivalenceᵢ } open IndexedSetoid indexedSetoid public using (Carrier; _≈_; _≉_; setoid) ------------------------------------------------------------------------ -- Preorders record IsIndexedPreorder {i a ℓ₁ ℓ₂} {I : Set i} (A : I → Set a) (_≈ᵢ_ : IRel A ℓ₁) (_∼ᵢ_ : IRel A ℓ₂) : Set (i ⊔ a ⊔ ℓ₁ ⊔ ℓ₂) where field isEquivalenceᵢ : IsIndexedEquivalence A _≈ᵢ_ reflexiveᵢ : _≈ᵢ_ ⇒[ A ] _∼ᵢ_ transᵢ : Transitive A _∼ᵢ_ module Eq = IsIndexedEquivalence isEquivalenceᵢ reflᵢ : Reflexive A _∼ᵢ_ reflᵢ = reflexiveᵢ Eq.reflᵢ ∼ᵢ-respˡ-≈ᵢ : Respectsˡ A _∼ᵢ_ _≈ᵢ_ ∼ᵢ-respˡ-≈ᵢ x≈y x∼z = transᵢ (reflexiveᵢ (Eq.symᵢ x≈y)) x∼z ∼ᵢ-respʳ-≈ᵢ : Respectsʳ A _∼ᵢ_ _≈ᵢ_ ∼ᵢ-respʳ-≈ᵢ x≈y z∼x = transᵢ z∼x (reflexiveᵢ x≈y) ∼ᵢ-resp-≈ᵢ : Respects₂ A _∼ᵢ_ _≈ᵢ_ ∼ᵢ-resp-≈ᵢ = ∼ᵢ-respʳ-≈ᵢ , ∼ᵢ-respˡ-≈ᵢ -- Lifted properties reflexive : Lift A _≈ᵢ_ B.⇒ Lift A _∼ᵢ_ reflexive x≈y i = reflexiveᵢ (x≈y i) refl : B.Reflexive (Lift A _∼ᵢ_) refl i = reflᵢ trans : B.Transitive (Lift A _∼ᵢ_) trans x≈y y≈z i = transᵢ (x≈y i) (y≈z i) ∼-respˡ-≈ : (Lift A _∼ᵢ_) B.Respectsˡ (Lift A _≈ᵢ_) ∼-respˡ-≈ x≈y x∼z i = ∼ᵢ-respˡ-≈ᵢ (x≈y i) (x∼z i) ∼-respʳ-≈ : (Lift A _∼ᵢ_) B.Respectsʳ (Lift A _≈ᵢ_) ∼-respʳ-≈ x≈y z∼x i = ∼ᵢ-respʳ-≈ᵢ (x≈y i) (z∼x i) ∼-resp-≈ : (Lift A _∼ᵢ_) B.Respects₂ (Lift A _≈ᵢ_) ∼-resp-≈ = ∼-respʳ-≈ , ∼-respˡ-≈ isPreorder : B.IsPreorder (Lift A _≈ᵢ_) (Lift A _∼ᵢ_) isPreorder = record { isEquivalence = Eq.isEquivalence ; reflexive = reflexive ; trans = trans } record IndexedPreorder {i} (I : Set i) c ℓ₁ ℓ₂ : Set (suc (i ⊔ c ⊔ ℓ₁ ⊔ ℓ₂)) where infix 4 _≈ᵢ_ _∼ᵢ_ _≈_ _∼_ field Carrierᵢ : I → Set c _≈ᵢ_ : IRel Carrierᵢ ℓ₁ _∼ᵢ_ : IRel Carrierᵢ ℓ₂ isPreorderᵢ : IsIndexedPreorder Carrierᵢ _≈ᵢ_ _∼ᵢ_ open IsIndexedPreorder isPreorderᵢ public Carrier : Set _ Carrier = ∀ i → Carrierᵢ i _≈_ : B.Rel Carrier _ x ≈ y = ∀ i → x i ≈ᵢ y i _∼_ : B.Rel Carrier _ x ∼ y = ∀ i → x i ∼ᵢ y i preorder : B.Preorder _ _ _ preorder = record { isPreorder = isPreorder } ------------------------------------------------------------------------ -- Partial orders record IsIndexedPartialOrder {i a ℓ₁ ℓ₂} {I : Set i} (A : I → Set a) (_≈ᵢ_ : IRel A ℓ₁) (_≤ᵢ_ : IRel A ℓ₂) : Set (i ⊔ a ⊔ ℓ₁ ⊔ ℓ₂) where field isPreorderᵢ : IsIndexedPreorder A _≈ᵢ_ _≤ᵢ_ antisymᵢ : Antisymmetric A _≈ᵢ_ _≤ᵢ_ open IsIndexedPreorder isPreorderᵢ public renaming ( ∼ᵢ-respˡ-≈ᵢ to ≤ᵢ-respˡ-≈ᵢ ; ∼ᵢ-respʳ-≈ᵢ to ≤ᵢ-respʳ-≈ᵢ ; ∼ᵢ-resp-≈ᵢ to ≤ᵢ-resp-≈ᵢ ; ∼-respˡ-≈ to ≤-respˡ-≈ ; ∼-respʳ-≈ to ≤-respʳ-≈ ; ∼-resp-≈ to ≤-resp-≈ ) antisym : B.Antisymmetric (Lift A _≈ᵢ_) (Lift A _≤ᵢ_) antisym x≤y y≤x i = antisymᵢ (x≤y i) (y≤x i) isPartialOrder : B.IsPartialOrder (Lift A _≈ᵢ_) (Lift A _≤ᵢ_) isPartialOrder = record { isPreorder = isPreorder ; antisym = antisym } record IndexedPoset {i} (I : Set i) c ℓ₁ ℓ₂ : Set (suc (i ⊔ c ⊔ ℓ₁ ⊔ ℓ₂)) where field Carrierᵢ : I → Set c _≈ᵢ_ : IRel Carrierᵢ ℓ₁ _≤ᵢ_ : IRel Carrierᵢ ℓ₂ isPartialOrderᵢ : IsIndexedPartialOrder Carrierᵢ _≈ᵢ_ _≤ᵢ_ open IsIndexedPartialOrder isPartialOrderᵢ public preorderᵢ : IndexedPreorder I c ℓ₁ ℓ₂ preorderᵢ = record { isPreorderᵢ = isPreorderᵢ } open IndexedPreorder preorderᵢ public using (Carrier; _≈_; preorder) renaming (_∼_ to _≤_) poset : B.Poset _ _ _ poset = record { isPartialOrder = isPartialOrder } ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 0.17 REL = IREL {-# WARNING_ON_USAGE REL "Warning: REL was deprecated in v0.17. Please use IREL instead." #-} Rel = IRel {-# WARNING_ON_USAGE Rel "Warning: Rel was deprecated in v0.17. Please use IRel instead." #-}
{ "alphanum_fraction": 0.5539079823, "avg_line_length": 28.1875, "ext": "agda", "hexsha": "fde3fe6e5988ce0da208d696e7f3be7929ef76ab", "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/Relation/Binary/Indexed/Homogeneous.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Binary/Indexed/Homogeneous.agda", "max_line_length": 73, "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/Relation/Binary/Indexed/Homogeneous.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2988, "size": 7216 }
------------------------------------------------------------------------------ -- Totality properties for Tree using induction instance ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Program.Mirror.Tree.Induction.Instances.TotalityATP where open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.List open import FOTC.Program.Mirror.Forest.TotalityATP open import FOTC.Program.Mirror.Mirror open import FOTC.Program.Mirror.Type ------------------------------------------------------------------------------ mirror-Tree-ind-instance : (∀ d {ts} → Forest ts → Forest (map mirror ts) → Tree (mirror · node d ts)) → Forest (map mirror []) → (∀ {t ts} → Tree t → Tree (mirror · t) → Forest ts → Forest (map mirror ts) → Forest (map mirror (t ∷ ts))) → ∀ {t} → Tree t → Tree (mirror · t) mirror-Tree-ind-instance = Tree-mutual-ind postulate mirror-Tree : ∀ {t} → Tree t → Tree (mirror · t) {-# ATP prove mirror-Tree mirror-Tree-ind-instance reverse-Forest #-}
{ "alphanum_fraction": 0.5322847682, "avg_line_length": 38.9677419355, "ext": "agda", "hexsha": "ac3a6e825ddcbda351ff83bb0bff53f974c379b4", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/Mirror/Tree/Induction/Instances/TotalityATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/Mirror/Tree/Induction/Instances/TotalityATP.agda", "max_line_length": 79, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/Mirror/Tree/Induction/Instances/TotalityATP.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": 274, "size": 1208 }
{-# OPTIONS --cubical #-} module Montuno where open import Data.Fin using (#_) open import Data.Integer using (+_) open import Data.List using (List; _∷_; []; map; concat; _++_; replicate; zip) open import Data.Nat using (_*_; ℕ; suc; _+_) open import Data.Product using (_,_) open import Function using (_∘_) open import Note {- double : List Chord → List Chord double = map (λ c → flatten (c ∷ (transposeChord (+ chromaticScaleSize) c) ∷ [])) -- add the base note of the first chord to the first chord, transposed up 2 octaves add2octave : List Chord → List Chord add2octave [] = [] add2octave cs@(chord [] ∷ _) = cs add2octave (c@(chord (n ∷ ns)) ∷ cs) = (appendNote (transpose (+ (chromaticScaleSize * 2)) n) c) ∷ cs baseOctave : Chord baseOctave = chord (map (note ∘ +_ ∘ (_* chromaticScaleSize)) (0 ∷ 1 ∷ 2 ∷ [])) makeUnit : {n : ℕ} → Scale (suc n) → (Chord → List Chord) → ScaleDegree (suc n) → List Chord makeUnit scale f = add2octave ∘ double ∘ f ∘ relativeChordToChord ∘ triad scale ∘ (λ d → (d , octave (+ 0))) -- TODO: See if we can use the one in Data.List _≫=_ : {A B : Set} → List A → (A → List B) → List B xs ≫= f = concat (map f xs) make2 : {n : ℕ} → Scale (5 + n) → (Chord → List Chord) → ScaleDegree (5 + n) → List Chord make2 scale f secondScaleDegree = let scaleDegrees = secondScaleDegree ∷ map scaleDegree (# 4 ∷ # 3 ∷ []) in makeUnit scale f (scaleDegree (# 0)) ++ (scaleDegrees ≫= makeUnit scale oompah) ++ (baseOctave ∷ []) rhythm rhythma : List Duration rhythm = map duration (+ 2 ∷ + 1 ∷ (replicate 6 (+ 2) ++ (+ 1 ∷ []))) rhythma = map duration (+ 1 ∷ + 1 ∷ + 1 ∷ (replicate 6 (+ 2) ++ (+ 1 ∷ []))) ex8 ex9 ex10 : {n : ℕ} → Scale (5 + n) → List TimedChord ex8 scale = zip (make2 scale oompah (scaleDegree (# 3))) rhythm ex9 scale = zip (make2 scale arpegiate (scaleDegree (# 3))) rhythm ex10 scale = zip (make2 scale arpegiate (scaleDegree (# 1))) rhythma ++ ex8 scale -}
{ "alphanum_fraction": 0.6219387755, "avg_line_length": 40.8333333333, "ext": "agda", "hexsha": "aacccae288663ff6dccfd1da19d853824c32d678", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z", "max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "halfaya/MusicTools", "max_forks_repo_path": "agda/Montuno.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z", "max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "halfaya/MusicTools", "max_issues_repo_path": "agda/Montuno.agda", "max_line_length": 108, "max_stars_count": 28, "max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "halfaya/MusicTools", "max_stars_repo_path": "agda/Montuno.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z", "num_tokens": 687, "size": 1960 }
{-# OPTIONS --safe #-} module Cubical.HITs.S3.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open Iso data S³ : Type₀ where base : S³ surf : PathP (λ j → PathP (λ i → base ≡ base) refl refl) refl refl flip₀₂S³ : S³ → S³ flip₀₂S³ base = base flip₀₂S³ (surf j i i₁) = surf i₁ i j flip₀₂S³Id : (x : S³) → flip₀₂S³ (flip₀₂S³ x) ≡ x flip₀₂S³Id base = refl flip₀₂S³Id (surf j i i₁) = refl flip₀₂S³Iso : Iso S³ S³ fun flip₀₂S³Iso = flip₀₂S³ inv flip₀₂S³Iso = flip₀₂S³ rightInv flip₀₂S³Iso = flip₀₂S³Id leftInv flip₀₂S³Iso = flip₀₂S³Id
{ "alphanum_fraction": 0.7282051282, "avg_line_length": 23.4, "ext": "agda", "hexsha": "d4ea7c6658207c66726318093c7bb76423473937", "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/HITs/S3/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/HITs/S3/Base.agda", "max_line_length": 68, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/S3/Base.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 250, "size": 585 }
open import Prelude hiding (id; erase) module Implicits.WellTyped where open import Data.Fin.Substitution open import Data.Vec hiding ([_]) open import Data.List as List hiding ([_]; map) open import Implicits.Syntax.Type open import Implicits.Syntax.Term open import Implicits.Syntax.Context open import Implicits.Substitutions module TypingRules (_⊢ᵣ_ : ∀ {ν} → ICtx ν → Type ν → Set) where infixl 4 _⊢_∈_ ----------------------------------------------------------------------------- -- typings data _⊢_∈_ {ν n} (K : Ktx ν n) : Term ν n → Type ν → Set where var : (x : Fin n) → K ⊢ var x ∈ (lookup x (proj₁ K)) λ' : ∀ {t b} a → a ∷Γ K ⊢ t ∈ b → K ⊢ λ' a t ∈ simpl (a →' b) Λ : ∀ {t} {a : Type (suc ν)} → ktx-weaken K ⊢ t ∈ a → K ⊢ Λ t ∈ ∀' a _[_] : ∀ {t} {a : Type (suc ν)} → K ⊢ t ∈ ∀' a → (b : Type ν) → K ⊢ t [ b ] ∈ a tp[/tp b ] _·_ : ∀ {f t a b} → K ⊢ f ∈ simpl (a →' b) → K ⊢ t ∈ a → K ⊢ f · t ∈ b -- implicit abstract/application ρ : ∀ {t b a} → [] ⊢unamb a → a ∷K K ⊢ t ∈ b → K ⊢ ρ a t ∈ (a ⇒ b) _⟨_⟩ : ∀ {a b f} → K ⊢ f ∈ a ⇒ b → (proj₂ K) ⊢ᵣ a → K ⊢ f ⟨⟩ ∈ b _with'_ : ∀ {r e a b} → K ⊢ r ∈ a ⇒ b → K ⊢ e ∈ a → K ⊢ r with' e ∈ b _⊢_∉_ : ∀ {ν n} → (K : Ktx ν n) → Term ν n → Type ν → Set _⊢_∉_ K t τ = ¬ K ⊢ t ∈ τ ----------------------------------------------------------------------------- -- syntactic sugar let'_in'_ : ∀ {ν n} {e₁ : Term ν n} {e₂ : Term ν (suc n)} {a b} {K} → K ⊢ e₁ ∈ a → a ∷Γ K ⊢ e₂ ∈ b → K ⊢ (let' e₁ ∶ a in' e₂) ∈ b let' e₁ in' e₂ = (λ' _ e₂) · e₁ implicit'_∶_in'_ : ∀ {ν n} {e₁ : Term ν n} {e₂ : Term ν (suc n)} {a b} {K} → K ⊢ e₁ ∈ a → [] ⊢unamb a → a ∷K K ⊢ e₂ ∈ b → K ⊢ (implicit e₁ ∶ a in' e₂) ∈ b implicit' e₁ ∶ a in' e₂ = (ρ a e₂) with' e₁ wt-¿ : ∀ {ν n} {r : Type ν} {K : Ktx ν n} → [] ⊢unamb r → (proj₂ K) ⊢ᵣ r → K ⊢ (¿ r) ∈ r wt-¿ r x = (ρ r (var zero)) ⟨ x ⟩ ----------------------------------------------------------------------------- -- utilities erase : ∀ {ν n} {K : Ktx ν n} {t a} → K ⊢ t ∈ a → Term ν n erase {t = t} _ = t -- Collections of typing derivations for well-typed terms. data _⊢ⁿ_∈_ {m n} (Γ : Ktx n m) : ∀ {k} → Vec (Term n m) k → Vec (Type n) k → Set where [] : Γ ⊢ⁿ [] ∈ [] _∷_ : ∀ {t a k} {ts : Vec (Term n m) k} {as : Vec (Type n) k} → Γ ⊢ t ∈ a → Γ ⊢ⁿ ts ∈ as → Γ ⊢ⁿ t ∷ ts ∈ (a ∷ as) -- Lookup a well-typed term in a collection thereof. lookup-⊢ : ∀ {m n k} {Γ : Ktx n m} {ts : Vec (Term n m) k} {as : Vec (Type n) k} → (x : Fin k) → Γ ⊢ⁿ ts ∈ as → Γ ⊢ lookup x ts ∈ lookup x as lookup-⊢ zero (⊢t ∷ ⊢ts) = ⊢t lookup-⊢ (suc x) (⊢t ∷ ⊢ts) = lookup-⊢ x ⊢ts
{ "alphanum_fraction": 0.4293659622, "avg_line_length": 40.2537313433, "ext": "agda", "hexsha": "590b071b2f17e58c1d3c1c5da8d8f9c77d669b5e", "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/WellTyped.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/WellTyped.agda", "max_line_length": 91, "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/WellTyped.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": 1170, "size": 2697 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category open import Categories.Functor hiding (id) -- Coimit of a Cocone over a Functor F : J → C module Categories.Diagram.Colimit {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e} {J : Category o′ ℓ′ e′} (F : Functor J C) where private module C = Category C module J = Category J open C open HomReasoning open Functor F open import Level open import Data.Product using (proj₂) open import Categories.Category.Construction.Cocones F renaming (Cocone⇒ to _⇨_) open import Categories.Object.Initial as I hiding (up-to-iso; transport-by-iso) open import Categories.Morphism.Reasoning C open import Categories.Morphism C open import Categories.Morphism Cocones as MC using () renaming (_≅_ to _⇔_) private variable K K′ : Cocone A B : J.Obj X Y Z : Obj q : K ⇨ K′ -- A Colimit is an Initial object in the category of Cocones -- (This could be unpacked...) record Colimit : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where field initial : Initial Cocones module initial = Initial initial open initial using () renaming (⊥ to colimit) public open Cocone colimit hiding (coapex) renaming (N to coapex; ψ to proj; commute to colimit-commute) public rep-cocone : ∀ K → colimit ⇨ K rep-cocone K = initial.! {K} rep : ∀ K → coapex ⇒ Cocone.N K rep K = arr where open _⇨_ (rep-cocone K) unrep : coapex ⇒ X → Cocone unrep f = record { coapex = record { ψ = λ A → f ∘ proj A ; commute = λ g → pullʳ (colimit-commute g) } } coconify : (f : coapex ⇒ X) → colimit ⇨ unrep f coconify f = record { arr = f ; commute = refl } commute : rep K ∘ proj A ≈ Cocone.ψ K A commute {K = K} = _⇨_.commute (rep-cocone K) unrep-cone : (colimit ⇨ K) → Cocone unrep-cone f = unrep (_⇨_.arr f) g-η : ∀ {f : coapex ⇒ X} → rep (unrep f) ≈ f g-η {f = f} = initial.!-unique (coconify f) η-cocone : Cocones [ rep-cocone colimit ≈ Category.id Cocones ] η-cocone = initial.⊥-id (rep-cocone colimit) η : rep colimit ≈ id η = η-cocone rep-cocone∘ : Cocones [ Cocones [ q ∘ rep-cocone K ] ≈ rep-cocone K′ ] rep-cocone∘ {K = K} {q = q} = Equiv.sym (initial.!-unique (Cocones [ q ∘ rep-cocone K ])) rep∘ : ∀ {q : K ⇨ K′} → _⇨_.arr q ∘ rep K ≈ rep K′ rep∘ {q = q} = rep-cocone∘ {q = q} rep-cone-self-id : Cocones [ rep-cocone colimit ≈ Cocones.id ] rep-cone-self-id = initial.!-unique ( Cocones.id ) rep-self-id : rep colimit ≈ id rep-self-id = rep-cone-self-id open Colimit up-to-iso-cone : (L₁ L₂ : Colimit) → colimit L₁ ⇔ colimit L₂ up-to-iso-cone L₁ L₂ = I.up-to-iso Cocones (initial L₁) (initial L₂) up-to-iso : (L₁ L₂ : Colimit) → coapex L₁ ≅ coapex L₂ up-to-iso L₁ L₂ = iso-cocone⇒iso-coapex (up-to-iso-cone L₁ L₂) transport-by-iso-cocone : (C : Colimit) → colimit C ⇔ K → Colimit transport-by-iso-cocone C C⇿K = record { initial = I.transport-by-iso Cocones (initial C) C⇿K } transport-by-iso : (C : Colimit) → coapex C ≅ X → Colimit transport-by-iso C C≅X = transport-by-iso-cocone C (proj₂ p) where p = cocone-resp-iso (colimit C) C≅X
{ "alphanum_fraction": 0.6332268371, "avg_line_length": 28.9814814815, "ext": "agda", "hexsha": "ce5f839cdfd5ea0cab23db6c49ec0b7a20653666", "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/Diagram/Colimit.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/Diagram/Colimit.agda", "max_line_length": 106, "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/Diagram/Colimit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1170, "size": 3130 }
-- Moved from the successfull test-suite. See Issue 1481. module tests.Nat where data Nat : Set where Z : Nat S : Nat → Nat {-# BUILTIN NATURAL Nat #-} _+_ : Nat → Nat → Nat Z + m = m S n + m = S (n + m) {-# BUILTIN NATPLUS _+_ #-} _*_ : Nat → Nat → Nat Z * m = Z S n * m = m + (n * m) {-# BUILTIN NATTIMES _*_ #-} data Unit : Set where unit : Unit postulate IO : Set → Set String : Set natToString : Nat → String putStr : String → IO Unit printNat : Nat → IO Unit printNat n = putStr (natToString n) {-# COMPILED_TYPE IO IO #-} {-# COMPILED_EPIC natToString (n : Any) -> String = bigToStr(n) #-} {-# COMPILED_EPIC putStr (a : String, u : Unit) -> Unit = foreign Int "wputStr" (a : String); primUnit #-} main : IO Unit main = printNat (7 * 191) -- should print 1337
{ "alphanum_fraction": 0.5729665072, "avg_line_length": 18.1739130435, "ext": "agda", "hexsha": "4e83f102543c445b0bbc437a1ee4cf429a955af1", "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/epic/tests/Nat.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/epic/tests/Nat.agda", "max_line_length": 73, "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/epic/tests/Nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 270, "size": 836 }
{-# OPTIONS --safe --warning=error #-} open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Sets.FinSet.Definition open import LogicalFormulae open import Numbers.Naturals.WithK open import Sets.FinSet.Lemmas module Sets.FinSetWithK where private sgEq : {l m : _} {L : Set l} → {pr : L → Set m} → {a b : Sg L pr} → (underlying a ≡ underlying b) → ({c : L} → (r s : pr c) → r ≡ s) → (a ≡ b) sgEq {l} {m} {L} {prop} {(a , b1)} {(.a , b)} refl pr2 with pr2 {a} b b1 sgEq {l} {m} {L} {prop} {(a , b1)} {(.a , .b1)} refl pr2 | refl = refl finNotEqualsRefl : {n : ℕ} {a b : FinSet (succ n)} → (p1 p2 : FinNotEquals a b) → p1 ≡ p2 finNotEqualsRefl {.1} {.fzero} {.(fsucc fzero)} (fne2 .fzero .(fsucc fzero) (inl (refl ,, refl))) (fne2 .fzero .(fsucc fzero) (inl (refl ,, refl))) = refl finNotEqualsRefl {.1} {.fzero} {.(fsucc fzero)} (fne2 .fzero .(fsucc fzero) (inl (refl ,, refl))) (fne2 .fzero .(fsucc fzero) (inr (() ,, snd))) finNotEqualsRefl {.1} {.(fsucc fzero)} {.fzero} (fne2 .(fsucc fzero) .fzero (inr (refl ,, refl))) (fne2 .(fsucc fzero) .fzero (inl (() ,, snd))) finNotEqualsRefl {.1} {.(fsucc fzero)} {.fzero} (fne2 .(fsucc fzero) .fzero (inr (refl ,, refl))) (fne2 .(fsucc fzero) .fzero (inr (refl ,, refl))) = refl finNotEqualsRefl {.(succ (succ _))} {.fzero} {.(fsucc a)} (fneN .fzero .(fsucc a) (inl (inl (refl ,, (a , refl))))) (fneN .fzero .(fsucc a) (inl (inl (refl ,, (.a , refl))))) = refl finNotEqualsRefl {.(succ (succ _))} {.fzero} {.(fsucc a)} (fneN .fzero .(fsucc a) (inl (inl (refl ,, (a , refl))))) (fneN .fzero .(fsucc a) (inl (inr ((a₁ , ()) ,, snd)))) finNotEqualsRefl {.(succ (succ _))} {.fzero} {.(fsucc a)} (fneN .fzero .(fsucc a) (inl (inl (refl ,, (a , refl))))) (fneN .fzero .(fsucc a) (inr ((fst ,, snd) , b))) = exFalso q where p : fzero ≡ fsucc fst p = _&_&_.one b q : False q with p ... | () finNotEqualsRefl {.(succ (succ _))} {.(fsucc a)} {.fzero} (fneN .(fsucc a) .fzero (inl (inr ((a , refl) ,, refl)))) (fneN .(fsucc a) .fzero (inl (inl (() ,, snd)))) finNotEqualsRefl {.(succ (succ _))} {.(fsucc a)} {.fzero} (fneN .(fsucc a) .fzero (inl (inr ((a , refl) ,, refl)))) (fneN .(fsucc a) .fzero (inl (inr ((.a , refl) ,, refl)))) = refl finNotEqualsRefl {.(succ (succ _))} {.(fsucc a)} {.fzero} (fneN .(fsucc a) .fzero (inl (inr ((a , refl) ,, refl)))) (fneN .(fsucc a) .fzero (inr ((fst ,, snd) , b))) = exFalso q where p : fzero ≡ fsucc snd p = _&_&_.two b q : False q with p ... | () finNotEqualsRefl {.(succ (succ _))} {a} {b} (fneN a b (inr (record { fst = fst ; snd = snd₁ } , snd))) (fneN .a .b (inl (inl (fst1 ,, snd₂)))) = exFalso q where p : fzero ≡ fsucc fst p = transitivity (equalityCommutative fst1) (_&_&_.one snd) q : False q with p ... | () finNotEqualsRefl {.(succ (succ _))} {a} {b} (fneN a b (inr (record { fst = fst ; snd = snd1 } , snd))) (fneN .a .b (inl (inr (fst₁ ,, snd2)))) = exFalso q where p : fzero ≡ fsucc snd1 p = transitivity (equalityCommutative snd2) (_&_&_.two snd) q : False q with p ... | () finNotEqualsRefl {.(succ (succ _))} {.fzero} {b} (fneN fzero b (inr (record { fst = fst ; snd = snd₁ } , snd))) (fneN .fzero .b (inr ((fst1 ,, snd₂) , b1))) = exFalso q where p : fzero ≡ fsucc fst1 p = _&_&_.one b1 q : False q with p ... | () finNotEqualsRefl {.(succ (succ _))} {.(fsucc a)} {.fzero} (fneN (fsucc a) fzero (inr (record { fst = fst ; snd = snd₁ } , snd))) (fneN .(fsucc a) .fzero (inr ((fst₁ ,, snd2) , b1))) = exFalso q where p : fzero ≡ fsucc snd2 p = _&_&_.two b1 q : False q with p ... | () finNotEqualsRefl {.(succ (succ _))} {.(fsucc a)} {.(fsucc b)} (fneN (fsucc a) (fsucc b) (inr (record { fst = fst ; snd = snd1 } , snd))) (fneN .(fsucc a) .(fsucc b) (inr ((fst1 ,, snd2) , b1))) = ans where t : a ≡ fst1 t = fsuccInjective (_&_&_.one b1) t' : a ≡ fst t' = fsuccInjective (_&_&_.one snd) u : b ≡ snd1 u = fsuccInjective (_&_&_.two snd) u' : b ≡ snd2 u' = fsuccInjective (_&_&_.two b1) equality : {c : FinSet (succ (succ _)) && FinSet (succ (succ _))} → (r1 s : (fsucc a ≡ fsucc (_&&_.fst c)) & (fsucc b ≡ fsucc (_&&_.snd c)) & FinNotEquals (_&&_.fst c) (_&&_.snd c)) → r1 ≡ s equality record { one = refl ; two = refl ; three = q } record { one = refl ; two = refl ; three = q' } = applyEquality (λ t → record { one = refl ; two = refl ; three = t }) (finNotEqualsRefl q q') r : (fst ,, snd1) ≡ (fst1 ,, snd2) r rewrite equalityCommutative t | equalityCommutative t' | equalityCommutative u | equalityCommutative u' = refl ans : fneN (fsucc a) (fsucc b) (inr ((fst ,, snd1) , snd)) ≡ fneN (fsucc a) (fsucc b) (inr ((fst1 ,, snd2) , b1)) ans = applyEquality (λ t → fneN (fsucc a) (fsucc b) (inr t)) (sgEq r equality)
{ "alphanum_fraction": 0.5622805206, "avg_line_length": 57.630952381, "ext": "agda", "hexsha": "77bac63511cd8339a26d2c871e0ed50c5d47b37f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Sets/FinSetWithK.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Sets/FinSetWithK.agda", "max_line_length": 202, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Sets/FinSetWithK.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": 2028, "size": 4841 }
------------------------------------------------------------------------------ -- Totality properties respect to ListN ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Program.SortList.Properties.Totality.ListN-ATP where open import FOTC.Base open import FOTC.Data.Nat.List.Type open import FOTC.Data.Nat.List.PropertiesATP open import FOTC.Program.SortList.SortList ------------------------------------------------------------------------------ -- The function flatten generates a ListN. flatten-ListN : ∀ {t} → Tree t → ListN (flatten t) flatten-ListN tnil = prf where postulate prf : ListN (flatten nil) {-# ATP prove prf #-} flatten-ListN (ttip {i} Ni) = prf where postulate prf : ListN (flatten (tip i)) {-# ATP prove prf #-} flatten-ListN (tnode {t₁} {i} {t₂} Tt₁ Ni Tt₂) = prf (flatten-ListN Tt₁) (flatten-ListN Tt₂) where postulate prf : ListN (flatten t₁) → ListN (flatten t₂) → ListN (flatten (node t₁ i t₂))
{ "alphanum_fraction": 0.5049586777, "avg_line_length": 37.8125, "ext": "agda", "hexsha": "cce7e0914d8e435292608c1cf81f9fe3073403a4", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/ListN-ATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/ListN-ATP.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Program/SortList/Properties/Totality/ListN-ATP.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": 291, "size": 1210 }
module Day5 where open import Prelude.String as String open import Data.Maybe open import Foreign.Haskell using (Unit) open import Prelude.List as List open import Data.Nat open import Data.Nat.DivMod open import Data.Nat.Properties import Data.Nat.Show as ℕs open import Prelude.Char open import Data.Vec as Vec renaming (_>>=_ to _VV=_ ; toList to VecToList) open import Data.Product open import Relation.Nullary open import Data.Nat.Properties open import Data.Bool.Base open import AocIO open import AocUtil open import AocVec open import Relation.Binary.PropositionalEquality open import EvenOdd open import Prelude.Int unsafeParseInt : List Char → Int unsafeParseInt ('-' ∷ ls) with (unsafeParseNat ls) ... | zero = pos zero ... | suc n = negsuc n unsafeParseInt ls = pos (unsafeParseNat ls) main : IO Unit main = mainBuilder (readFileMain process-file) where process-file : String → IO Unit process-file file-content with lines (unpackString file-content) ... | file-lines with List.map unsafeParseInt file-lines ... | instructions with List.map (λ n → printString (primShowInteger n)) instructions ... | io-ops = void (sequence-io-prim io-ops)
{ "alphanum_fraction": 0.7595258256, "avg_line_length": 28.119047619, "ext": "agda", "hexsha": "c4349edcf710d70f6a4e00bc6fbf6f6092318ae8", "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": "37956e581dc51bf78008d7dd902bb18d2ee481f6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Zalastax/adventofcode2017", "max_forks_repo_path": "day-5/Day5.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37956e581dc51bf78008d7dd902bb18d2ee481f6", "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": "Zalastax/adventofcode2017", "max_issues_repo_path": "day-5/Day5.agda", "max_line_length": 89, "max_stars_count": null, "max_stars_repo_head_hexsha": "37956e581dc51bf78008d7dd902bb18d2ee481f6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Zalastax/adventofcode2017", "max_stars_repo_path": "day-5/Day5.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 299, "size": 1181 }
-- Andreas, 2016-01-21, issue 1791 -- With-clause stripping for copatterns with "polymorphic" field. -- {-# OPTIONS --show-implicit #-} -- {-# OPTIONS -v tc.with.strip:60 #-} postulate anything : ∀{A : Set} → A record Wrap (A : Set) : Set where field unwrap : A module VisibleWorks where -- monomorphic field record Pointed (M : Set → Set) : Set₁ where field point : ∀ A → M A test : Pointed Wrap Wrap.unwrap (Pointed.point test A) with Set₂ ... | _ = anything -- polymorphic field record Pointed (M : Set → Set) : Set₁ where field point : ∀{A} → M A module ExplicitWorks where test : Pointed Wrap Wrap.unwrap (Pointed.point test {A}) with Set₂ ... | _ = anything -- WAS: hidden fails test : Pointed Wrap Wrap.unwrap (Pointed.point test) with Set₂ ... | _ = anything -- should succeed
{ "alphanum_fraction": 0.6537059538, "avg_line_length": 20.0731707317, "ext": "agda", "hexsha": "e41b59464e3f84439a9f14754145d011488d0458", "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/Issue1791-long.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/Issue1791-long.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue1791-long.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": 249, "size": 823 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.FinData.Base where open import Cubical.Foundations.Prelude open import Cubical.Data.Nat open import Cubical.Relation.Nullary data Fin : ℕ → Type₀ where zero : {n : ℕ} → Fin (suc n) suc : {n : ℕ} (i : Fin n) → Fin (suc n) toℕ : ∀ {n} → Fin n → ℕ toℕ zero = 0 toℕ (suc i) = suc (toℕ i) fromℕ : (n : ℕ) → Fin (suc n) fromℕ zero = zero fromℕ (suc n) = suc (fromℕ n) ¬Fin0 : ¬ Fin 0 ¬Fin0 ()
{ "alphanum_fraction": 0.6139240506, "avg_line_length": 21.5454545455, "ext": "agda", "hexsha": "82b2a9dade3422f1d463547b46dc5f598432be4f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "RobertHarper/cubical", "max_forks_repo_path": "Cubical/Data/FinData/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "RobertHarper/cubical", "max_issues_repo_path": "Cubical/Data/FinData/Base.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "d13941587a58895b65f714f1ccc9c1f5986b109c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "RobertHarper/cubical", "max_stars_repo_path": "Cubical/Data/FinData/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 189, "size": 474 }
{-# OPTIONS --allow-unsolved-metas #-} open import bool open import bool-thms2 open import eq open import maybe open import product open import product-thms open import bool-relations using (transitive ; total) module z05-01-hc-sorted-list (A : Set) -- type of elements (_≤A_ : A → A → 𝔹) -- ordering function (≤A-trans : transitive _≤A_) -- proof of transitivity of given ordering (≤A-total : total _≤A_) -- proof of totality of given ordering where open import bool-relations _≤A_ hiding (transitive ; total) open import minmax _≤A_ ≤A-trans ≤A-total data slist : A → A → Set where snil : ∀ {l u : A} → l ≤A u ≡ tt → slist l u scons : ∀ {l u : A} → (d : A) -- value stored at head → slist l u -- elements to the right ≥ stored value → d ≤A l ≡ tt → slist (min d l) (max d u) slist-insert : ∀ {l u : A} → (d : A) -- insert 'd' → slist l u -- into this 'bst' → d ≤A l ≡ tt → slist (min d l) (max d u) -- type might change slist-insert d (snil l≤Au) d≤Al≡tt = scons d (snil l≤Au) d≤Al≡tt slist-insert d (scons d' xs d'≤Al≡tt) d≤Al≡tt with keep (d ≤A d') slist-insert d L@(scons d' xs d'≤Al≡tt) d≤Al≡tt | tt , p = scons d L d≤Al≡tt slist-insert d L@(scons d' xs d'≤Al≡tt) d≤Al≡tt | ff , p = {!!}
{ "alphanum_fraction": 0.5492857143, "avg_line_length": 32.5581395349, "ext": "agda", "hexsha": "57bdbdb0f1ec97ea65754e1b80c1e52f1140e7e1", "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/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-01-hc-sorted-list.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/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-01-hc-sorted-list.agda", "max_line_length": 76, "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/2015-Verified_Functional_programming_in_Agda-Stump/ial/z05-01-hc-sorted-list.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": 501, "size": 1400 }
{-# OPTIONS --cubical --safe #-} module Cubical.HITs.Truncation where open import Cubical.HITs.Truncation.Base public open import Cubical.HITs.Truncation.Properties public
{ "alphanum_fraction": 0.7976878613, "avg_line_length": 28.8333333333, "ext": "agda", "hexsha": "1f6140abcf88fe1abde2cf1de80e193093b6ed66", "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/Truncation.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/Truncation.agda", "max_line_length": 53, "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/Truncation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 46, "size": 173 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Groups.Definition open import Setoids.Setoids open import Rings.Definition open import Sets.EquivalenceRelations open import Rings.Ideals.Definition open import Rings.IntegralDomains.Definition open import Rings.Ideals.Prime.Definition open import Rings.Cosets module Rings.Ideals.Prime.Lemmas {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} {c : _} {pred : A → Set c} (i : Ideal R pred) where open Ring R open Group additiveGroup open Setoid S open Equivalence eq open import Rings.Ideals.Lemmas R idealPrimeImpliesQuotientIntDom : PrimeIdeal i → IntegralDomain (cosetRing R i) IntegralDomain.intDom (idealPrimeImpliesQuotientIntDom isPrime) {a} {b} ab=0 a!=0 = ans where ab=0' : pred (a * b) ab=0' = translate' i ab=0 a!=0' : (pred a) → False a!=0' prA = a!=0 (translate i prA) ans' : pred b ans' = PrimeIdeal.isPrime isPrime ab=0' a!=0' ans : pred (inverse (Ring.0R (cosetRing R i)) + b) ans = translate i ans' IntegralDomain.nontrivial (idealPrimeImpliesQuotientIntDom isPrime) 1=0 = PrimeIdeal.notContainedIsNotContained isPrime u where t : pred (Ring.1R (cosetRing R i)) t = translate' i 1=0 u : pred (PrimeIdeal.notContained isPrime) u = Ideal.isSubset i identIsIdent (Ideal.accumulatesTimes i {y = PrimeIdeal.notContained isPrime} t) quotientIntDomImpliesIdealPrime : IntegralDomain (cosetRing R i) → PrimeIdeal i quotientIntDomImpliesIdealPrime intDom = record { isPrime = isPrime ; notContained = Ring.1R R ; notContainedIsNotContained = notCon } where abstract notCon : pred 1R → False notCon 1=0 = IntegralDomain.nontrivial intDom (translate i 1=0) isPrime : {a b : A} → pred (a * b) → (pred a → False) → pred b isPrime {a} {b} predAB !predA = translate' i (IntegralDomain.intDom intDom (translate i predAB) λ t → !predA (translate' i t)) private dividesZero : {a : A} → generatedIdealPred R 0R a → a ∼ 0R dividesZero (c , pr) = symmetric (transitive (symmetric (transitive *Commutative timesZero)) pr) zeroIdealPrimeImpliesIntDom : PrimeIdeal (generatedIdeal R 0R) → IntegralDomain R IntegralDomain.intDom (zeroIdealPrimeImpliesIntDom record { isPrime = isPrime ; notContained = notContained ; notContainedIsNotContained = notContainedIsNotContained }) {a} {b} ab=0 a!=0 with isPrime {a} {b} (1R , transitive (transitive *Commutative timesZero) (symmetric ab=0)) (λ 0|a → a!=0 (dividesZero 0|a)) ... | c , 0c=b = transitive (symmetric 0c=b) (transitive *Commutative timesZero) IntegralDomain.nontrivial (zeroIdealPrimeImpliesIntDom record { isPrime = isPrime ; notContained = notContained ; notContainedIsNotContained = notContainedIsNotContained }) 1=0 = notContainedIsNotContained (notContained , transitive (*WellDefined (symmetric 1=0) reflexive) identIsIdent) intDomImpliesZeroIdealPrime : IntegralDomain R → PrimeIdeal (generatedIdeal R 0R) PrimeIdeal.isPrime (intDomImpliesZeroIdealPrime intDom) (c , 0=ab) 0not|a with IntegralDomain.intDom intDom (transitive (symmetric 0=ab) (transitive *Commutative timesZero)) (λ a=0 → 0not|a (0R , transitive timesZero (symmetric a=0))) ... | b=0 = 0R , transitive timesZero (symmetric b=0) PrimeIdeal.notContained (intDomImpliesZeroIdealPrime intDom) = 1R PrimeIdeal.notContainedIsNotContained (intDomImpliesZeroIdealPrime intDom) (c , 0c=1) = IntegralDomain.nontrivial intDom (symmetric (transitive (symmetric (transitive *Commutative timesZero)) 0c=1)) primeIdealWellDefined : {c : _} {pred2 : A → Set c} (ideal2 : Ideal R pred2) → ({x : A} → pred x → pred2 x) → ({x : A} → pred2 x → pred x) → PrimeIdeal i → PrimeIdeal ideal2 PrimeIdeal.isPrime (primeIdealWellDefined ideal2 predToPred2 pred2ToPred record { isPrime = isPrime ; notContained = notContained ; notContainedIsNotContained = notContainedIsNotContained }) p2ab notP2a = predToPred2 (isPrime (pred2ToPred p2ab) λ p → notP2a (predToPred2 p)) PrimeIdeal.notContained (primeIdealWellDefined ideal2 predToPred2 pred2ToPred record { isPrime = isPrime ; notContained = notContained ; notContainedIsNotContained = notContainedIsNotContained }) = notContained PrimeIdeal.notContainedIsNotContained (primeIdealWellDefined ideal2 predToPred2 pred2ToPred record { isPrime = isPrime ; notContained = notContained ; notContainedIsNotContained = notContainedIsNotContained }) pred2Not = notContainedIsNotContained (pred2ToPred pred2Not)
{ "alphanum_fraction": 0.7508944544, "avg_line_length": 65.7647058824, "ext": "agda", "hexsha": "0d8fcefa0216b9d30dd0fcf60b1444da3d74f82c", "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/Ideals/Prime/Lemmas.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/Ideals/Prime/Lemmas.agda", "max_line_length": 311, "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/Ideals/Prime/Lemmas.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": 1381, "size": 4472 }
{-A Polynomials over commutative rings ================================== -} {-# OPTIONS --safe #-} ---------------------------------- module Cubical.Algebra.Polynomials.Univariate.Base where open import Cubical.HITs.PropositionalTruncation open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.Data.Nat renaming (_+_ to _Nat+_; _·_ to _Nat·_) hiding (·-comm) open import Cubical.Data.Nat.Order open import Cubical.Data.Empty.Base renaming (rec to ⊥rec ) open import Cubical.Data.Bool open import Cubical.Algebra.Group hiding (Bool) open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing ------------------------------------------------------------------------------------ private variable ℓ ℓ' : Level A : Type ℓ module PolyMod (R' : CommRing ℓ) where private R = fst R' open CommRingStr (snd R') public ------------------------------------------------------------------------------------------- -- First definition of a polynomial. -- A polynomial a₁ + a₂x + ... + aⱼxʲ of degree j is represented as a list [a₁, a₂, ...,aⱼ] -- modulo trailing zeros. ------------------------------------------------------------------------------------------- data Poly : Type ℓ where [] : Poly _∷_ : (a : R) → (p : Poly) → Poly drop0 : 0r ∷ [] ≡ [] infixr 5 _∷_ module Elim (B : Poly → Type ℓ') ([]* : B []) (cons* : (r : R) (p : Poly) (b : B p) → B (r ∷ p)) (drop0* : PathP (λ i → B (drop0 i)) (cons* 0r [] []*) []*) where f : (p : Poly) → B p f [] = []* f (x ∷ p) = cons* x p (f p) f (drop0 i) = drop0* i -- Given a proposition (as type) ϕ ranging over polynomials, we prove it by: -- ElimProp.f ϕ ⌜proof for base case []⌝ ⌜proof for induction case a ∷ p⌝ -- ⌜proof that ϕ actually is a proposition over the domain of polynomials⌝ module ElimProp (B : Poly → Type ℓ') ([]* : B []) (cons* : (r : R) (p : Poly) (b : B p) → B (r ∷ p)) (BProp : {p : Poly} → isProp (B p)) where f : (p : Poly) → B p f = Elim.f B []* cons* (toPathP (BProp (transport (λ i → B (drop0 i)) (cons* 0r [] []*)) []*)) module Rec (B : Type ℓ') ([]* : B) (cons* : R → B → B) (drop0* : cons* 0r []* ≡ []*) (Bset : isSet B) where f : Poly → B f = Elim.f (λ _ → B) []* (λ r p b → cons* r b) drop0* module RecPoly ([]* : Poly) (cons* : R → Poly → Poly) (drop0* : cons* 0r []* ≡ []*) where f : Poly → Poly f [] = []* f (a ∷ p) = cons* a (f p) f (drop0 i) = drop0* i -------------------------------------------------------------------------------------------------- -- Second definition of a polynomial. The purpose of this second definition is to -- facilitate the proof that the first definition is a set. The two definitions are -- then shown to be equivalent. -- A polynomial a₀ + a₁x + ... + aⱼxʲ of degree j is represented as a function f -- such that for i ∈ ℕ we have f(i) = aᵢ if i ≤ j, and 0 for i > j -------------------------------------------------------------------------------------------------- PolyFun : Type ℓ PolyFun = Σ[ p ∈ (ℕ → R) ] (∃[ n ∈ ℕ ] ((m : ℕ) → n ≤ m → p m ≡ 0r)) isSetPolyFun : isSet PolyFun isSetPolyFun = isSetΣSndProp (isSetΠ (λ x → isSetCommRing R')) λ f x y → squash x y --construction of the function that represents the polynomial Poly→Fun : Poly → (ℕ → R) Poly→Fun [] = (λ _ → 0r) Poly→Fun (a ∷ p) = (λ n → if isZero n then a else Poly→Fun p (predℕ n)) Poly→Fun (drop0 i) = lemma i where lemma : (λ n → if isZero n then 0r else 0r) ≡ (λ _ → 0r) lemma i zero = 0r lemma i (suc n) = 0r Poly→Prf : (p : Poly) → ∃[ n ∈ ℕ ] ((m : ℕ) → n ≤ m → (Poly→Fun p m ≡ 0r)) Poly→Prf = ElimProp.f (λ p → ∃[ n ∈ ℕ ] ((m : ℕ) → n ≤ m → (Poly→Fun p m ≡ 0r))) ∣ 0 , (λ m ineq → refl) ∣ (λ r p → map ( λ (n , ineq) → (suc n) , λ { zero h → ⊥rec (znots (sym (≤0→≡0 h))) ; (suc m) h → ineq m (pred-≤-pred h) } ) ) squash Poly→PolyFun : Poly → PolyFun Poly→PolyFun p = (Poly→Fun p) , (Poly→Prf p) ---------------------------------------------------- -- Start of code by Anders Mörtberg and Evan Cavallo at0 : (ℕ → R) → R at0 f = f 0 atS : (ℕ → R) → (ℕ → R) atS f n = f (suc n) polyEq : (p p' : Poly) → Poly→Fun p ≡ Poly→Fun p' → p ≡ p' polyEq [] [] _ = refl polyEq [] (a ∷ p') α = sym drop0 ∙∙ cong₂ _∷_ (cong at0 α) (polyEq [] p' (cong atS α)) ∙∙ refl polyEq [] (drop0 j) α k = hcomp (λ l → λ { (j = i1) → drop0 l ; (k = i0) → drop0 l ; (k = i1) → drop0 (j ∧ l) }) (is-set 0r 0r (cong at0 α) refl j k ∷ []) polyEq (a ∷ p) [] α = refl ∙∙ cong₂ _∷_ (cong at0 α) (polyEq p [] (cong atS α)) ∙∙ drop0 polyEq (a ∷ p) (a₁ ∷ p') α = cong₂ _∷_ (cong at0 α) (polyEq p p' (cong atS α)) polyEq (a ∷ p) (drop0 j) α k = hcomp -- filler (λ l → λ { (k = i0) → a ∷ p ; (k = i1) → drop0 (j ∧ l) ; (j = i0) → at0 (α k) ∷ polyEq p [] (cong atS α) k }) (at0 (α k) ∷ polyEq p [] (cong atS α) k) polyEq (drop0 i) [] α k = hcomp (λ l → λ { (i = i1) → drop0 l ; (k = i0) → drop0 (i ∧ l) ; (k = i1) → drop0 l }) (is-set 0r 0r (cong at0 α) refl i k ∷ []) polyEq (drop0 i) (a ∷ p') α k = hcomp -- filler (λ l → λ { (k = i0) → drop0 (i ∧ l) ; (k = i1) → a ∷ p' ; (i = i0) → at0 (α k) ∷ polyEq [] p' (cong atS α) k }) (at0 (α k) ∷ polyEq [] p' (cong atS α) k) polyEq (drop0 i) (drop0 j) α k = hcomp (λ l → λ { (k = i0) → drop0 (i ∧ l) ; (k = i1) → drop0 (j ∧ l) ; (i = i0) (j = i0) → at0 (α k) ∷ [] ; (i = i1) (j = i1) → drop0 l }) (is-set 0r 0r (cong at0 α) refl (i ∧ j) k ∷ []) PolyFun→Poly+ : (q : PolyFun) → Σ[ p ∈ Poly ] Poly→Fun p ≡ q .fst PolyFun→Poly+ (f , pf) = rec lem (λ x → rem1 f (x .fst) (x .snd) , funExt (rem2 f (fst x) (snd x)) ) pf where lem : isProp (Σ[ p ∈ Poly ] Poly→Fun p ≡ f) lem (p , α) (p' , α') = ΣPathP (polyEq p p' (α ∙ sym α'), isProp→PathP (λ i → (isSetΠ λ _ → is-set) _ _) _ _) rem1 : (p : ℕ → R) (n : ℕ) → ((m : ℕ) → n ≤ m → p m ≡ 0r) → Poly rem1 p zero h = [] rem1 p (suc n) h = p 0 ∷ rem1 (λ x → p (suc x)) n (λ m x → h (suc m) (suc-≤-suc x)) rem2 : (f : ℕ → R) (n : ℕ) → (h : (m : ℕ) → n ≤ m → f m ≡ 0r) (m : ℕ) → Poly→Fun (rem1 f n h) m ≡ f m rem2 f zero h m = sym (h m zero-≤) rem2 f (suc n) h zero = refl rem2 f (suc n) h (suc m) = rem2 (λ x → f (suc x)) n (λ k p → h (suc k) (suc-≤-suc p)) m PolyFun→Poly : PolyFun → Poly PolyFun→Poly q = PolyFun→Poly+ q .fst PolyFun→Poly→PolyFun : (p : Poly) → PolyFun→Poly (Poly→PolyFun p) ≡ p PolyFun→Poly→PolyFun p = polyEq _ _ (PolyFun→Poly+ (Poly→PolyFun p) .snd) --End of code by Mörtberg and Cavallo ------------------------------------- isSetPoly : isSet Poly isSetPoly = isSetRetract Poly→PolyFun PolyFun→Poly PolyFun→Poly→PolyFun isSetPolyFun
{ "alphanum_fraction": 0.4359309623, "avg_line_length": 33.5438596491, "ext": "agda", "hexsha": "8f95645232eac3a685369021658034793ab097d5", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Algebra/Polynomials/Univariate/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Algebra/Polynomials/Univariate/Base.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Algebra/Polynomials/Univariate/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2728, "size": 7648 }
-- This module gives an introduction to the module system of Agda. module Introduction.Modules where --------------------------------------------------------------------------- -- Simple sub-modules --------------------------------------------------------------------------- -- As mentioned in 'Introduction.Basics' each file contains a single top-level -- module. This module can contain any number of sub-modules. A sub-module is -- declared in the same way as the top-level module, except that its name is -- not qualified. module Numbers where -- The contents of the top-level module do not have to be indented, but the -- contents of a sub-module do. data Nat : Set where zero : Nat suc : Nat -> Nat -- Outside a module its contents can be accessed using the name of the module. one : Numbers.Nat one = Numbers.suc Numbers.zero -- Of course, this would get very tedious after a while, so to bring the -- contents of a module into scope you can use an 'open' declaration. open Numbers two : Nat two = suc one -- When opening a module it is possible to control what names are brought into -- scope. The open declaration supports three modifiers : -- using (x1; ..; xn) only bring x1 .. xn into scope -- renaming (x to y;..) bring y into scope and make it refer to the name x -- from the opened module. -- hiding (x1; ..; xn) bring everything except x1 .. xn into scope -- The using and hiding modifiers can be combined with renaming but not with -- each other. -- For example, this will bring the names z and s (and nothing else) into -- scope as new names for zero and suc. open Numbers using () renaming (zero to z; suc to s) -- We can now pattern match on the renamed constructors. plus : Nat -> Nat -> Nat plus z m = m plus (s n) m = s (plus n m) --------------------------------------------------------------------------- -- 'private' and 'abstract' --------------------------------------------------------------------------- -- Above we saw how to control which names are brought into scope when opening -- a module. It is also possible to restrict what is visible outside a module -- by declaring things 'private'. Declaring something private will only prevent -- someone from using it outside the module, it doesn't prevent it from showing -- up after reduction, or from it to reduce. -- To prevent something from reducing (effectively hiding the definition) it -- can be declared 'abstract'. module Datastructures where private data List (A : Set) : Set where nil : List A _::_ : A -> List A -> List A _++_ : {A : Set} -> List A -> List A -> List A nil ++ ys = ys (x :: xs) ++ ys = x :: (xs ++ ys) reverse : {A : Set} -> List A -> List A reverse nil = nil reverse (x :: xs) = reverse xs ++ (x :: nil) -- Not making the stack operations abstract will reveal the underlying -- implementation, even though it's private. Stack : Set -> Set Stack A = List A emptyS : {A : Set} -> Stack A emptyS = nil push : {A : Set} -> A -> Stack A -> Stack A push x xs = x :: xs abstract -- An abstract datatype doesn't reveal its constructors data Queue (A : Set) : Set where queue : (front back : List A) -> Queue A -- invariant : if the front is -- empty, so is the back -- Abstraction is contagious, anything that pattern matches on a queue must -- also be abstract. private -- make sure the invariant is preserved flip : {A : Set} -> Queue A -> Queue A flip (queue nil back) = queue (reverse back) nil flip q = q -- these functions will not reduce outside the module emptyQ : {A : Set} -> Queue A emptyQ = queue nil nil enqueue : {A : Set} -> A -> Queue A -> Queue A enqueue x (queue front back) = flip (queue front (x :: back)) open Datastructures testS = push zero emptyS testQ = enqueue zero emptyQ
{ "alphanum_fraction": 0.5990495248, "avg_line_length": 32.2419354839, "ext": "agda", "hexsha": "b12c02101424875a03b0060b8b490d1425f21b6b", "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": "examples/Introduction/Modules.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/Introduction/Modules.agda", "max_line_length": 79, "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/Introduction/Modules.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": 948, "size": 3998 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Morphism.Cartesian where open import Level open import Categories.Category open import Categories.Functor hiding (_≡_; _∘_) record CartesianProperties {o₀ ℓ₀ e₀} {o₁ ℓ₁ e₁} {E : Category o₀ ℓ₀ e₀} {B : Category o₁ ℓ₁ e₁} {p : Functor E B} {e′ e} {φ : E [ e′ , e ]} {e′′ : Category.Obj E} {ψ : E [ e′′ , e ]} {g : B [ Functor.F₀ p e′′ , Functor.F₀ p e′ ]} (pf : Category._≡_ B (Category._∘_ B (Functor.F₁ p φ) g) (Functor.F₁ p ψ)) : Set (o₀ ⊔ ℓ₀ ⊔ e₀ ⊔ ℓ₁ ⊔ e₁) where private module E = Category E private module B = Category B open B using (_∘_; _≡_) open E using () renaming (_∘_ to _∘E_; _≡_ to _≡E_) open Functor p renaming (F₀ to p₀; F₁ to p₁) field χ : E [ e′′ , e′ ] ψ≡φ∘χ : ψ ≡E φ ∘E χ p₁[χ]≡g : p₁ χ ≡ g χ-unique : (f : E [ e′′ , e′ ]) → ψ ≡E φ ∘E f → p₁ f ≡ g → f ≡E χ record Cartesian {o₀ ℓ₀ e₀} {o₁ ℓ₁ e₁} {E : Category o₀ ℓ₀ e₀} {B : Category o₁ ℓ₁ e₁} (p : Functor E B) {e′ e} (φ : E [ e′ , e ]) : Set (o₀ ⊔ ℓ₀ ⊔ e₀ ⊔ ℓ₁ ⊔ e₁) where private module E = Category E private module B = Category B open B using (_∘_; _≡_) open E using () renaming (_∘_ to _∘E_; _≡_ to _≡E_) open Functor p renaming (F₀ to p₀; F₁ to p₁) field properties : ∀ {e′′} (ψ : E [ e′′ , e ]) (g : B [ p₀ e′′ , p₀ e′ ]) (pf : p₁ φ ∘ g ≡ p₁ ψ) → CartesianProperties {p = p} pf
{ "alphanum_fraction": 0.5155115512, "avg_line_length": 39.8684210526, "ext": "agda", "hexsha": "8d74f01636e8cee41a024c4bb7fa63892419a545", "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/Morphism/Cartesian.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/Morphism/Cartesian.agda", "max_line_length": 167, "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/Morphism/Cartesian.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": 623, "size": 1515 }
------------------------------------------------------------------------ -- Paolo Capriotti's variant of higher lenses ------------------------------------------------------------------------ {-# OPTIONS --cubical #-} import Equality.Path as P module Lens.Non-dependent.Higher.Capriotti {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq open import Logical-equivalence using (_⇔_) open import Prelude open import Bijection equality-with-J as B using (_↔_) open import Coherently-constant eq using (Coherently-constant) open import Equality.Decidable-UIP equality-with-J using (Constant) open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) open import Function-universe equality-with-J as F hiding (id; _∘_) open import H-level equality-with-J as H-level open import H-level.Closure equality-with-J open import H-level.Truncation.Propositional eq as T using (∥_∥; ∣_∣) open import Preimage equality-with-J open import Surjection equality-with-J using (_↠_) open import Univalence-axiom equality-with-J open import Lens.Non-dependent eq import Lens.Non-dependent.Higher eq as Higher import Lens.Non-dependent.Higher.Capriotti.Variant eq as Variant import Lens.Non-dependent.Traditional eq as Traditional private variable a b p : Level A B : Type a P Q : A → Type p ------------------------------------------------------------------------ -- Coherently-constant -- A preservation lemma for Coherently-constant. -- -- Note that P and Q must target the same universe. Coherently-constant-map : {P : A → Type p} {Q : B → Type p} → Univalence p → (f : B → A) → (∀ x → P (f x) ≃ Q x) → Coherently-constant P → Coherently-constant Q Coherently-constant-map {P = P} {Q = Q} univ f P≃Q (R , P≡R) = R ∘ T.∥∥-map f , ⟨ext⟩ λ x → ≃⇒≡ univ (Q x ↝⟨ inverse $ P≃Q x ⟩ P (f x) ↝⟨ ≡⇒≃ $ cong (_$ f x) P≡R ⟩□ R ∣ f x ∣ □) -- Coherently-constant is, in a certain sense, closed under Σ. -- -- This lemma is due to Paolo Capriotti. Coherently-constant-Σ : Coherently-constant P → Coherently-constant Q → Coherently-constant (λ x → ∃ λ (y : P x) → Q (x , y)) Coherently-constant-Σ {P = P} {Q = Q} (P′ , p) (Q′ , q) = (λ x → ∃ λ (y : P′ x) → Q′ (T.elim (λ x → P′ x → ∥ ∃ P ∥) (λ _ → Π-closure ext 1 λ _ → T.truncation-is-proposition) (λ x y → ∣ x , subst id (sym (p′ x)) y ∣) x y)) , (⟨ext⟩ λ x → ((∃ λ (y : P x) → Q (x , y)) ≡⟨ (cong (uncurry Σ) $ Σ-≡,≡→≡ (p′ x) $ ⟨ext⟩ λ y → subst (λ P → P → Type _) (p′ x) (λ y → Q (x , y)) y ≡⟨ subst-→-domain _ _ ⟩ Q (x , subst id (sym (p′ x)) y) ≡⟨ cong (_$ (x , subst id (sym (p′ x)) y)) q ⟩∎ Q′ ∣ x , subst id (sym (p′ x)) y ∣ ∎) ⟩∎ (∃ λ (y : P′ ∣ x ∣) → Q′ ∣ x , subst id (sym (p′ x)) y ∣) ∎)) where p′ : ∀ _ → _ p′ x = cong (_$ x) p -- If the domain of f is stable, then there is a split surjection from -- Constant f to Coherently-constant f. -- -- In "Notions of Anonymous Existence in Martin-Löf Type Theory" Kraus -- Escardó, Coquand and Altenkirch prove that Constant f implies -- Coherently-constant f when the domain of f is stable, and the other -- direction holds without the assumption. Constant↠Coherently-constant : {f : A → B} → (∥ A ∥ → A) → Constant f ↠ Coherently-constant f Constant↠Coherently-constant {f = f} s = record { logical-equivalence = record { to = λ c → f ∘ s , ⟨ext⟩ λ x → c x (s ∣ x ∣) ; from = λ (g , eq) x y → f x ≡⟨ cong (_$ x) eq ⟩ g ∣ x ∣ ≡⟨ cong g $ T.truncation-is-proposition ∣ x ∣ ∣ y ∣ ⟩ g ∣ y ∣ ≡⟨ cong (_$ y) $ sym eq ⟩∎ f y ∎ } ; right-inverse-of = λ (g , eq) → Σ-≡,≡→≡ (f ∘ s ≡⟨ cong (_∘ s) eq ⟩ g ∘ ∣_∣ ∘ s ≡⟨ (⟨ext⟩ λ x → cong g $ T.truncation-is-proposition ∣ s x ∣ x) ⟩∎ g ∎) (subst (λ g → f ≡ g ∘ ∣_∣) (trans (cong (_∘ s) eq) (⟨ext⟩ λ x → cong g (T.truncation-is-proposition ∣ s x ∣ x))) (⟨ext⟩ λ x → trans (cong (_$ x) eq) (trans (cong g (T.truncation-is-proposition ∣ x ∣ (∣ s ∣ x ∣ ∣))) (cong (_$ s ∣ x ∣) (sym eq)))) ≡⟨ trans (subst-∘ _ _ _) $ sym trans-subst ⟩ trans (⟨ext⟩ λ x → trans (cong (_$ x) eq) (trans (cong g (T.truncation-is-proposition ∣ x ∣ (∣ s ∣ x ∣ ∣))) (cong (_$ s ∣ x ∣) (sym eq)))) (cong (_∘ ∣_∣) $ trans (cong (_∘ s) eq) (⟨ext⟩ λ x → cong g (T.truncation-is-proposition ∣ s x ∣ x))) ≡⟨ cong₂ trans (trans (ext-trans _ _) $ cong₂ trans (_≃_.right-inverse-of (Eq.extensionality-isomorphism bad-ext) _) (trans (ext-trans _ _) $ cong (trans _) $ cong ⟨ext⟩ $ ⟨ext⟩ λ _ → trans (sym $ cong-∘ _ _ _) $ cong (cong _) $ cong-sym _ _)) (trans (cong-trans _ _ _) $ cong₂ trans (cong-∘ _ _ _) (cong-pre-∘-ext _)) ⟩ trans (trans eq (trans (⟨ext⟩ λ x → cong g (T.truncation-is-proposition ∣ x ∣ (∣ s ∣ x ∣ ∣))) (⟨ext⟩ λ x → cong (_$ x) (sym (cong (_∘ s ∘ ∣_∣) eq))))) (trans (cong (_∘ s ∘ ∣_∣) eq) (⟨ext⟩ λ x → cong g (T.truncation-is-proposition (∣ s ∣ x ∣ ∣) ∣ x ∣))) ≡⟨ trans (trans-assoc _ _ _) $ cong (trans _) $ trans (trans-assoc _ _ _) $ cong₂ trans (trans (cong ⟨ext⟩ $ ⟨ext⟩ λ _ → trans (cong (cong _) $ H-level.mono₁ 1 T.truncation-is-proposition _ _) $ cong-sym _ _) $ ext-sym _) (cong (flip trans _) $ _≃_.right-inverse-of (Eq.extensionality-isomorphism bad-ext) _) ⟩ trans eq (trans (sym $ ⟨ext⟩ λ x → cong g (T.truncation-is-proposition (∣ s ∣ x ∣ ∣) ∣ x ∣)) (trans (sym (cong (_∘ s ∘ ∣_∣) eq)) (trans (cong (_∘ s ∘ ∣_∣) eq) (⟨ext⟩ λ x → cong g (T.truncation-is-proposition (∣ s ∣ x ∣ ∣) ∣ x ∣))))) ≡⟨ trans (cong (trans _) $ trans (cong (trans _) $ trans-sym-[trans] _ _) $ trans-symˡ _) $ trans-reflʳ _ ⟩∎ eq ∎) } ------------------------------------------------------------------------ -- The lens type family -- Higher lenses, as presented by Paolo Capriotti, who seems to have -- been first to describe a notion of higher lens -- (http://homotopytypetheory.org/2014/04/29/higher-lenses/). Lens : Type a → Type b → Type (lsuc (a ⊔ b)) Lens A B = ∃ λ (get : A → B) → Coherently-constant (get ⁻¹_) -- Some derived definitions (based on Paolo's presentation). module Lens {A : Type a} {B : Type b} (l : Lens A B) where -- A getter. get : A → B get = proj₁ l -- A predicate. H : Pow a ∥ B ∥ H = proj₁ (proj₂ l) -- An equality. get⁻¹-≡ : (get ⁻¹_) ≡ H ∘ ∣_∣ get⁻¹-≡ = proj₂ (proj₂ l) -- An equivalence. get⁻¹-≃ : ∀ b → get ⁻¹ b ≃ H ∣ b ∣ get⁻¹-≃ = ≡⇒≃ ∘ ext⁻¹ get⁻¹-≡ -- All the getter's fibres are equivalent. get⁻¹-constant : (b₁ b₂ : B) → get ⁻¹ b₁ ≃ get ⁻¹ b₂ get⁻¹-constant b₁ b₂ = get ⁻¹ b₁ ↝⟨ get⁻¹-≃ b₁ ⟩ H ∣ b₁ ∣ ↝⟨ ≡⇒≃ $ cong H $ T.truncation-is-proposition _ _ ⟩ H ∣ b₂ ∣ ↝⟨ inverse $ get⁻¹-≃ b₂ ⟩□ get ⁻¹ b₂ □ -- A setter. set : A → B → A set a b = $⟨ _≃_.to (get⁻¹-constant (get a) b) ⟩ (get ⁻¹ get a → get ⁻¹ b) ↝⟨ _$ (a , refl _) ⟩ get ⁻¹ b ↝⟨ proj₁ ⟩□ A □ instance -- The lenses defined above have getters and setters. has-getter-and-setter : Has-getter-and-setter (Lens {a = a} {b = b}) has-getter-and-setter = record { get = Lens.get ; set = Lens.set } ------------------------------------------------------------------------ -- Equality characterisation lemmas -- An equality characterisation lemma. equality-characterisation₁ : {l₁ l₂ : Lens A B} → let open Lens in (l₁ ≡ l₂) ≃ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (h : ∀ b → H l₁ b ≡ H l₂ b) → trans (sym (cong _⁻¹_ (⟨ext⟩ g))) (trans (get⁻¹-≡ l₁) (⟨ext⟩ (h ∘ ∣_∣))) ≡ get⁻¹-≡ l₂) equality-characterisation₁ {A = A} {B = B} {l₁ = l₁} {l₂ = l₂} = l₁ ≡ l₂ ↝⟨ inverse $ Eq.≃-≡ $ Eq.↔⇒≃ Σ-assoc ⟩ ((get l₁ , H l₁) , get⁻¹-≡ l₁) ≡ ((get l₂ , H l₂) , get⁻¹-≡ l₂) ↔⟨ inverse B.Σ-≡,≡↔≡ ⟩ (∃ λ (eq : (get l₁ , H l₁) ≡ (get l₂ , H l₂)) → subst (λ (g , H) → g ⁻¹_ ≡ H ∘ ∣_∣) eq (get⁻¹-≡ l₁) ≡ get⁻¹-≡ l₂) ↝⟨ (Σ-cong-contra ≡×≡↔≡ λ _ → F.id) ⟩ (∃ λ ((g , h) : get l₁ ≡ get l₂ × H l₁ ≡ H l₂) → subst (λ (g , H) → g ⁻¹_ ≡ H ∘ ∣_∣) (cong₂ _,_ g h) (get⁻¹-≡ l₁) ≡ get⁻¹-≡ l₂) ↔⟨ inverse Σ-assoc ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (h : H l₁ ≡ H l₂) → subst (λ (g , H) → g ⁻¹_ ≡ H ∘ ∣_∣) (cong₂ _,_ g h) (get⁻¹-≡ l₁) ≡ get⁻¹-≡ l₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ≡⇒↝ _ $ cong (_≡ _) $ lemma _ _) ⟩ (∃ λ (g : get l₁ ≡ get l₂) → ∃ λ (h : H l₁ ≡ H l₂) → trans (sym (cong _⁻¹_ g)) (trans (get⁻¹-≡ l₁) (cong (_∘ ∣_∣) h)) ≡ get⁻¹-≡ l₂) ↝⟨ (Σ-cong-contra (Eq.extensionality-isomorphism bad-ext) λ _ → Σ-cong-contra (Eq.extensionality-isomorphism bad-ext) λ _ → F.id) ⟩ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (h : ∀ b → H l₁ b ≡ H l₂ b) → trans (sym (cong _⁻¹_ (⟨ext⟩ g))) (trans (get⁻¹-≡ l₁) (cong (_∘ ∣_∣) (⟨ext⟩ h))) ≡ get⁻¹-≡ l₂) ↝⟨ (∃-cong λ _ → ∃-cong λ _ → ≡⇒↝ _ $ cong (λ eq → trans _ (trans _ eq) ≡ _) $ cong-pre-∘-ext _) ⟩□ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (h : ∀ b → H l₁ b ≡ H l₂ b) → trans (sym (cong _⁻¹_ (⟨ext⟩ g))) (trans (get⁻¹-≡ l₁) (⟨ext⟩ (h ∘ ∣_∣))) ≡ get⁻¹-≡ l₂) □ where open Lens lemma : ∀ _ (h : H l₁ ≡ H l₂) → _ lemma g h = subst (λ (g , H) → g ⁻¹_ ≡ H ∘ ∣_∣) (cong₂ _,_ g h) (get⁻¹-≡ l₁) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (λ (g , _) → g ⁻¹_) (cong₂ _,_ g h))) (trans (get⁻¹-≡ l₁) (cong (λ (_ , H) → H ∘ ∣_∣) (cong₂ _,_ g h))) ≡⟨ cong₂ (λ p q → trans (sym p) (trans (get⁻¹-≡ l₁) q)) (trans (sym $ cong-∘ _ _ _) $ cong (cong _⁻¹_) $ cong-proj₁-cong₂-, _ _) (trans (sym $ cong-∘ _ _ _) $ cong (cong (_∘ ∣_∣)) $ cong-proj₂-cong₂-, _ h) ⟩∎ trans (sym (cong _⁻¹_ g)) (trans (get⁻¹-≡ l₁) (cong (_∘ ∣_∣) h)) ∎ -- Another equality characterisation lemma. equality-characterisation₂ : {A : Type a} {B : Type b} {l₁ l₂ : Lens A B} (univ : Univalence (a ⊔ b)) → let open Lens in (l₁ ≡ l₂) ≃ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (h : ∀ b → H l₁ b ≃ H l₂ b) → trans (sym (cong _⁻¹_ (⟨ext⟩ g))) (trans (get⁻¹-≡ l₁) (⟨ext⟩ (≃⇒≡ univ ∘ h ∘ ∣_∣))) ≡ get⁻¹-≡ l₂) equality-characterisation₂ {A = A} {B = B} {l₁ = l₁} {l₂ = l₂} univ = l₁ ≡ l₂ ↝⟨ equality-characterisation₁ ⟩ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (h : ∀ b → H l₁ b ≡ H l₂ b) → trans (sym (cong _⁻¹_ (⟨ext⟩ g))) (trans (get⁻¹-≡ l₁) (⟨ext⟩ (h ∘ ∣_∣))) ≡ get⁻¹-≡ l₂) ↝⟨ (∃-cong λ _ → Σ-cong-contra (∀-cong ext λ _ → inverse $ ≡≃≃ univ) λ _ → F.id) ⟩□ (∃ λ (g : ∀ a → get l₁ a ≡ get l₂ a) → ∃ λ (h : ∀ b → H l₁ b ≃ H l₂ b) → trans (sym (cong _⁻¹_ (⟨ext⟩ g))) (trans (get⁻¹-≡ l₁) (⟨ext⟩ (≃⇒≡ univ ∘ h ∘ ∣_∣))) ≡ get⁻¹-≡ l₂) □ where open Lens ------------------------------------------------------------------------ -- Conversions between different kinds of lenses -- Variant.Coherently-constant P is equivalent to -- Coherently-constant P (assuming univalence). Variant-coherently-constant≃Coherently-constant : {P : A → Type p} → Univalence p → Variant.Coherently-constant P ≃ Coherently-constant P Variant-coherently-constant≃Coherently-constant {A = A} {p = p} {P = P} univ = Variant.Coherently-constant P ↔⟨⟩ (∃ λ (H : ∥ A ∥ → Type p) → ∀ b → P b ≃ H ∣ b ∣) ↝⟨ (∃-cong λ _ → ∀-cong ext λ _ → inverse $ ≡≃≃ univ) ⟩ (∃ λ (H : ∥ A ∥ → Type p) → ∀ b → P b ≡ H ∣ b ∣) ↝⟨ (∃-cong λ _ → Eq.extensionality-isomorphism bad-ext) ⟩ (∃ λ (H : ∥ A ∥ → Type p) → P ≡ H ∘ ∣_∣) ↔⟨⟩ Coherently-constant P □ -- The lenses defined above are equivalent to those defined in Variant -- (assuming univalence). Variant-lens≃Lens : {A : Type a} {B : Type b} → Block "conversion" → Univalence (a ⊔ b) → Variant.Lens A B ≃ Lens A B Variant-lens≃Lens {a = a} {A = A} {B = B} ⊠ univ = Variant.Lens A B ↔⟨⟩ (∃ λ (get : A → B) → Variant.Coherently-constant (get ⁻¹_)) ↝⟨ (∃-cong λ _ → Variant-coherently-constant≃Coherently-constant univ) ⟩ (∃ λ (get : A → B) → Coherently-constant (get ⁻¹_)) ↔⟨⟩ Lens A B □ -- The conversion preserves getters and setters. Variant-lens≃Lens-preserves-getters-and-setters : {A : Type a} {B : Type b} (bc : Block "conversion") (univ : Univalence (a ⊔ b)) → Preserves-getters-and-setters-⇔ A B (_≃_.logical-equivalence (Variant-lens≃Lens bc univ)) Variant-lens≃Lens-preserves-getters-and-setters {A = A} {B = B} bc@⊠ univ = Preserves-getters-and-setters-→-↠-⇔ (_≃_.surjection (Variant-lens≃Lens bc univ)) λ l → refl _ , ⟨ext⟩ λ a → ⟨ext⟩ λ b → (let eq₁ = cong (H l) $ T.truncation-is-proposition ∣ get l a ∣ ∣ b ∣ eq₂ = ⟨ext⟩ (≃⇒≡ univ ∘ get⁻¹-≃ l) in proj₁ (_≃_.from (≡⇒≃ (cong (_$ b) eq₂)) (≡⇒→ eq₁ (≡⇒→ (cong (_$ get l a) eq₂) (a , refl _)))) ≡⟨ cong₂ (λ p q → proj₁ (_≃_.from p (≡⇒→ eq₁ (_≃_.to q (a , refl _))))) (lemma l _) (lemma l _) ⟩∎ proj₁ (_≃_.from (get⁻¹-≃ l b) (≡⇒→ eq₁ (_≃_.to (get⁻¹-≃ l (get l a)) (a , refl _)))) ∎) where open Variant.Lens lemma : ∀ (l : Variant.Lens A B) b → ≡⇒≃ (cong (_$ b) (⟨ext⟩ (≃⇒≡ univ ∘ get⁻¹-≃ l))) ≡ get⁻¹-≃ l b lemma l b = ≡⇒≃ (cong (_$ b) (⟨ext⟩ (≃⇒≡ univ ∘ get⁻¹-≃ l))) ≡⟨ cong ≡⇒≃ $ cong-ext (≃⇒≡ univ ∘ get⁻¹-≃ l) ⟩ ≡⇒≃ (≃⇒≡ univ (get⁻¹-≃ l b)) ≡⟨ _≃_.right-inverse-of (≡≃≃ univ) _ ⟩∎ get⁻¹-≃ l b ∎ -- The lenses defined above are equivalent to those defined in Higher -- (assuming univalence). Lens≃Higher-lens : {A : Type a} {B : Type b} → Block "conversion" → Univalence (a ⊔ b) → Lens A B ≃ Higher.Lens A B Lens≃Higher-lens {A = A} {B = B} bc univ = Lens A B ↝⟨ inverse $ Variant-lens≃Lens bc univ ⟩ Variant.Lens A B ↝⟨ Variant.Lens≃Higher-lens bc univ ⟩□ Higher.Lens A B □ -- The conversion preserves getters and setters. Lens≃Higher-lens-preserves-getters-and-setters : {A : Type a} {B : Type b} (bc : Block "conversion") (univ : Univalence (a ⊔ b)) → Preserves-getters-and-setters-⇔ A B (_≃_.logical-equivalence (Lens≃Higher-lens bc univ)) Lens≃Higher-lens-preserves-getters-and-setters bc univ = Preserves-getters-and-setters-⇔-∘ {f = _≃_.logical-equivalence $ Variant.Lens≃Higher-lens bc univ} (Variant.Lens≃Higher-lens-preserves-getters-and-setters bc univ) (Preserves-getters-and-setters-⇔-inverse {f = _≃_.logical-equivalence $ Variant-lens≃Lens bc univ} (Variant-lens≃Lens-preserves-getters-and-setters bc univ)) -- An alternative proof showing that Lens A B is equivalent to -- Higher.Lens A B (assuming univalence). -- -- This proof was simplified following a suggestion by Paolo -- Capriotti. -- -- I have not proved that this equivalence preserves getters and -- setters. Lens≃Higher-lens′ : {A : Type a} {B : Type b} → Univalence (a ⊔ b) → Lens A B ≃ Higher.Lens A B Lens≃Higher-lens′ {a = a} {b = b} {A = A} {B = B} univ = (∃ λ (g : A → B) → ∃ λ (H : Pow a ∥ B ∥) → (g ⁻¹_) ≡ H ∘ ∣_∣) ↔⟨ Σ-cong lemma₂ (λ _ → ∃-cong (lemma₃ _)) ⟩ (∃ λ (p : ∃ λ (P : Pow a B) → A ≃ ∃ P) → ∃ λ (H : Pow a ∥ B ∥) → proj₁ p ≡ H ∘ ∣_∣) ↔⟨ ∃-comm ⟩ (∃ λ (H : Pow a ∥ B ∥) → ∃ λ (p : ∃ λ (P : Pow a B) → A ≃ ∃ P) → proj₁ p ≡ H ∘ ∣_∣) ↔⟨ (∃-cong λ _ → inverse Σ-assoc) ⟩ (∃ λ (H : Pow a ∥ B ∥) → ∃ λ (P : Pow a B) → A ≃ ∃ P × P ≡ H ∘ ∣_∣) ↔⟨ (∃-cong λ _ → ∃-cong λ _ → ×-comm) ⟩ (∃ λ (H : Pow a ∥ B ∥) → ∃ λ (P : Pow a B) → P ≡ H ∘ ∣_∣ × A ≃ ∃ P) ↔⟨ (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ eq → Eq.≃-preserves ext F.id (∃-cong λ x → ≡⇒↝ _ (cong (_$ x) eq))) ⟩ (∃ λ (H : Pow a ∥ B ∥) → ∃ λ (P : Pow a B) → P ≡ H ∘ ∣_∣ × A ≃ ∃ (H ∘ ∣_∣)) ↔⟨ (∃-cong λ _ → Σ-assoc) ⟩ (∃ λ (H : Pow a ∥ B ∥) → (∃ λ (P : Pow a B) → P ≡ H ∘ ∣_∣) × A ≃ ∃ (H ∘ ∣_∣)) ↔⟨ (∃-cong λ _ → drop-⊤-left-× λ _ → _⇔_.to contractible⇔↔⊤ (singleton-contractible _)) ⟩ (∃ λ (H : Pow a ∥ B ∥) → A ≃ ∃ (H ∘ ∣_∣)) ↔⟨ inverse $ Σ-cong (inverse $ Pow↔Fam a ext univ) (λ _ → Eq.≃-preserves ext F.id F.id) ⟩ (∃ λ (H : Fam a ∥ B ∥) → A ≃ ∃ ((proj₂ H ⁻¹_) ∘ ∣_∣)) ↔⟨ inverse Σ-assoc ⟩ (∃ λ (R : Type ℓ) → ∃ λ (f : R → ∥ B ∥) → A ≃ ∃ ((f ⁻¹_) ∘ ∣_∣)) ↔⟨ (∃-cong λ R → ∃-cong λ f → Eq.≃-preserves ext F.id (∃ ((f ⁻¹_) ∘ ∣_∣) ↔⟨ (∃-cong λ b → drop-⊤-right λ r → _⇔_.to contractible⇔↔⊤ $ +⇒≡ T.truncation-is-proposition) ⟩ B × R ↔⟨ ×-comm ⟩□ R × B □)) ⟩ (∃ λ (R : Type ℓ) → (R → ∥ B ∥) × (A ≃ (R × B))) ↔⟨ (∃-cong λ _ → ×-comm) ⟩ (∃ λ (R : Type ℓ) → (A ≃ (R × B)) × (R → ∥ B ∥)) ↔⟨ inverse Higher.Lens-as-Σ ⟩□ Higher.Lens A B □ where ℓ = a ⊔ b lemma₁ : ∀ (g : A → B) b → g ⁻¹ b ↔ (g ∘ lower {ℓ = ℓ}) ⁻¹ b lemma₁ g b = record { surjection = record { logical-equivalence = record { to = λ { (a , ga≡b) → lift a , ga≡b } ; from = λ { (lift a , ga≡b) → a , ga≡b } } ; right-inverse-of = refl } ; left-inverse-of = refl } abstract lemma₂ : (A → B) ↔ ∃ λ (P : Pow a B) → A ≃ ∃ P lemma₂ = →↔Σ≃Σ ℓ ext univ lemma₃ : (g : A → B) (H : Pow a ∥ B ∥) → ((g ⁻¹_) ≡ H ∘ ∣_∣) ≃ (proj₁ (_↔_.to lemma₂ g) ≡ H ∘ ∣_∣) lemma₃ g H = let lemma = F.id ≡⟨ sym ≡⇒↝-refl ⟩ ≡⇒↝ _ (refl _) ≡⟨ cong (≡⇒↝ _) $ sym sym-refl ⟩∎ ≡⇒↝ _ (sym (refl _)) ∎ in (g ⁻¹_) ≡ H ∘ ∣_∣ ↝⟨ inverse $ Eq.extensionality-isomorphism ext ⟩ (∀ b → g ⁻¹ b ≡ H ∣ b ∣) ↝⟨ ∀-cong ext (λ _ → ≡-preserves-≃ ext univ univ (Eq.↔⇒≃ $ lemma₁ _ _) F.id) ⟩ (∀ b → (g ∘ lower) ⁻¹ b ≡ H ∣ b ∣) ↝⟨ Eq.extensionality-isomorphism ext ⟩ ((g ∘ lower) ⁻¹_) ≡ H ∘ ∣_∣ ↝⟨ ≡⇒↝ _ $ cong (λ eq → (g ∘ lower ∘ _≃_.from eq ⁻¹_) ≡ H ∘ ∣_∣) lemma ⟩ (g ∘ lower ∘ _≃_.from (≡⇒↝ _ (sym (refl _))) ⁻¹_) ≡ H ∘ ∣_∣ ↔⟨⟩ proj₁ (_↔_.to lemma₂ g) ≡ H ∘ ∣_∣ □ -- If the domain A is a set, then Traditional.Lens A B and Lens A B -- are isomorphic (assuming univalence). Lens↔Traditional-lens : {A : Type a} {B : Type b} → Block "conversion" → Univalence (a ⊔ b) → Is-set A → Lens A B ↔ Traditional.Lens A B Lens↔Traditional-lens {A = A} {B} bc univ A-set = Lens A B ↔⟨ Lens≃Higher-lens bc univ ⟩ Higher.Lens A B ↝⟨ Higher.Lens↔Traditional-lens bc univ A-set ⟩□ Traditional.Lens A B □ -- The isomorphism preserves getters and setters. Lens↔Traditional-lens-preserves-getters-and-setters : {A : Type a} {B : Type b} (bc : Block "conversion") (univ : Univalence (a ⊔ b)) (s : Is-set A) → Preserves-getters-and-setters-⇔ A B (_↔_.logical-equivalence (Lens↔Traditional-lens bc univ s)) Lens↔Traditional-lens-preserves-getters-and-setters bc univ s = Preserves-getters-and-setters-⇔-∘ {f = _↔_.logical-equivalence $ Higher.Lens↔Traditional-lens bc univ s} {g = _≃_.logical-equivalence $ Lens≃Higher-lens bc univ} (Higher.Lens↔Traditional-lens-preserves-getters-and-setters bc univ s) (Lens≃Higher-lens-preserves-getters-and-setters bc univ)
{ "alphanum_fraction": 0.3913859173, "avg_line_length": 42.897260274, "ext": "agda", "hexsha": "c4097efc71209afecf0bf84beb7a39ee4d9e90bd", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_forks_event_min_datetime": "2020-07-01T14:33:26.000Z", "max_forks_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/dependent-lenses", "max_forks_repo_path": "src/Lens/Non-dependent/Higher/Capriotti.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "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/dependent-lenses", "max_issues_repo_path": "src/Lens/Non-dependent/Higher/Capriotti.agda", "max_line_length": 143, "max_stars_count": 3, "max_stars_repo_head_hexsha": "f2da6f7e95b87ca525e8ea43929c6d6163a74811", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/dependent-lenses", "max_stars_repo_path": "src/Lens/Non-dependent/Higher/Capriotti.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:55:52.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T12:10:46.000Z", "num_tokens": 8589, "size": 25052 }
open import Common.Equality open import Common.Prelude hiding (pred) pred : Nat → Nat pred = _∸ 1 T : Bool → Set T = if_then ⊤ else ⊥ if : {A : Set} (b : Bool) → A → A → A if b = if b then_else_ test₁ : Nat → Nat test₁ = 5 +_ test₁-test : ∀ x → test₁ x ≡ 5 + x test₁-test _ = refl test₂ : Nat → Nat test₂ = _* 5 test₂-test : ∀ x → test₂ x ≡ x * 5 test₂-test _ = refl infixr 9 _∘_ _∘_ : {A B C : Set} → (B → C) → (A → B) → (A → C) f ∘ g = λ x → f (g x) test₃ : Nat → Nat test₃ = (_* 5) ∘ (6 +_) ∘ (2 ∸_) test₃-test : ∀ x → test₃ x ≡ (6 + (2 ∸ x)) * 5 test₃-test _ = refl infixr 0 _⊚_ _⊚_ : {A B C : Set} → (B → C) → (A → B) → (A → C) f ⊚ g = λ x → f (g x) test₃½ : Nat → Nat test₃½ = _* 5 ⊚ 6 +_ ⊚ 2 ∸_ test₃½-test : ∀ x → test₃½ x ≡ (6 + (2 ∸ x)) * 5 test₃½-test _ = refl test₄ : Nat → Nat → Nat test₄ = Common.Prelude.if true then_else_ test₄-test : ∀ x y → test₄ x y ≡ x test₄-test _ _ = refl test₅ : Bool → Nat test₅ = if_then 2 else 3 test₅-test : ∀ x → test₅ x ≡ (if x then 2 else 3) test₅-test _ = refl postulate foo_bar_ : (b₁ b₂ : Bool) → if b₁ then Nat else if b₂ then Bool else Nat test₆ : (b : Bool) → if b then Bool else Nat test₆ = foo false bar_ test₆-test : ∀ x → test₆ x ≡ (foo false bar x) test₆-test _ = refl test₇ : Nat → Nat test₇ = (Common.Prelude._+ 2) ∘ (1 Common.Prelude.∸_) test₇-test : ∀ x → test₇ x ≡ (1 Common.Prelude.∸ x) Common.Prelude.+ 2 test₇-test _ = refl _test₈_ : Nat → Nat → Nat _test₈_ = _*_ test₈-test : ∀ x y → (x test₈ y) ≡ x * y test₈-test _ _ = refl test₉ : Nat → Nat → Nat test₉ = Common.Prelude._*_ test₉-test : ∀ x y → test₉ x y ≡ x Common.Prelude.* y test₉-test _ _ = refl data D : Set₂ where ⟨_⟩_ : Set → Set₁ → D Test₁₀ : D → Set Test₁₀ (⟨_⟩_ X _) = X Test₁₁ : Set → Set Test₁₁ ⟨_⟩ = ⟨_⟩ postulate ⟦_⟧ : Set → Set Test₁₂ : Set → Set Test₁₂ A = ⟦_⟧ A Test₁₂-test : ∀ X → Test₁₂ X ≡ ⟦ X ⟧ Test₁₂-test _ = refl module M where _! : Set₁ → Set₁ X ! = X Test₁₃ : Set₁ Test₁₃ = M._! Set Test₁₄ : (x : Nat → Nat) → x ≡ suc → Set₁ Test₁₄ .(1 +_) refl = Set _$_ : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → A → B f $ x = f x test₁₅ : (((⊤ → Bool) → Bool) → Nat) → Nat test₁₅ = _$ _$ _ postulate -_ : Nat → Nat _-_ : Nat → Nat → Nat test₁₆ : Nat → Nat test₁₆ = (-_) test₁₆-test : ∀ x → test₁₆ x ≡ (- x) test₁₆-test _ = refl test₁₇ : (f : Nat → Nat) → f ≡ suc → Set₁ test₁₇ .(1 +_) refl = Set test₁₈ : (section : Nat) → section +_ ≡ λ x → section + x test₁₈ section = refl
{ "alphanum_fraction": 0.5592877378, "avg_line_length": 18.1691176471, "ext": "agda", "hexsha": "d7ee2d844e031e105f845bcacc5f4845b841f577", "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/Sections.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/Sections.agda", "max_line_length": 74, "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/Sections.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": 1142, "size": 2471 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Directed acyclic multigraphs ------------------------------------------------------------------------ -- A representation of DAGs, based on the idea underlying Martin -- Erwig's FGL. Note that this representation does not aim to be -- efficient. {-# OPTIONS --without-K --safe #-} module Data.Graph.Acyclic where open import Level using (_⊔_) open import Data.Nat.Base as Nat using (ℕ; zero; suc; _<′_) import Data.Nat.Properties as Nat open import Data.Fin as Fin using (Fin; Fin′; zero; suc; #_; toℕ; _≟_) renaming (_ℕ-ℕ_ to _-_) import Data.Fin.Properties as FP import Data.Fin.Permutation.Components as PC open import Data.Product as Prod using (∃; _×_; _,_) open import Data.Maybe.Base using (Maybe; nothing; just) open import Data.Empty open import Data.Unit.Base using (⊤; tt) open import Data.Vec as Vec using (Vec; []; _∷_) open import Data.List.Base as List using (List; []; _∷_) open import Function open import Induction.Nat using (<′-rec; <′-Rec) open import Relation.Nullary open import Relation.Binary.PropositionalEquality as P using (_≡_) ------------------------------------------------------------------------ -- A lemma private lemma : ∀ n (i : Fin n) → n - suc i <′ n lemma zero () lemma (suc n) i = Nat.≤⇒≤′ $ Nat.s≤s $ FP.nℕ-ℕi≤n n i ------------------------------------------------------------------------ -- Node contexts record Context {ℓ e} (Node : Set ℓ) (Edge : Set e) (n : ℕ) : Set (ℓ ⊔ e) where constructor context field label : Node successors : List (Edge × Fin n) open Context public -- Map for contexts. module _ {ℓ₁ e₁} {N₁ : Set ℓ₁} {E₁ : Set e₁} {ℓ₂ e₂} {N₂ : Set ℓ₂} {E₂ : Set e₂} where cmap : ∀ {n} → (N₁ → N₂) → (List (E₁ × Fin n) → List (E₂ × Fin n)) → Context N₁ E₁ n → Context N₂ E₂ n cmap f g c = context (f (label c)) (g (successors c)) ------------------------------------------------------------------------ -- Graphs infixr 3 _&_ -- The DAGs are indexed on the number of nodes. data Graph {ℓ e} (Node : Set ℓ) (Edge : Set e) : ℕ → Set (ℓ ⊔ e) where ∅ : Graph Node Edge 0 _&_ : ∀ {n} (c : Context Node Edge n) (g : Graph Node Edge n) → Graph Node Edge (suc n) private example : Graph ℕ ℕ 5 example = context 0 [] & context 1 ((10 , # 1) ∷ (11 , # 1) ∷ []) & context 2 ((12 , # 0) ∷ []) & context 3 [] & context 4 [] & ∅ ------------------------------------------------------------------------ -- Higher-order functions module _ {ℓ e} {N : Set ℓ} {E : Set e} {t} where -- "Fold right". foldr : (T : ℕ → Set t) → (∀ {n} → Context N E n → T n → T (suc n)) → T 0 → ∀ {m} → Graph N E m → T m foldr T _∙_ x ∅ = x foldr T _∙_ x (c & g) = c ∙ foldr T _∙_ x g -- "Fold left". foldl : ∀ {n} (T : ℕ → Set t) → ((i : Fin n) → T (toℕ i) → Context N E (n - suc i) → T (suc (toℕ i))) → T 0 → Graph N E n → T n foldl T f x ∅ = x foldl T f x (c & g) = foldl (T ∘′ suc) (f ∘ suc) (f zero x c) g module _ {ℓ₁ e₁} {N₁ : Set ℓ₁} {E₁ : Set e₁} {ℓ₂ e₂} {N₂ : Set ℓ₂} {E₂ : Set e₂} where -- Maps over node contexts. map : (∀ {n} → Context N₁ E₁ n → Context N₂ E₂ n) → ∀ {n} → Graph N₁ E₁ n → Graph N₂ E₂ n map f = foldr _ (λ c → f c &_) ∅ -- Maps over node labels. nmap : ∀ {ℓ₁ ℓ₂ e} {N₁ : Set ℓ₁} {N₂ : Set ℓ₂} {E : Set e} → ∀ {n} → (N₁ → N₂) → Graph N₁ E n → Graph N₂ E n nmap f = map (cmap f id) -- Maps over edge labels. emap : ∀ {ℓ e₁ e₂} {N : Set ℓ} {E₁ : Set e₁} {E₂ : Set e₂} → ∀ {n} → (E₁ → E₂) → Graph N E₁ n → Graph N E₂ n emap f = map (cmap id (List.map (Prod.map f id))) -- Zips two graphs with the same number of nodes. Note that one of the -- graphs has a type which restricts it to be completely disconnected. zipWith : ∀ {ℓ₁ ℓ₂ ℓ e} {N₁ : Set ℓ₁} {N₂ : Set ℓ₂} {N : Set ℓ} {E : Set e} → ∀ {n} → (N₁ → N₂ → N) → Graph N₁ ⊥ n → Graph N₂ E n → Graph N E n zipWith _∙_ ∅ ∅ = ∅ zipWith _∙_ (c₁ & g₁) (c₂ & g₂) = context (label c₁ ∙ label c₂) (successors c₂) & zipWith _∙_ g₁ g₂ ------------------------------------------------------------------------ -- Specific graphs -- A completeley disconnected graph. disconnected : ∀ n → Graph ⊤ ⊥ n disconnected zero = ∅ disconnected (suc n) = context tt [] & disconnected n -- A complete graph. complete : ∀ n → Graph ⊤ ⊤ n complete zero = ∅ complete (suc n) = context tt (List.map (tt ,_) $ Vec.toList (Vec.allFin n)) & complete n ------------------------------------------------------------------------ -- Queries module _ {ℓ e} {N : Set ℓ} {E : Set e} where -- The top-most context. head : ∀ {n} → Graph N E (suc n) → Context N E n head (c & g) = c -- The remaining graph. tail : ∀ {n} → Graph N E (suc n) → Graph N E n tail (c & g) = g -- Finds the context and remaining graph corresponding to a given node -- index. _[_] : ∀ {n} → Graph N E n → (i : Fin n) → Graph N E (suc (n - suc i)) ∅ [ () ] (c & g) [ zero ] = c & g (c & g) [ suc i ] = g [ i ] -- The nodes of the graph (node number relative to "topmost" node × -- node label). nodes : ∀ {n} → Graph N E n → Vec (Fin n × N) n nodes = Vec.zip (Vec.allFin _) ∘ foldr (Vec N) (λ c → label c ∷_) [] private test-nodes : nodes example ≡ (# 0 , 0) ∷ (# 1 , 1) ∷ (# 2 , 2) ∷ (# 3 , 3) ∷ (# 4 , 4) ∷ [] test-nodes = P.refl module _ {ℓ e} {N : Set ℓ} {E : Set e} where -- Topological sort. Gives a vector where earlier nodes are never -- successors of later nodes. topSort : ∀ {n} → Graph N E n → Vec (Fin n × N) n topSort = nodes -- The edges of the graph (predecessor × edge label × successor). -- -- The predecessor is a node number relative to the "topmost" node in -- the graph, and the successor is a node number relative to the -- predecessor. edges : ∀ {n} → Graph N E n → List (∃ λ i → E × Fin (n - suc i)) edges {n} = foldl (λ _ → List (∃ λ i → E × Fin (n - suc i))) (λ i es c → es List.++ List.map (i ,_) (successors c)) [] private test-edges : edges example ≡ (# 1 , 10 , # 1) ∷ (# 1 , 11 , # 1) ∷ (# 2 , 12 , # 0) ∷ [] test-edges = P.refl -- The successors of a given node i (edge label × node number relative -- to i). sucs : ∀ {ℓ e} {N : Set ℓ} {E : Set e} → ∀ {n} → Graph N E n → (i : Fin n) → List (E × Fin (n - suc i)) sucs g i = successors $ head (g [ i ]) private test-sucs : sucs example (# 1) ≡ (10 , # 1) ∷ (11 , # 1) ∷ [] test-sucs = P.refl -- The predecessors of a given node i (node number relative to i × -- edge label). preds : ∀ {ℓ e} {N : Set ℓ} {E : Set e} → ∀ {n} → Graph N E n → (i : Fin n) → List (Fin′ i × E) preds g zero = [] preds (c & g) (suc i) = List._++_ (List.mapMaybe (p i) $ successors c) (List.map (Prod.map suc id) $ preds g i) where p : ∀ {e} {E : Set e} {n} (i : Fin n) → E × Fin n → Maybe (Fin′ (suc i) × E) p i (e , j) with i ≟ j p i (e , .i) | yes P.refl = just (zero , e) p i (e , j) | no _ = nothing private test-preds : preds example (# 3) ≡ (# 1 , 10) ∷ (# 1 , 11) ∷ (# 2 , 12) ∷ [] test-preds = P.refl ------------------------------------------------------------------------ -- Operations -- Weakens a node label. weaken : ∀ {n} {i : Fin n} → Fin (n - suc i) → Fin n weaken {n} {i} j = Fin.inject≤ j (FP.nℕ-ℕi≤n n (suc i)) -- Labels each node with its node number. number : ∀ {ℓ e} {N : Set ℓ} {E : Set e} → ∀ {n} → Graph N E n → Graph (Fin n × N) E n number {N = N} {E} = foldr (λ n → Graph (Fin n × N) E n) (λ c g → cmap (zero ,_) id c & nmap (Prod.map suc id) g) ∅ private test-number : number example ≡ (context (# 0 , 0) [] & context (# 1 , 1) ((10 , # 1) ∷ (11 , # 1) ∷ []) & context (# 2 , 2) ((12 , # 0) ∷ []) & context (# 3 , 3) [] & context (# 4 , 4) [] & ∅) test-number = P.refl -- Reverses all the edges in the graph. reverse : ∀ {ℓ e} {N : Set ℓ} {E : Set e} → ∀ {n} → Graph N E n → Graph N E n reverse {N = N} {E} g = foldl (Graph N E) (λ i g' c → context (label c) (List.map (Prod.swap ∘ Prod.map PC.reverse id) $ preds g i) & g') ∅ g private test-reverse : reverse (reverse example) ≡ example test-reverse = P.refl ------------------------------------------------------------------------ -- Views -- Expands the subgraph induced by a given node into a tree (thus -- losing all sharing). data Tree {ℓ e} (N : Set ℓ) (E : Set e) : Set (ℓ ⊔ e) where node : (label : N) (successors : List (E × Tree N E)) → Tree N E module _ {ℓ e} {N : Set ℓ} {E : Set e} where toTree : ∀ {n} → Graph N E n → Fin n → Tree N E toTree g i = <′-rec Pred expand _ (g [ i ]) where Pred = λ n → Graph N E (suc n) → Tree N E expand : (n : ℕ) → <′-Rec Pred n → Pred n expand n rec (c & g) = node (label c) (List.map (Prod.map id (λ i → rec (n - suc i) (lemma n i) (g [ i ]))) (successors c)) -- Performs the toTree expansion once for each node. toForest : ∀ {n} → Graph N E n → Vec (Tree N E) n toForest g = Vec.map (toTree g) (Vec.allFin _) private test-toForest : toForest example ≡ let n3 = node 3 [] in node 0 [] ∷ node 1 ((10 , n3) ∷ (11 , n3) ∷ []) ∷ node 2 ((12 , n3) ∷ []) ∷ node 3 [] ∷ node 4 [] ∷ [] test-toForest = P.refl
{ "alphanum_fraction": 0.477141409, "avg_line_length": 29.2729970326, "ext": "agda", "hexsha": "14cf98350b17391ac9e6f5899e35a3064856ef3f", "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/Graph/Acyclic.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/Graph/Acyclic.agda", "max_line_length": 78, "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/Graph/Acyclic.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3386, "size": 9865 }
import cedille-options module interactive-cmds (options : cedille-options.options) where open import lib open import functions open import cedille-types open import conversion open import ctxt open import general-util open import monad-instances open import spans options {id} open import subst open import syntax-util open import to-string options open import toplevel-state options {IO} open import untyped-spans options {IO} open import parser open import rewriting open import rename open import classify options {id} import spans options {IO} as io-spans open import elaboration (record options {during-elaboration = ff}) open import elaboration-helpers (record options {during-elaboration = ff}) open import templates private {- Parsing -} ll-ind : ∀ {X : language-level → Set} → X ll-term → X ll-type → X ll-kind → (ll : language-level) → X ll ll-ind t T k ll-term = t ll-ind t T k ll-type = T ll-ind t T k ll-kind = k ll-lift : language-level → Set ll-lift = ⟦_⟧ ∘ ll-ind TERM TYPE KIND ll-ind' : ∀ {X : Σ language-level ll-lift → Set} → (s : Σ language-level ll-lift) → ((t : term) → X (ll-term , t)) → ((T : type) → X (ll-type , T)) → ((k : kind) → X (ll-kind , k)) → X s ll-ind' (ll-term , t) tf Tf kf = tf t ll-ind' (ll-type , T) tf Tf kf = Tf T ll-ind' (ll-kind , k) tf Tf kf = kf k ll-disambiguate : ctxt → term → maybe type ll-disambiguate Γ (Var pi x) = ctxt-lookup-type-var Γ x ≫=maybe λ _ → just (TpVar pi x) ll-disambiguate Γ (App t NotErased t') = ll-disambiguate Γ t ≫=maybe λ T → just (TpAppt T t') ll-disambiguate Γ (AppTp t T') = ll-disambiguate Γ t ≫=maybe λ T → just (TpApp T T') ll-disambiguate Γ (Lam pi KeptLambda pi' x (SomeClass atk) t) = ll-disambiguate (ctxt-tk-decl pi' x atk Γ) t ≫=maybe λ T → just (TpLambda pi pi' x atk T) ll-disambiguate Γ (Parens pi t pi') = ll-disambiguate Γ t ll-disambiguate Γ (Let pi d t) = ll-disambiguate (Γ' d) t ≫=maybe λ T → just (TpLet pi d T) where Γ' : defTermOrType → ctxt Γ' (DefTerm pi' x (SomeType T) t) = ctxt-term-def pi' localScope OpacTrans x t T Γ Γ' (DefTerm pi' x NoType t) = ctxt-term-udef pi' localScope OpacTrans x t Γ Γ' (DefType pi' x k T) = ctxt-type-def pi' localScope OpacTrans x T k Γ ll-disambiguate Γ t = nothing parse-string : (ll : language-level) → string → maybe (ll-lift ll) parse-string ll s = case ll-ind {λ ll → string → Either string (ll-lift ll)} parseTerm parseType parseKind ll s of λ {(Left e) → nothing; (Right e) → just e} ttk = "term, type, or kind" parse-err-msg : (failed-to-parse : string) → (as-a : string) → string parse-err-msg failed-to-parse "" = "Failed to parse \\\\\"" ^ failed-to-parse ^ "\\\\\"" parse-err-msg failed-to-parse as-a = "Failed to parse \\\\\"" ^ failed-to-parse ^ "\\\\\" as a " ^ as-a infixr 7 _≫nothing_ _-_!_≫parse_ _!_≫error_ _≫nothing_ : ∀{ℓ}{A : Set ℓ} → maybe A → maybe A → maybe A (nothing ≫nothing m₂) = m₂ (m₁ ≫nothing m₂) = m₁ _-_!_≫parse_ : ∀{A B : Set} → (string → maybe A) → string → (error-msg : string) → (A → string ⊎ B) → string ⊎ B (f - s ! e ≫parse f') = maybe-else (inj₁ (parse-err-msg s e)) f' (f s) _!_≫error_ : ∀{E A B : Set} → maybe A → E → (A → E ⊎ B) → E ⊎ B (just a ! e ≫error f) = f a (nothing ! e ≫error f) = inj₁ e parse-try : ∀ {X : Set} → ctxt → string → maybe (((ll : language-level) → ll-lift ll → X) → X) parse-try Γ s = maybe-map (λ t f → maybe-else (f ll-term t) (f ll-type) (ll-disambiguate Γ t)) (parse-string ll-term s) ≫nothing maybe-map (λ T f → f ll-type T) (parse-string ll-type s) ≫nothing maybe-map (λ k f → f ll-kind k) (parse-string ll-kind s) string-to-𝔹 : string → maybe 𝔹 string-to-𝔹 "tt" = just tt string-to-𝔹 "ff" = just ff string-to-𝔹 _ = nothing parse-ll : string → maybe language-level parse-ll "term" = just ll-term parse-ll "type" = just ll-type parse-ll "kind" = just ll-kind parse-ll _ = nothing {- Local Context -} record lci : Set where constructor mk-lci field ll : string; x : var; t : string; T : string; fn : string; pi : posinfo merge-lcis-ctxt : ctxt → 𝕃 string → ctxt merge-lcis-ctxt c = foldr merge-lci-ctxt c ∘ (sort-lcis ∘ strings-to-lcis) where strings-to-lcis : 𝕃 string → 𝕃 lci strings-to-lcis ss = strings-to-lcis-h ss [] where strings-to-lcis-h : 𝕃 string → 𝕃 lci → 𝕃 lci strings-to-lcis-h (ll :: x :: t :: T :: fn :: pi :: tl) items = strings-to-lcis-h tl (mk-lci ll x t T fn pi :: items) strings-to-lcis-h _ items = items language-level-type-of : language-level → language-level language-level-type-of ll-term = ll-type language-level-type-of _ = ll-kind merge-lci-ctxt : lci → ctxt → ctxt merge-lci-ctxt (mk-lci ll v t T fn pi) Γ = maybe-else Γ (λ Γ → Γ) (parse-ll ll ≫=maybe λ ll → parse-string (language-level-type-of ll) T ≫=maybe h ll (parse-string ll t)) where h : (ll : language-level) → maybe (ll-lift ll) → ll-lift (language-level-type-of ll) → maybe ctxt h ll-term (just t) T = just (ctxt-term-def pi localScope OpacTrans v t (qualif-type Γ T) Γ) h ll-type (just T) k = just (ctxt-type-def pi localScope OpacTrans v T (qualif-kind Γ k) Γ) h ll-term nothing T = just (ctxt-term-decl pi v T Γ) h ll-type nothing k = just (ctxt-type-decl pi v k Γ) h _ _ _ = nothing sort-lcis : 𝕃 lci → 𝕃 lci sort-lcis = list-merge-sort.merge-sort lci λ l l' → posinfo-to-ℕ (lci.pi l) > posinfo-to-ℕ (lci.pi l') where import list-merge-sort get-local-ctxt : ctxt → (pos : ℕ) → (local-ctxt : 𝕃 string) → ctxt get-local-ctxt Γ @ (mk-ctxt (fn , mn , _) _ is _ _) pi = merge-lcis-ctxt (foldr (flip ctxt-clear-symbol ∘ fst) Γ (flip filter (trie-mappings is) λ {(x , ci , fn' , pi') → fn =string fn' && posinfo-to-ℕ pi' > pi})) {- Helpers -} qualif-ed : ∀ {ed : exprd} → ctxt → ⟦ ed ⟧ → ⟦ ed ⟧ qualif-ed{TERM} = qualif-term qualif-ed{TYPE} = qualif-type qualif-ed{KIND} = qualif-kind qualif-ed Γ e = e step-reduce : ∀ {ed : exprd} → ctxt → ⟦ ed ⟧ → ⟦ ed ⟧ step-reduce Γ t = let t' = erase t in maybe-else t' id (step-reduceh Γ t') where step-reduceh : ∀ {ed : exprd} → ctxt → ⟦ ed ⟧ → maybe ⟦ ed ⟧ step-reduceh{TERM} Γ (Var pi x) = ctxt-lookup-term-var-def Γ (qualif-var Γ x) step-reduceh{TYPE} Γ (TpVar pi x) = ctxt-lookup-type-var-def Γ (qualif-var Γ x) step-reduceh{TERM} Γ (App (Lam pi b pi' x oc t) me t') = just (subst Γ t' x t) step-reduceh{TYPE} Γ (TpApp (TpLambda pi pi' x (Tkk _) T) T') = just (subst Γ T' x T) step-reduceh{TYPE} Γ (TpAppt (TpLambda pi pi' x (Tkt _) T) t) = just (subst Γ t x T) step-reduceh{TERM} Γ (App t me t') = step-reduceh Γ t ≫=maybe λ t → just (App t me t') step-reduceh{TYPE} Γ (TpApp T T') = step-reduceh Γ T ≫=maybe λ T → just (TpApp T T') step-reduceh{TYPE} Γ (TpAppt T t) = step-reduceh Γ T ≫=maybe λ T → just (TpAppt T t) step-reduceh{TERM} Γ (Lam pi b pi' x oc t) = step-reduceh (ctxt-var-decl x Γ) t ≫=maybe λ t → just (Lam pi b pi' x oc t) step-reduceh{TYPE} Γ (TpLambda pi pi' x atk T) = step-reduceh (ctxt-var-decl x Γ) T ≫=maybe λ T → just (TpLambda pi pi' x atk T) step-reduceh{TERM} Γ (Let pi (DefTerm pi' x ot t') t) = just (subst Γ t' x t) step-reduceh{TYPE} Γ (TpLet pi (DefTerm pi' x ot t) T) = just (subst Γ t x T) step-reduceh{TYPE} Γ (TpLet pi (DefType pi' x k T') T) = just (subst Γ T' x T) step-reduceh Γ t = nothing parse-norm : string → maybe (∀ {ed : exprd} → ctxt → ⟦ ed ⟧ → ⟦ ed ⟧) parse-norm "all" = just λ Γ t → hnf Γ unfold-all t tt parse-norm "head" = just λ Γ t → hnf Γ unfold-head t tt parse-norm "once" = just λ Γ → step-reduce Γ ∘ erase parse-norm _ = nothing {- Command Executors -} normalize-cmd : ctxt → (str ll pi norm : string) → 𝕃 string → string ⊎ tagged-val normalize-cmd Γ str ll pi norm ls = parse-ll - ll ! "language-level" ≫parse λ ll' → string-to-ℕ - pi ! "natural number" ≫parse λ sp → parse-norm - norm ! "normalization method (all, head, once)" ≫parse λ norm → parse-string ll' - str ! ll ≫parse λ t → let Γ' = get-local-ctxt Γ sp ls in inj₂ (to-string-tag "" Γ' (norm Γ' (qualif-ed Γ' t))) normalize-prompt : ctxt → (str norm : string) → 𝕃 string → string ⊎ tagged-val normalize-prompt Γ str norm ls = parse-norm - norm ! "normalization method (all, head, once)" ≫parse λ norm → let Γ' = merge-lcis-ctxt Γ ls in parse-try Γ' - str ! ttk ≫parse λ f → f λ ll t → inj₂ (to-string-tag "" Γ' (norm Γ' (qualif-ed Γ' t))) erase-cmd : ctxt → (str ll pi : string) → 𝕃 string → string ⊎ tagged-val erase-cmd Γ str ll pi ls = parse-ll - ll ! "language-level" ≫parse λ ll' → string-to-ℕ - pi ! "natural number" ≫parse λ sp → parse-string ll' - str ! ll ≫parse λ t → let Γ' = get-local-ctxt Γ sp ls in inj₂ (to-string-tag "" Γ' (erase (qualif-ed Γ' t))) erase-prompt : ctxt → (str : string) → 𝕃 string → string ⊎ tagged-val erase-prompt Γ str ls = let Γ' = merge-lcis-ctxt Γ ls in parse-try Γ' - str ! ttk ≫parse λ f → f λ ll t → inj₂ (to-string-tag "" Γ' (erase (qualif-ed Γ' t))) private cmds-to-escaped-string : cmds → strM cmds-to-escaped-string (CmdsNext c cs) = cmd-to-string c $ strAdd "\\n\\n" ≫str cmds-to-escaped-string cs cmds-to-escaped-string CmdsStart = strEmpty data-cmd : ctxt → (encoding name ps is cs : string) → string ⊎ tagged-val data-cmd Γ encodingₛ x psₛ isₛ csₛ = string-to-𝔹 - encodingₛ ! "boolean" ≫parse λ encoding → parse-string ll-kind - psₛ ! "kind" ≫parse λ psₖ → parse-string ll-kind - isₛ ! "kind" ≫parse λ isₖ → parse-string ll-kind - csₛ ! "kind" ≫parse λ csₖ → let ps = map (λ {(Index x atk) → Decl posinfo-gen posinfo-gen Erased x atk posinfo-gen}) $ kind-to-indices Γ psₖ cs = map (λ {(Index x (Tkt T)) → Ctr x T; (Index x (Tkk k)) → Ctr x $ mtpvar "ErrorExpectedTypeNotKind"}) $ kind-to-indices empty-ctxt csₖ is = kind-to-indices (add-constructors-to-ctxt cs $ add-parameters-to-ctxt ps $ Γ) isₖ picked-encoding = if encoding then mendler-encoding else mendler-simple-encoding defs = datatype-encoding.mk-defs picked-encoding Γ $ Data x ps is cs in inj₂ $ strRunTag "" Γ $ cmds-to-escaped-string $ fst defs br-cmd : ctxt → (str qed : string) → 𝕃 string → IO ⊤ br-cmd Γ str qed ls = let Γ' = merge-lcis-ctxt Γ ls in maybe-else (return (io-spans.spans-to-rope (io-spans.global-error "Parse error" nothing))) (λ s → s >>= return ∘ io-spans.spans-to-rope) (parse-try {maybe (IO io-spans.spans)} Γ' str ≫=maybe λ f → f λ where ll-term t → just (untyped-term-spans t Γ' io-spans.empty-spans >>= return ∘ (snd ∘ snd)) ll-type T → parse-string ll-term qed ≫=maybe λ q → case check-term q (just $ qualif-type Γ' T) Γ' empty-spans of λ where (triv , _ , ss @ (regular-spans nothing _)) → just (putStrLn "inhabited: Type inhabited" >> untyped-type-spans T Γ' io-spans.empty-spans >>= return ∘ (snd ∘ snd)) (triv , _ , _) → just (untyped-type-spans T Γ' io-spans.empty-spans >>= return ∘ (snd ∘ snd)) ll-kind k → just (untyped-kind-spans k Γ' io-spans.empty-spans >>= return ∘ (snd ∘ snd))) >>= putRopeLn conv-cmd : ctxt → (ll str1 str2 : string) → 𝕃 string → string ⊎ tagged-val conv-cmd Γ ll s1 s2 ls = parse-ll - ll ! "language-level" ≫parse λ ll' → parse-string ll' - s1 ! ll ≫parse λ t1 → parse-string ll' - s2 ! ll ≫parse λ t2 → let Γ' = merge-lcis-ctxt Γ ls; t2 = erase (qualif-ed Γ' t2) in if ll-ind {λ ll → ctxt → ll-lift ll → ll-lift ll → 𝔹} conv-term conv-type conv-kind ll' Γ' (qualif-ed Γ' t1) t2 then inj₂ (to-string-tag "" Γ' t2) else inj₁ "Inconvertible" rewrite-cmd : ctxt → (span-str : string) → (input-str : string) → (use-hnf : string) → (local-ctxt : 𝕃 string) → string ⊎ tagged-val rewrite-cmd Γ ss is hd ls = string-to-𝔹 - hd ! "boolean" ≫parse λ use-hnf → let Γ = merge-lcis-ctxt Γ ls in parse-try Γ - ss ! ttk ≫parse λ f → f λ ll ss → parse-try Γ - is ! ttk ≫parse λ f → (f λ where ll-term t → (case check-term t nothing Γ empty-spans of λ {(just T , _ , regular-spans nothing _) → just T; _ → nothing}) ! "Error when synthesizing a type for the input term" ≫error λ where (TpEq _ t₁ t₂ _) → inj₂ (t₁ , t₂) _ → inj₁ "Synthesized a non-equational type from the input term" ll-type (TpEq _ t₁ t₂ _) → inj₂ (t₁ , t₂) ll-type _ → inj₁ "Expected the input expression to be a term, but got a type" ll-kind _ → inj₁ "Expected the input expression to be a term, but got a kind") ≫=⊎ uncurry λ t₁ t₂ → let x = fresh-var "x" (ctxt-binds-var Γ) empty-renamectxt f = ll-ind {λ ll → ctxt → term → var → ll-lift ll → ll-lift ll} subst subst subst ll Γ t₂ x in case (ll-ind {λ ll → ll-lift ll → ctxt → 𝔹 → maybe stringset → term → term → var → ℕ → ll-lift ll × ℕ × ℕ} rewrite-term rewrite-type rewrite-kind ll (qualif-ed Γ ss) Γ use-hnf nothing (Beta posinfo-gen NoTerm NoTerm) t₁ x 0) of λ where (e , 0 , _) → inj₁ "No rewrites could be performed" (e , _ , _) → inj₂ (strRunTag "" Γ (to-stringh (erase (f e)) ≫str strAdd "§" ≫str strAdd x ≫str strAdd "§" ≫str to-stringh (erase e))) {- Commands -} tv-to-rope : string ⊎ tagged-val → rope tv-to-rope (inj₁ s) = [[ "{\"error\":\"" ]] ⊹⊹ [[ s ]] ⊹⊹ [[ "\"}" ]] tv-to-rope (inj₂ (_ , v , ts)) = [[ "{" ]] ⊹⊹ tagged-val-to-rope 0 ("value" , v , ts) ⊹⊹ [[ "}" ]] interactive-cmd-h : ctxt → 𝕃 string → string ⊎ tagged-val interactive-cmd-h Γ ("normalize" :: input :: ll :: sp :: norm :: lc) = normalize-cmd Γ input ll sp norm lc interactive-cmd-h Γ ("erase" :: input :: ll :: sp :: lc) = erase-cmd Γ input ll sp lc interactive-cmd-h Γ ("normalizePrompt" :: input :: norm :: lc) = normalize-prompt Γ input norm lc interactive-cmd-h Γ ("erasePrompt" :: input :: lc) = erase-prompt Γ input lc interactive-cmd-h Γ ("conv" :: ll :: ss :: is :: lc) = conv-cmd Γ ll ss is lc interactive-cmd-h Γ ("rewrite" :: ss :: is :: head :: lc) = rewrite-cmd Γ ss is head lc interactive-cmd-h Γ ("data" :: encoding :: x :: ps :: is :: cs :: []) = data-cmd Γ encoding x ps is cs interactive-cmd-h Γ cs = inj₁ ("Unknown interactive cmd: " ^ 𝕃-to-string (λ s → s) ", " cs) interactive-cmd : 𝕃 string → toplevel-state → IO ⊤ interactive-cmd ("br" :: input :: qed :: lc) ts = br-cmd (toplevel-state.Γ ts) input qed lc interactive-cmd ls ts = putRopeLn (tv-to-rope (interactive-cmd-h (toplevel-state.Γ ts) ls))
{ "alphanum_fraction": 0.5992249098, "avg_line_length": 46.3343653251, "ext": "agda", "hexsha": "ff28d1c2c5debfad6ddd01a9e99c33411765d80e", "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": "acf691e37210607d028f4b19f98ec26c4353bfb5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "xoltar/cedille", "max_forks_repo_path": "src/interactive-cmds.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5", "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": "xoltar/cedille", "max_issues_repo_path": "src/interactive-cmds.agda", "max_line_length": 188, "max_stars_count": null, "max_stars_repo_head_hexsha": "acf691e37210607d028f4b19f98ec26c4353bfb5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "xoltar/cedille", "max_stars_repo_path": "src/interactive-cmds.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5187, "size": 14966 }
open import Agda.Primitive open import Categories.Category module SecondOrder.IndexedCategory where IndexedCategory : ∀ {i o l e} (I : Set i) (𝒞 : Category o l e) → Category (i ⊔ o) (i ⊔ l) (i ⊔ e) IndexedCategory I 𝒞 = let open Category 𝒞 in record { Obj = I → Obj ; _⇒_ = λ A B → ∀ i → A i ⇒ B i ; _≈_ = λ f g → ∀ i → f i ≈ g i ; id = λ i → id ; _∘_ = λ f g i → f i ∘ g i ; assoc = λ i → assoc ; sym-assoc = λ i → sym-assoc ; identityˡ = λ i → identityˡ ; identityʳ = λ i → identityʳ ; identity² = λ i → identity² ; equiv = record { refl = λ i → Equiv.refl ; sym = λ ξ i → Equiv.sym (ξ i) ; trans = λ ζ ξ i → Equiv.trans (ζ i) (ξ i) } ; ∘-resp-≈ = λ ζ ξ i → ∘-resp-≈ (ζ i) (ξ i) }
{ "alphanum_fraction": 0.492481203, "avg_line_length": 33.25, "ext": "agda", "hexsha": "e792b8848efe4065e6d02fb33ca668ede90cf620", "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/IndexedCategory.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/IndexedCategory.agda", "max_line_length": 100, "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/IndexedCategory.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": 317, "size": 798 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Indexed applicative functors ------------------------------------------------------------------------ -- Note that currently the applicative functor laws are not included -- here. {-# OPTIONS --without-K --safe #-} module Category.Applicative.Indexed where open import Category.Functor using (RawFunctor) open import Data.Product using (_×_; _,_) open import Function open import Level open import Relation.Binary.PropositionalEquality as P using (_≡_) IFun : ∀ {i} → Set i → (ℓ : Level) → Set _ IFun I ℓ = I → I → Set ℓ → Set ℓ ------------------------------------------------------------------------ -- Type, and usual combinators record RawIApplicative {i f} {I : Set i} (F : IFun I f) : Set (i ⊔ suc f) where infixl 4 _⊛_ _<⊛_ _⊛>_ infix 4 _⊗_ field pure : ∀ {i A} → A → F i i A _⊛_ : ∀ {i j k A B} → F i j (A → B) → F j k A → F i k B rawFunctor : ∀ {i j} → RawFunctor (F i j) rawFunctor = record { _<$>_ = λ g x → pure g ⊛ x } private open module RF {i j : I} = RawFunctor (rawFunctor {i = i} {j = j}) public _<⊛_ : ∀ {i j k A B} → F i j A → F j k B → F i k A x <⊛ y = const <$> x ⊛ y _⊛>_ : ∀ {i j k A B} → F i j A → F j k B → F i k B x ⊛> y = flip const <$> x ⊛ y _⊗_ : ∀ {i j k A B} → F i j A → F j k B → F i k (A × B) x ⊗ y = (_,_) <$> x ⊛ y zipWith : ∀ {i j k A B C} → (A → B → C) → F i j A → F j k B → F i k C zipWith f x y = f <$> x ⊛ y zip : ∀ {i j k A B} → F i j A → F j k B → F i k (A × B) zip = zipWith _,_ ------------------------------------------------------------------------ -- Applicative with a zero record RawIApplicativeZero {i f} {I : Set i} (F : IFun I f) : Set (i ⊔ suc f) where field applicative : RawIApplicative F ∅ : ∀ {i j A} → F i j A open RawIApplicative applicative public ------------------------------------------------------------------------ -- Alternative functors: `F i j A` is a monoid record RawIAlternative {i f} {I : Set i} (F : IFun I f) : Set (i ⊔ suc f) where infixr 3 _∣_ field applicativeZero : RawIApplicativeZero F _∣_ : ∀ {i j A} → F i j A → F i j A → F i j A open RawIApplicativeZero applicativeZero public ------------------------------------------------------------------------ -- Applicative functor morphisms, specialised to propositional -- equality. record Morphism {i f} {I : Set i} {F₁ F₂ : IFun I f} (A₁ : RawIApplicative F₁) (A₂ : RawIApplicative F₂) : Set (i ⊔ suc f) where module A₁ = RawIApplicative A₁ module A₂ = RawIApplicative A₂ field op : ∀ {i j X} → F₁ i j X → F₂ i j X op-pure : ∀ {i X} (x : X) → op (A₁.pure {i = i} x) ≡ A₂.pure x op-⊛ : ∀ {i j k X Y} (f : F₁ i j (X → Y)) (x : F₁ j k X) → op (f A₁.⊛ x) ≡ (op f A₂.⊛ op x) op-<$> : ∀ {i j X Y} (f : X → Y) (x : F₁ i j X) → op (f A₁.<$> x) ≡ (f A₂.<$> op x) op-<$> f x = begin op (A₁._⊛_ (A₁.pure f) x) ≡⟨ op-⊛ _ _ ⟩ A₂._⊛_ (op (A₁.pure f)) (op x) ≡⟨ P.cong₂ A₂._⊛_ (op-pure _) P.refl ⟩ A₂._⊛_ (A₂.pure f) (op x) ∎ where open P.≡-Reasoning
{ "alphanum_fraction": 0.4516717325, "avg_line_length": 30.462962963, "ext": "agda", "hexsha": "7a8579b664aadd39b51b64ca9d64ffb8b184d201", "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/Category/Applicative/Indexed.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/Category/Applicative/Indexed.agda", "max_line_length": 74, "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/Category/Applicative/Indexed.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1189, "size": 3290 }
open import Prelude module Typed (Name : Set) -- Data stuff (Datatype : Name -> List (List Name)) -- Effect stuff (Effect : Set) (_⊆_ : Effect -> Effect -> Set) (Monad : Effect -> Set -> Set) (return : forall {M A} -> A -> Monad M A) (map : forall {M A B} -> (A -> B) -> Monad M A -> Monad M B) (join : forall {M A} -> Monad M (Monad M A) -> Monad M A) (morph : forall {M N} -> M ⊆ N -> (A : Set) -> Monad M A -> Monad N A) where _=<<_ : forall {M A B} -> (A -> Monad M B) -> Monad M A -> Monad M B k =<< m = join (map k m) _>>=_ : forall {M A B} -> Monad M A -> (A -> Monad M B) -> Monad M B m >>= k = k =<< m infixl 50 _<*>_ _<*>_ : forall {M A B} -> Monad M (A -> B) -> Monad M A -> Monad M B f <*> x = f >>= \f -> x >>= \x -> return (f x) infixr 80 _⟶_ infix 100 [_]_ data VTy : Set data CTy : Set where _⟶_ : VTy -> CTy -> CTy [_]_ : Effect -> VTy -> CTy data VTy where ⟨_⟩ : CTy -> VTy TyCon : Name -> VTy Cxt = List VTy data ExC : Effect -> Cxt -> CTy -> Set data InV : Effect -> Cxt -> VTy -> Set data InC : Cxt -> CTy -> Set where ƛ_ : forall {V C Γ} -> InC (Γ ◄ V) C -> InC Γ (V ⟶ C) exC : forall {M N Γ V} -> ExC M Γ ([ N ] V) -> N ⊆ M -> InC Γ ([ M ] V) inV : forall {M Γ V} -> InV M Γ V -> InC Γ ([ M ] V) InDs : Effect -> Cxt -> List Name -> Set data InV where ⟪_⟫ : forall {M Γ C} -> InC Γ C -> InV M Γ ⟨ C ⟩ ⟦_⟧ : forall {M Γ V} -> InC Γ ([ M ] V) -> InV M Γ V con : forall {M Γ D args} -> args ∈ Datatype D -> InDs M Γ args -> InV M Γ (TyCon D) InDs M Γ = Box (\D -> InV M Γ (TyCon D)) data ExC where var : forall {M Γ V} -> V ∈ Γ -> ExC M Γ ([ M ] V) _•_ : forall {M Γ V C} -> ExC M Γ (V ⟶ C) -> InV M Γ V -> ExC M Γ C Els : _ data El : Name -> Set where el : forall {args D} -> args ∈ Datatype D -> Els args -> El D Els = Box El VTy⟦_⟧ : VTy -> Set CTy⟦_⟧ : CTy -> Set CTy⟦ V ⟶ C ⟧ = VTy⟦ V ⟧ -> CTy⟦ C ⟧ CTy⟦ [ M ] V ⟧ = Monad M VTy⟦ V ⟧ VTy⟦ ⟨ C ⟩ ⟧ = CTy⟦ C ⟧ VTy⟦ TyCon D ⟧ = El D Env = Box VTy⟦_⟧ inC⟦_⟧ : forall {Γ C} -> InC Γ C -> Env Γ -> CTy⟦ C ⟧ inDs⟦_⟧ : forall {M Γ Ds} -> InDs M Γ Ds -> Env Γ -> Monad M (Els Ds) inV⟦_⟧ : forall {M Γ V} -> InV M Γ V -> Env Γ -> Monad M VTy⟦ V ⟧ inV⟦ ⟪ c ⟫ ⟧ ρ = return (inC⟦ c ⟧ ρ) inV⟦ ⟦ c ⟧ ⟧ ρ = inC⟦ c ⟧ ρ inV⟦ con x Ds ⟧ ρ = return (el x) <*> inDs⟦ Ds ⟧ ρ inDs⟦ ⟨⟩ ⟧ ρ = return ⟨⟩ inDs⟦ Ds ◃ v ⟧ ρ = return _◃_ <*> inDs⟦ Ds ⟧ ρ <*> inV⟦ v ⟧ ρ exC⟦_⟧ : forall {M Γ C} -> ExC M Γ C -> Env Γ -> Monad M CTy⟦ C ⟧ inC⟦ ƛ c ⟧ ρ = \v -> inC⟦ c ⟧ (ρ ◃ v) inC⟦ exC c m ⟧ ρ = morph m _ =<< exC⟦ c ⟧ ρ inC⟦ inV v ⟧ ρ = inV⟦ v ⟧ ρ exC⟦ var x ⟧ ρ = return (return (ρ ! x)) exC⟦ f • s ⟧ ρ = exC⟦ f ⟧ ρ <*> inV⟦ s ⟧ ρ
{ "alphanum_fraction": 0.4702034884, "avg_line_length": 22.9333333333, "ext": "agda", "hexsha": "cec32b10c0eab41de796bb3fd207378700200c3f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/sinatra/Typed.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/sinatra/Typed.agda", "max_line_length": 73, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/sinatra/Typed.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": 1279, "size": 2752 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Functions.Definition open import Numbers.Naturals.Definition open import Sets.FinSet.Definition module Sets.Cardinality.Finite.Definition where record FiniteSet {a : _} (A : Set a) : Set a where field size : ℕ mapping : FinSet size → A bij : Bijection mapping
{ "alphanum_fraction": 0.7184750733, "avg_line_length": 22.7333333333, "ext": "agda", "hexsha": "2d9d93d4de7c843631deee5bfff6baf4eaf7b789", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Sets/Cardinality/Finite/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Sets/Cardinality/Finite/Definition.agda", "max_line_length": 50, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Sets/Cardinality/Finite/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 89, "size": 341 }
{-# OPTIONS --without-K --safe #-} module Util.Prelude where open import Data.Bool public using (Bool ; true ; false) open import Data.Empty public using (⊥ ; ⊥-elim) open import Data.Fin public using (Fin ; zero ; suc) open import Data.List public using (List ; [] ; _∷_) open import Data.Maybe public using (Maybe ; just ; nothing) open import Data.Nat public using (ℕ ; zero ; suc) open import Data.Product public using (Σ ; ∃ ; Σ-syntax ; ∃-syntax ; _×_ ; _,_ ; proj₁ ; proj₂) open import Data.Sum public using (_⊎_ ; inj₁ ; inj₂) open import Data.Unit public using (⊤) open import Data.Vec public using (Vec ; [] ; _∷_) open import Function public using (id ; _∘_ ; _∘′_ ; _$_ ; _on_) open import Level public using (Level ; 0ℓ) renaming (zero to lzero ; suc to lsuc ; _⊔_ to _⊔ℓ_) open import Relation.Nullary public using (¬_ ; Dec ; yes ; no) open import Relation.Binary.PropositionalEquality public using ( _≡_ ; _≢_ ; refl ; sym ; trans ; cong ; cong₂ ; subst ; subst₂ ; module ≡-Reasoning ) infix 1 triangle⟨_⟩⟨_⟩⟨_⟩ triangle⟨_⟩⟨_⟩⟨_⟩ : ∀ {a} {A : Set a} x {y z : A} → y ≡ x → z ≡ x → y ≡ z triangle⟨ x ⟩⟨ y≡x ⟩⟨ z≡x ⟩ = trans y≡x (sym z≡x)
{ "alphanum_fraction": 0.6376569038, "avg_line_length": 27.1590909091, "ext": "agda", "hexsha": "f8bc3f69624c1b4c7c7e5a69dcbed35b673dbb3b", "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": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JLimperg/msc-thesis-code", "max_forks_repo_path": "src/Util/Prelude.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "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": "JLimperg/msc-thesis-code", "max_issues_repo_path": "src/Util/Prelude.agda", "max_line_length": 66, "max_stars_count": 5, "max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JLimperg/msc-thesis-code", "max_stars_repo_path": "src/Util/Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z", "num_tokens": 441, "size": 1195 }
{-# OPTIONS --without-K --safe #-} open import Categories.Adjoint open import Categories.Category open import Categories.Functor renaming (id to idF) module Categories.Adjoint.Monadic.Properties {o ℓ e o′ ℓ′ e′} {𝒞 : Category o ℓ e} {𝒟 : Category o′ ℓ′ e′} {L : Functor 𝒞 𝒟} {R : Functor 𝒟 𝒞} (adjoint : L ⊣ R) where open import Level open import Function using (_$_) open import Categories.Adjoint.Properties open import Categories.Adjoint.Monadic open import Categories.NaturalTransformation.NaturalIsomorphism open import Categories.NaturalTransformation open import Categories.Monad open import Categories.Diagram.Coequalizer open import Categories.Category.Construction.EilenbergMoore open import Categories.Category.Construction.Properties.EilenbergMoore open import Categories.Morphism import Categories.Morphism.Reasoning as MR private module L = Functor L module R = Functor R module 𝒞 = Category 𝒞 module 𝒟 = Category 𝒟 module adjoint = Adjoint adjoint T : Monad 𝒞 T = adjoint⇒monad adjoint 𝒞ᵀ : Category _ _ _ 𝒞ᵀ = EilenbergMoore T Comparison : Functor 𝒟 𝒞ᵀ Comparison = ComparisonF adjoint module Comparison = Functor Comparison -- If we have a coequalizer of the following diagram for every T-algabra, then the comparison functor has a left adjoint. module _ (has-coequalizer : (M : Module T) → Coequalizer 𝒟 (L.F₁ (Module.action M)) (adjoint.counit.η (L.₀ (Module.A M)))) where open Coequalizer Comparison⁻¹ : Functor 𝒞ᵀ 𝒟 Comparison⁻¹ = record { F₀ = λ M → obj (has-coequalizer M) ; F₁ = λ {M} {N} α → coequalize (has-coequalizer M) $ begin 𝒟 [ 𝒟 [ arr (has-coequalizer N) ∘ L.F₁ (Module⇒.arr α) ] ∘ L.F₁ (Module.action M) ] ≈⟨ pullʳ (⟺ L.homomorphism) ⟩ 𝒟 [ arr (has-coequalizer N) ∘ L.F₁ (𝒞 [ Module⇒.arr α ∘ Module.action M ]) ] ≈⟨ refl⟩∘⟨ L.F-resp-≈ (Module⇒.commute α) ⟩ 𝒟 [ arr (has-coequalizer N) ∘ L.F₁ (𝒞 [ Module.action N ∘ R.F₁ (L.F₁ (Module⇒.arr α)) ]) ] ≈⟨ refl⟩∘⟨ L.homomorphism ⟩ 𝒟 [ arr (has-coequalizer N) ∘ 𝒟 [ L.F₁ (Module.action N) ∘ L.F₁ (R.F₁ (L.F₁ (Module⇒.arr α))) ] ] ≈⟨ pullˡ (equality (has-coequalizer N)) ⟩ 𝒟 [ 𝒟 [ arr (has-coequalizer N) ∘ adjoint.counit.η (L.F₀ (Module.A N)) ] ∘ L.F₁ (R.F₁ (L.F₁ (Module⇒.arr α))) ] ≈⟨ extendˡ (adjoint.counit.commute (L.F₁ (Module⇒.arr α))) ⟩ 𝒟 [ 𝒟 [ arr (has-coequalizer N) ∘ L.F₁ (Module⇒.arr α) ] ∘ adjoint.counit.η (L.₀ (Module.A M)) ] ∎ ; identity = λ {A} → ⟺ $ unique (has-coequalizer A) $ begin 𝒟 [ arr (has-coequalizer A) ∘ L.F₁ 𝒞.id ] ≈⟨ refl⟩∘⟨ L.identity ⟩ 𝒟 [ arr (has-coequalizer A) ∘ 𝒟.id ] ≈⟨ id-comm ⟩ 𝒟 [ 𝒟.id ∘ arr (has-coequalizer A) ] ∎ ; homomorphism = λ {X} {Y} {Z} {f} {g} → ⟺ $ unique (has-coequalizer X) $ begin 𝒟 [ arr (has-coequalizer Z) ∘ L.F₁ (𝒞 [ Module⇒.arr g ∘ Module⇒.arr f ]) ] ≈⟨ 𝒟.∘-resp-≈ʳ L.homomorphism ○ 𝒟.sym-assoc ⟩ 𝒟 [ 𝒟 [ arr (has-coequalizer Z) ∘ L.F₁ (Module⇒.arr g) ] ∘ L.F₁ (Module⇒.arr f) ] ≈⟨ universal (has-coequalizer Y) ⟩∘⟨refl ⟩ 𝒟 [ 𝒟 [ coequalize (has-coequalizer Y) _ ∘ arr (has-coequalizer Y) ] ∘ L.F₁ (Module⇒.arr f) ] ≈⟨ extendˡ (universal (has-coequalizer X)) ⟩ 𝒟 [ 𝒟 [ coequalize (has-coequalizer Y) _ ∘ coequalize (has-coequalizer X) _ ] ∘ arr (has-coequalizer X) ] ∎ ; F-resp-≈ = λ {A} {B} {f} {g} eq → unique (has-coequalizer A) $ begin 𝒟 [ arr (has-coequalizer B) ∘ L.F₁ (Module⇒.arr g) ] ≈⟨ refl⟩∘⟨ L.F-resp-≈ (𝒞.Equiv.sym eq) ⟩ 𝒟 [ arr (has-coequalizer B) ∘ L.F₁ (Module⇒.arr f) ] ≈⟨ universal (has-coequalizer A) ⟩ 𝒟 [ coequalize (has-coequalizer A) _ ∘ arr (has-coequalizer A) ] ∎ } where open 𝒟.HomReasoning open MR 𝒟 private module Comparison⁻¹ = Functor Comparison⁻¹ Comparison⁻¹⊣Comparison : Comparison⁻¹ ⊣ Comparison Adjoint.unit Comparison⁻¹⊣Comparison = ntHelper record { η = λ M → record { arr = 𝒞 [ R.F₁ (arr (has-coequalizer M)) ∘ adjoint.unit.η (Module.A M) ] ; commute = begin 𝒞 [ 𝒞 [ R.F₁ (arr (has-coequalizer M)) ∘ adjoint.unit.η (Module.A M) ] ∘ Module.action M ] ≈⟨ pullʳ (adjoint.unit.commute (Module.action M)) ⟩ -- It would be nice to have a reasoning combinator doing this "⟺ homomorphism ... homomorphism" pattern 𝒞 [ R.F₁ (arr (has-coequalizer M)) ∘ 𝒞 [ R.F₁ (L.F₁ (Module.action M)) ∘ adjoint.unit.η (R.F₀ (L.F₀ (Module.A M))) ] ] ≈⟨ pullˡ (⟺ R.homomorphism) ⟩ 𝒞 [ R.F₁ (𝒟 [ arr (has-coequalizer M) ∘ L.F₁ (Module.action M) ]) ∘ adjoint.unit.η (R.F₀ (L.F₀ (Module.A M))) ] ≈⟨ (R.F-resp-≈ (equality (has-coequalizer M)) ⟩∘⟨refl) ⟩ 𝒞 [ R.F₁ (𝒟 [ arr (has-coequalizer M) ∘ adjoint.counit.η (L.F₀ (Module.A M)) ]) ∘ adjoint.unit.η (R.F₀ (L.F₀ (Module.A M))) ] ≈⟨ (R.homomorphism ⟩∘⟨refl) ⟩ 𝒞 [ 𝒞 [ R.F₁ (arr (has-coequalizer M)) ∘ R.F₁ (adjoint.counit.η (L.F₀ (Module.A M))) ] ∘ adjoint.unit.η (R.F₀ (L.F₀ (Module.A M))) ] ≈⟨ cancelʳ adjoint.zag ⟩ -- FIXME Use something like cancel here R.F₁ (arr (has-coequalizer M)) ≈˘⟨ R.F-resp-≈ (𝒟.identityʳ) ⟩ R.F₁ (𝒟 [ arr (has-coequalizer M) ∘ 𝒟.id ]) ≈˘⟨ R.F-resp-≈ (𝒟.∘-resp-≈ʳ adjoint.zig) ⟩ R.F₁ (𝒟 [ arr (has-coequalizer M) ∘ 𝒟 [ adjoint.counit.η (L.F₀ (Module.A M)) ∘ L.F₁ (adjoint.unit.η (Module.A M)) ] ]) ≈⟨ R.F-resp-≈ (MR.extendʳ 𝒟 (adjoint.counit.sym-commute (arr (has-coequalizer M)))) ⟩ R.F₁ (𝒟 [ adjoint.counit.η (obj (has-coequalizer M)) ∘ 𝒟 [ L.F₁ (R.F₁ (arr (has-coequalizer M))) ∘ L.F₁ (adjoint.unit.η (Module.A M)) ] ]) ≈˘⟨ R.F-resp-≈ (𝒟.∘-resp-≈ʳ L.homomorphism) ⟩ R.F₁ (𝒟 [ adjoint.counit.η (obj (has-coequalizer M)) ∘ L.F₁ (𝒞 [ R.F₁ (arr (has-coequalizer M)) ∘ adjoint.unit.η (Module.A M)])]) ≈⟨ R.homomorphism ⟩ 𝒞 [ R.F₁ (adjoint.counit.η (obj (has-coequalizer M))) ∘ R.F₁ (L.F₁ (𝒞 [ R.F₁ (arr (has-coequalizer M)) ∘ adjoint.unit.η (Module.A M)])) ] ∎ } ; commute = λ {M} {N} f → begin 𝒞 [ 𝒞 [ R.F₁ (arr (has-coequalizer N)) ∘ adjoint.unit.η (Module.A N) ] ∘ Module⇒.arr f ] ≈⟨ extendˡ (adjoint.unit.commute (Module⇒.arr f)) ⟩ 𝒞 [ 𝒞 [ R.F₁ (arr (has-coequalizer N)) ∘ R.F₁ (L.F₁ (Module⇒.arr f)) ] ∘ adjoint.unit.η (Module.A M) ] ≈˘⟨ R.homomorphism ⟩∘⟨refl ⟩ 𝒞 [ R.F₁ (𝒟 [ arr (has-coequalizer N) ∘ L.F₁ (Module⇒.arr f) ]) ∘ adjoint.unit.η (Module.A M) ] ≈⟨ R.F-resp-≈ (universal (has-coequalizer M)) ⟩∘⟨refl ⟩ 𝒞 [ R.F₁ (𝒟 [ (coequalize (has-coequalizer M) _) ∘ (arr (has-coequalizer M)) ]) ∘ adjoint.unit.η (Module.A M) ] ≈⟨ pushˡ R.homomorphism ⟩ 𝒞 [ R.F₁ (coequalize (has-coequalizer M) _) ∘ 𝒞 [ R.F₁ (arr (has-coequalizer M)) ∘ adjoint.unit.η (Module.A M) ] ] ∎ } where open 𝒞.HomReasoning open MR 𝒞 Adjoint.counit Comparison⁻¹⊣Comparison = ntHelper record { η = λ X → coequalize (has-coequalizer (Comparison.F₀ X)) (adjoint.counit.commute (adjoint.counit.η X)) ; commute = λ {X} {Y} f → begin 𝒟 [ coequalize (has-coequalizer (Comparison.F₀ Y)) _ ∘ coequalize (has-coequalizer (Comparison.F₀ X)) _ ] ≈⟨ unique (has-coequalizer (Comparison.F₀ X)) (adjoint.counit.sym-commute f ○ pushˡ (universal (has-coequalizer (Comparison.F₀ Y))) ○ pushʳ (universal (has-coequalizer (Comparison.F₀ X)))) ⟩ coequalize (has-coequalizer (Comparison.F₀ X)) (extendˡ (adjoint.counit.commute (adjoint.counit.η X))) ≈˘⟨ unique (has-coequalizer (Comparison.F₀ X)) (pushʳ (universal (has-coequalizer (Comparison.F₀ X)))) ⟩ 𝒟 [ f ∘ coequalize (has-coequalizer (Comparison.F₀ X)) _ ] ∎ } where open 𝒟.HomReasoning open MR 𝒟 Adjoint.zig Comparison⁻¹⊣Comparison {X} = begin 𝒟 [ coequalize (has-coequalizer (Comparison.F₀ (Comparison⁻¹.F₀ X))) _ ∘ coequalize (has-coequalizer X) _ ] ≈⟨ unique (has-coequalizer X) (⟺ adjoint.RLadjunct≈id ○ pushˡ (universal (has-coequalizer (Comparison.F₀ (Comparison⁻¹.F₀ X)))) ○ pushʳ (universal (has-coequalizer X))) ⟩ coequalize (has-coequalizer X) {h = arr (has-coequalizer X)} (equality (has-coequalizer X)) ≈˘⟨ unique (has-coequalizer X) (⟺ 𝒟.identityˡ) ⟩ 𝒟.id ∎ where open 𝒟.HomReasoning open MR 𝒟 Adjoint.zag Comparison⁻¹⊣Comparison {A} = begin 𝒞 [ R.F₁ (coequalize (has-coequalizer (Comparison.F₀ A)) _) ∘ 𝒞 [ R.F₁ (arr (has-coequalizer (Comparison.F₀ A))) ∘ adjoint.unit.η (Module.A (Comparison.F₀ A)) ] ] ≈⟨ pullˡ (⟺ R.homomorphism) ⟩ 𝒞 [ R.F₁ (𝒟 [ coequalize (has-coequalizer (Comparison.F₀ A)) _ ∘ arr (has-coequalizer (Comparison.F₀ A)) ]) ∘ adjoint.unit.η (Module.A (Comparison.F₀ A)) ] ≈˘⟨ R.F-resp-≈ (universal (has-coequalizer (Comparison.F₀ A))) ⟩∘⟨refl ⟩ 𝒞 [ R.F₁ (adjoint.counit.η A) ∘ adjoint.unit.η (R.F₀ A) ] ≈⟨ adjoint.zag ⟩ 𝒞.id ∎ where open 𝒞.HomReasoning open MR 𝒞
{ "alphanum_fraction": 0.5528413737, "avg_line_length": 70.3884892086, "ext": "agda", "hexsha": "f9ac0128dcce9bc48eea10cba3f6c5ca5a789883", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Adjoint/Monadic/Properties.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Adjoint/Monadic/Properties.agda", "max_line_length": 303, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Adjoint/Monadic/Properties.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": 3642, "size": 9784 }
{-# OPTIONS --universe-polymorphism #-} open import Common.Prelude open import Common.Level open import Common.Reflect module UnquoteSetOmega where `Level : Term `Level = def (quote Level) [] ``Level : Type ``Level = el (lit 0) `Level -- while building the syntax of ∀ ℓ → Set ℓ (of type Setω) is harmless `∀ℓ→Setℓ : Term `∀ℓ→Setℓ = pi (arg (arginfo visible relevant) ``Level) (el (lit 0) (sort (set (var 0 [])))) -- unquoting it is harmfull ∀ℓ→Setℓ = unquote `∀ℓ→Setℓ
{ "alphanum_fraction": 0.6793248945, "avg_line_length": 23.7, "ext": "agda", "hexsha": "8a8ccb18b5f8e1ac8ee70026642ad3a20cc6d73f", "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": "test/fail/UnquoteSetOmega.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/UnquoteSetOmega.agda", "max_line_length": 91, "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": "test/fail/UnquoteSetOmega.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": 167, "size": 474 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Truncation open import lib.types.Pi module lib.types.Choice where unchoose : ∀ {i j} {n : ℕ₋₂} {A : Type i} {B : A → Type j} → Trunc n (Π A B) → Π A (Trunc n ∘ B) unchoose = Trunc-rec (Π-level λ _ → Trunc-level) (λ f → [_] ∘ f) has-choice : ∀ {i} (n : ℕ₋₂) (A : Type i) j → Type (lmax i (lsucc j)) has-choice {i} n A j = (B : A → Type j) → is-equiv (unchoose {n = n} {A} {B})
{ "alphanum_fraction": 0.5824411135, "avg_line_length": 31.1333333333, "ext": "agda", "hexsha": "d03138a23da3654205fedca1732295b242544a7d", "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/Choice.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/Choice.agda", "max_line_length": 77, "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/Choice.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 184, "size": 467 }
{-# OPTIONS --cubical --safe #-} module Data.Binary.Multiplication where open import Data.Binary.Definition open import Data.Binary.Addition double : 𝔹 → 𝔹 double 0ᵇ = 0ᵇ double (1ᵇ xs) = 2ᵇ double xs double (2ᵇ xs) = 2ᵇ 1ᵇ xs infixl 7 _*_ _*_ : 𝔹 → 𝔹 → 𝔹 0ᵇ * ys = 0ᵇ 1ᵇ xs * ys = ys + double (ys * xs) 2ᵇ xs * ys = double (ys + ys * xs)
{ "alphanum_fraction": 0.6387283237, "avg_line_length": 19.2222222222, "ext": "agda", "hexsha": "d45a25f10cfaffd852e36ffeac6d2bcfd7457f9f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/Binary/Multiplication.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "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/agda-playground", "max_issues_repo_path": "Data/Binary/Multiplication.agda", "max_line_length": 39, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/Binary/Multiplication.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z", "num_tokens": 161, "size": 346 }
------------------------------------------------------------------------ -- Instantiation of Contractive for functions ------------------------------------------------------------------------ -- Taken from the paper. open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Contractive open import Level module Contractive.Function {A B : Set} {_<_ : Rel A zero} (isWFO : IsWellFoundedOrder _<_) (dec : Decidable _<_) (proof-irrelevance : ∀ {a a'} (p₁ p₂ : a < a') → p₁ ≡ p₂) where open import Relation.Nullary open import Relation.Unary open import Data.Empty ofe : OFE ofe = record { Carrier = A ; Domain = A → B ; _<_ = _<_ ; isWellFoundedOrder = isWFO ; Eq = λ a f g → f a ≡ g a ; isEquivalence = λ _ → record { refl = refl ; sym = sym ; trans = trans } } open OFE ofe hiding (_<_) private limU : (A → (A → B)) → A → B limU f a' = f a' a' lim↓ : B → ∀ a → (∀ x → x < a → A → B) → A → B lim↓ b a f a' with dec a' a lim↓ b a f a' | yes a'<a = f a' a'<a a' lim↓ b a f a' | no a'≮a = b isLimit↓ : ∀ b a {fam : Family (↓ a)} → IsCoherent fam → IsLimit fam (lim↓ b a fam) isLimit↓ b a {fam} coh {a'} a'<a with dec a' a isLimit↓ b a {fam} coh {a'} a'<a | no a'≮a = ⊥-elim (a'≮a a'<a) isLimit↓ b a {fam} coh {a'} a'<a | yes a'<a₂ = cong (λ p → fam a' p a') (proof-irrelevance a'<a a'<a₂) -- The paper implicitly assumes that B is non-empty. cofe : B → COFE cofe b = record { ofe = ofe ; limU = limU ; isLimitU = λ _ _ → refl ; lim↓ = lim↓ b ; isLimit↓ = isLimit↓ b }
{ "alphanum_fraction": 0.4777585211, "avg_line_length": 25.4558823529, "ext": "agda", "hexsha": "ca627668fde7ebaaea771c4567671af2866bcc02", "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": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "Contractive/Function.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "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/codata", "max_issues_repo_path": "Contractive/Function.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "Contractive/Function.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 584, "size": 1731 }
{-# OPTIONS --rewriting #-} {-# OPTIONS --allow-unsolved-metas #-} open import Common.Equality {-# BUILTIN REWRITE _≡_ #-} postulate A : Set f : A → A a b c : A fa-to-b : f a ≡ b fx-to-c : ∀ x → f x ≡ c {-# REWRITE fa-to-b #-} {-# REWRITE fx-to-c #-} test₁ : f a ≡ b test₁ = refl x : A test₂ : f x ≡ c test₂ = refl x = a
{ "alphanum_fraction": 0.5309734513, "avg_line_length": 12.5555555556, "ext": "agda", "hexsha": "c3b5f1ed04ffe9f53a89c99e71d25fa0063f450d", "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/RewriteNondeterministic.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/RewriteNondeterministic.agda", "max_line_length": 38, "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/RewriteNondeterministic.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": 129, "size": 339 }
data Type : Set where A B : Type f : Type → Type → Type f A t = t f t = {!t!} -- WAS: Case-splitting t yields an internal error on Agda/TypeChecking/Coverage.hs:467 -- SHOULD: produce the following definition: -- f : Type → Type → Type -- f A t = t -- f B = {!!}
{ "alphanum_fraction": 0.6133828996, "avg_line_length": 17.9333333333, "ext": "agda", "hexsha": "26e44bfc0621f47a951e6f40edad0953482bd785", "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/Issue3828.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/Issue3828.agda", "max_line_length": 86, "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/Issue3828.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": 88, "size": 269 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import groups.HomSequence module cohomology.Theory where -- [i] for the universe level of the group record CohomologyTheory i : Type (lsucc i) where {- functorial parts -} field C : ℤ → Ptd i → Group i C-is-abelian : (n : ℤ) (X : Ptd i) → is-abelian (C n X) C-abgroup : ℤ → Ptd i → AbGroup i C-abgroup n X = C n X , C-is-abelian n X CEl : ℤ → Ptd i → Type i CEl n X = Group.El (C n X) Cident : (n : ℤ) (X : Ptd i) → CEl n X Cident n X = Group.ident (C n X) ⊙CEl : ℤ → Ptd i → Ptd i ⊙CEl n X = ⊙[ CEl n X , Cident n X ] {- functorial parts -} field C-fmap : (n : ℤ) {X Y : Ptd i} → X ⊙→ Y → (C n Y →ᴳ C n X) CEl-fmap : (n : ℤ) {X Y : Ptd i} → X ⊙→ Y → (CEl n Y → CEl n X) CEl-fmap n f = GroupHom.f (C-fmap n f) field C-fmap-idf : (n : ℤ) {X : Ptd i} → ∀ x → CEl-fmap n {X} {X} (⊙idf X) x == x C-fmap-∘ : (n : ℤ) {X Y Z : Ptd i} (g : Y ⊙→ Z) (f : X ⊙→ Y) → ∀ x → CEl-fmap n (g ⊙∘ f) x == CEl-fmap n f (CEl-fmap n g x) field C-Susp : (n : ℤ) (X : Ptd i) → C (succ n) (⊙Susp X) ≃ᴳ C n X CEl-Susp : (n : ℤ) (X : Ptd i) → CEl (succ n) (⊙Susp X) ≃ CEl n X CEl-Susp n X = GroupIso.f-equiv (C-Susp n X) field -- This naming is stretching the convention C-Susp-fmap : (n : ℤ) {X Y : Ptd i} (f : X ⊙→ Y) → CommSquareᴳ (C-fmap (succ n) (⊙Susp-fmap f)) (C-fmap n f) (GroupIso.f-hom (C-Susp n Y)) (GroupIso.f-hom (C-Susp n X)) C-Susp-fmap-cse : (n : ℤ) {X Y : Ptd i} (f : X ⊙→ Y) → CommSquareEquivᴳ (C-fmap (succ n) (⊙Susp-fmap f)) (C-fmap n f) (GroupIso.f-hom (C-Susp n Y)) (GroupIso.f-hom (C-Susp n X)) C-Susp-fmap-cse n {X} {Y} f = C-Susp-fmap n f , GroupIso.f-is-equiv (C-Susp n Y) , GroupIso.f-is-equiv (C-Susp n X) C-Susp-fmap' : (n : ℤ) {X Y : Ptd i} (f : X ⊙→ Y) → CommSquareᴳ (C-fmap n f) (C-fmap (succ n) (⊙Susp-fmap f)) (GroupIso.g-hom (C-Susp n Y)) (GroupIso.g-hom (C-Susp n X)) C-Susp-fmap' n f = fst (CommSquareEquivᴳ-inverse-v (C-Susp-fmap-cse n f)) CEl-Susp-fmap : (n : ℤ) {X Y : Ptd i} (f : X ⊙→ Y) → CommSquare (CEl-fmap (succ n) (⊙Susp-fmap f)) (CEl-fmap n f) (GroupIso.f (C-Susp n Y)) (GroupIso.f (C-Susp n X)) CEl-Susp-fmap n f = comm-sqr λ y' → C-Susp-fmap n f □$ᴳ y' field C-exact : (n : ℤ) {X Y : Ptd i} (f : X ⊙→ Y) → is-exact (C-fmap n (⊙cfcod' f)) (C-fmap n f) C-additive : (n : ℤ) {I : Type i} (Z : I → Ptd i) → C n (⊙BigWedge Z) →ᴳ Πᴳ I (λ i → C n (Z i)) C-additive n Z = Πᴳ-fanout (C-fmap n ∘ ⊙bwin {X = Z}) CEl-additive : (n : ℤ) {I : Type i} (Z : I → Ptd i) → CEl n (⊙BigWedge Z) → Π I (λ i → CEl n (Z i)) CEl-additive n Z = GroupHom.f (C-additive n Z) field C-additive-is-equiv : (n : ℤ) {I : Type i} (Z : I → Ptd i) → has-choice 0 I i → is-equiv (CEl-additive n Z) C-additive-iso : (n : ℤ) {I : Type i} (Z : I → Ptd i) → has-choice 0 I i → C n (⊙BigWedge Z) ≃ᴳ Πᴳ I (λ i → C n (Z i)) C-additive-iso n Z ac = C-additive n Z , C-additive-is-equiv n Z ac C2 : ℤ → Group i C2 n = C n (⊙Lift ⊙Bool) C2-is-abelian : (n : ℤ) → is-abelian (C2 n) C2-is-abelian n = C-is-abelian n (⊙Lift ⊙Bool) C2-abgroup : ℤ → AbGroup i C2-abgroup n = C-abgroup n (⊙Lift ⊙Bool) -- XXX This is put here due to the limitation of the current Agda. -- See issue #434. abstract ∘-C-fmap : (n : ℤ) {X Y Z : Ptd i} (f : X ⊙→ Y) (g : Y ⊙→ Z) → ∀ x → CEl-fmap n f (CEl-fmap n g x) == CEl-fmap n (g ⊙∘ f) x ∘-C-fmap n f g x = ! (C-fmap-∘ n g f x) CEl-fmap-idf = C-fmap-idf CEl-fmap-∘ = C-fmap-∘ ∘-CEl-fmap = ∘-C-fmap CEl-emap : (n : ℤ) {X Y : Ptd i} → X ⊙≃ Y → Group.El (C n Y) ≃ Group.El (C n X) CEl-emap n ⊙eq = equiv (CEl-fmap n (⊙–> ⊙eq)) (CEl-fmap n (⊙<– ⊙eq)) to-from from-to where abstract to-from = λ x → ! (CEl-fmap-∘ n (⊙<– ⊙eq) (⊙–> ⊙eq) x) ∙ ap (λ f → CEl-fmap n f x) (⊙λ= (⊙<–-inv-l ⊙eq)) ∙ CEl-fmap-idf n x from-to = λ x → ! (CEl-fmap-∘ n (⊙–> ⊙eq) (⊙<– ⊙eq) x) ∙ ap (λ f → CEl-fmap n f x) (⊙λ= (⊙<–-inv-r ⊙eq)) ∙ CEl-fmap-idf n x abstract CEl-isemap : (n : ℤ) {X Y : Ptd i} (f : X ⊙→ Y) → is-equiv (fst f) → is-equiv (CEl-fmap n f) CEl-isemap n f f-ise = snd (CEl-emap n (f , f-ise)) C-emap : (n : ℤ) {X Y : Ptd i} → X ⊙≃ Y → C n Y ≃ᴳ C n X C-emap n ⊙eq = ≃-to-≃ᴳ (CEl-emap n ⊙eq) lemma where abstract lemma = GroupHom.pres-comp (C-fmap n (⊙–> ⊙eq)) C-isemap = CEl-isemap {- Cohomology groups are independent of basepoint, and the action of - the cohomology is independent of the basepoint-preservation path -} C-base-indep : (n : ℤ) {A : Type i} (a₀ a₁ : A) → C n ⊙[ A , a₀ ] ≃ᴳ C n ⊙[ A , a₁ ] C-base-indep n a₀ a₁ = C-Susp n ⊙[ _ , a₁ ] ∘eᴳ (C-Susp n ⊙[ _ , a₀ ])⁻¹ᴳ private abstract CEl-fmap-base-indep' : (n : ℤ) {X Y : Ptd i} (f : de⊙ X → de⊙ Y) (p₁ p₂ : f (pt X) == pt Y) → ∀ y → CEl-fmap n (f , p₁) y == CEl-fmap n (f , p₂) y CEl-fmap-base-indep' n {X} {Y} f p₁ p₂ y = CEl-fmap n (f , p₁) y =⟨ ! $ <–-inv-r (CEl-Susp n Y) y |in-ctx CEl-fmap n (f , p₁) ⟩ CEl-fmap n (f , p₁) (–> (CEl-Susp n Y) (<– (CEl-Susp n Y) y)) =⟨ ! $ commutes (CEl-Susp-fmap n (f , p₁)) (<– (CEl-Susp n Y) y) ⟩ –> (CEl-Susp n X) (CEl-fmap (succ n) (Susp-fmap f , idp) (<– (CEl-Susp n Y) y)) =⟨ commutes (CEl-Susp-fmap n (f , p₂)) (<– (CEl-Susp n Y) y) ⟩ CEl-fmap n (f , p₂) (–> (CEl-Susp n Y) (<– (CEl-Susp n Y) y)) =⟨ <–-inv-r (CEl-Susp n Y) y |in-ctx CEl-fmap n (f , p₂) ⟩ CEl-fmap n (f , p₂) y =∎ abstract -- FIXME is there a better name? CEl-fmap-base-indep : (n : ℤ) {X Y : Ptd i} {f g : X ⊙→ Y} → (∀ x → fst f x == fst g x) → (∀ y → CEl-fmap n f y == CEl-fmap n g y) CEl-fmap-base-indep n h y = CEl-fmap-base-indep' n _ _ _ _ ∙ ap (λ f → CEl-fmap n f y) (⊙λ=' h (↓-idf=cst-in' idp)) C-fmap-base-indep = CEl-fmap-base-indep {- cohomology of the unit -} abstract C-Unit : ∀ n → is-trivialᴳ (C n (⊙Lift {j = i} ⊙Unit)) C-Unit n x = x =⟨ ! (CEl-fmap-idf n x) ⟩ CEl-fmap n (⊙idf _) x =⟨ CEl-fmap-base-indep n (λ _ → idp) x ⟩ CEl-fmap n (⊙cst ⊙∘ ⊙cfcod' (⊙idf _)) x =⟨ CEl-fmap-∘ n ⊙cst (⊙cfcod' (⊙idf _)) x ⟩ CEl-fmap n (⊙cfcod' (⊙idf _)) (CEl-fmap n ⊙cst x) =⟨ ! (CEl-fmap-idf n (CEl-fmap n (⊙cfcod' (⊙idf _)) (CEl-fmap n ⊙cst x))) ⟩ CEl-fmap n (⊙idf _) (CEl-fmap n (⊙cfcod' (⊙idf _)) (CEl-fmap n ⊙cst x)) =⟨ im-sub-ker (C-exact n (⊙idf _)) _ [ CEl-fmap n ⊙cst x , idp ] ⟩ Cident n (⊙Lift {j = i} ⊙Unit) =∎ {- more functoriality -} abstract C-fmap-cst : (n : ℤ) {X Y : Ptd i} → ∀ y → CEl-fmap n (⊙cst {X = X} {Y = Y}) y == Cident n X C-fmap-cst n {X} {Y} y = CEl-fmap n (⊙cst {X = ⊙LU} ⊙∘ ⊙cst {X = X}) y =⟨ CEl-fmap-∘ n ⊙cst ⊙cst y ⟩ CEl-fmap n (⊙cst {X = X}) (CEl-fmap n (⊙cst {X = ⊙LU}) y) =⟨ C-Unit n (CEl-fmap n (⊙cst {X = ⊙LU}) y) |in-ctx CEl-fmap n (⊙cst {X = X} {Y = ⊙LU}) ⟩ CEl-fmap n (⊙cst {X = X}) (Cident n ⊙LU) =⟨ GroupHom.pres-ident (C-fmap n (⊙cst {X = X} {Y = ⊙LU})) ⟩ Cident n X ∎ where ⊙LU = ⊙Lift {j = i} ⊙Unit C-fmap-const : (n : ℤ) {X Y : Ptd i} {f : X ⊙→ Y} → (∀ x → fst f x == pt Y) → ∀ y → CEl-fmap n f y == Cident n X C-fmap-const n f-is-const y = CEl-fmap-base-indep n f-is-const y ∙ C-fmap-cst n y -- FIXME Is there a better name? C-fmap-inverse : (n : ℤ) {X Y : Ptd i} (f : X ⊙→ Y) (g : Y ⊙→ X) → (∀ x → fst g (fst f x) == x) → (∀ x → CEl-fmap n f (CEl-fmap n g x) == x) C-fmap-inverse n f g p x = ! (CEl-fmap-∘ n g f x) ∙ CEl-fmap-base-indep n p x ∙ C-fmap-idf n x CEl-fmap-cst = C-fmap-cst CEl-fmap-const = C-fmap-const CEl-fmap-inverse = C-fmap-inverse record OrdinaryTheory i : Type (lsucc i) where constructor ordinary-theory field -- XXX This should be cohomology-thy cohomology-theory : CohomologyTheory i open CohomologyTheory cohomology-theory public field C-dimension : {n : ℤ} → n ≠ 0 → is-trivialᴳ (C2 n)
{ "alphanum_fraction": 0.4995756032, "avg_line_length": 37.3167420814, "ext": "agda", "hexsha": "6271a52b326f628b64eabee478f6c0e4eb6ea2c8", "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": "theorems/cohomology/Theory.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": "theorems/cohomology/Theory.agda", "max_line_length": 117, "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": "theorems/cohomology/Theory.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3909, "size": 8247 }
module HyperReal where open import Data.Nat open import Data.Nat.Properties open import Data.Empty open import Relation.Nullary using (¬_; Dec; yes; no) open import Level renaming ( suc to succ ; zero to Zero ; _⊔_ to _L⊔_ ) open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Relation.Binary.Definitions open import Relation.Binary.Structures open import nat open import logic open import bijection HyperNat : Set HyperNat = ℕ → ℕ open _∧_ open Bijection n1 : ℕ → ℕ n1 n = proj1 (fun→ nxn n) n2 : ℕ → ℕ n2 n = proj2 (fun→ nxn n) _n*_ : (i j : HyperNat ) → HyperNat i n* j = λ k → i k * j k _n+_ : (i j : HyperNat ) → HyperNat i n+ j = λ k → i k + j k hzero : HyperNat hzero _ = 0 h : (n : ℕ) → HyperNat h n _ = n record _n=_ (i j : HyperNat ) : Set where field =-map : Bijection ℕ ℕ =-m : ℕ is-n= : (k : ℕ ) → k > =-m → i k ≡ j (fun→ =-map k) open _n=_ record _n≤_ (i j : HyperNat ) : Set where field ≤-map : Bijection ℕ ℕ ≤-m : ℕ is-n≤ : (k : ℕ ) → k > ≤-m → i k ≤ j (fun→ ≤-map k) open _n≤_ record _n<_ (i j : HyperNat ) : Set where field <-map : Bijection ℕ ℕ <-m : ℕ is-n< : (k : ℕ ) → k > <-m → i k < j (fun→ <-map k) open _n<_ _n<=s≤_ : (i j : HyperNat ) → (i n< j) ⇔ (( i n+ h 1 ) n≤ j ) _n<=s≤_ = {!!} ¬hn<0 : {x : HyperNat } → ¬ ( x n< h 0 ) ¬hn<0 {x} x<0 = ⊥-elim ( nat-≤> (is-n< x<0 (suc (<-m x<0)) a<sa) 0<s ) postulate <-cmpn : Trichotomous {Level.zero} _n=_ _n<_ n=IsEquivalence : IsEquivalence _n=_ n=IsEquivalence = record { refl = record {=-map = bid ℕ ; =-m = 0 ; is-n= = λ _ _ → refl} ; sym = λ xy → record {=-map = bi-sym ℕ ℕ (=-map xy) ; =-m = =-m xy ; is-n= = λ k lt → {!!} } -- (is-n= xy k lt) } ; trans = λ xy yz → record {=-map = bi-trans ℕ ℕ ℕ (=-map xy) (=-map yz) ; =-m = {!!} ; is-n= = λ k lt → {!!} } } HNTotalOrder : IsTotalPreorder _n=_ _n≤_ HNTotalOrder = record { isPreorder = record { isEquivalence = n=IsEquivalence ; reflexive = λ eq → record { ≤-map = =-map eq ; ≤-m = =-m eq ; is-n≤ = {!!} } ; trans = trans1 } ; total = total } where open import Data.Sum.Base using (_⊎_) open _⊎_ total : (x y : HyperNat ) → (x n≤ y) ⊎ (y n≤ x) total x y with <-cmpn x y ... | tri< a ¬b ¬c = inj₁ {!!} ... | tri≈ ¬a b ¬c = {!!} ... | tri> ¬a ¬b c = {!!} trans1 : {i j k : HyperNat} → i n≤ j → j n≤ k → i n≤ k trans1 = {!!} record n-finite (i : HyperNat ) : Set where field val : ℕ is-val : i n= h val n-infinite : (i : HyperNat ) → Set n-infinite i = (j : ℕ ) → h j n≤ i n-linear : HyperNat n-linear i = i n-linear-is-infnite : n-infinite n-linear n-linear-is-infnite i = record { ≤-map = bid ℕ ; ≤-m = i ; is-n≤ = λ k lt → <to≤ lt } ¬-infinite-n-finite : (i : HyperNat ) → n-finite i → ¬ n-infinite i ¬-infinite-n-finite = {!!} data HyperZ : Set where hz : HyperNat → HyperNat → HyperZ hZ : ℕ → ℕ → HyperZ hZ x y = hz (λ _ → x) (λ _ → y ) _z+_ : (i j : HyperZ ) → HyperZ hz i i₁ z+ hz j j₁ = hz ( i n+ j ) (i₁ n+ j₁ ) _z*_ : (i j : HyperZ ) → HyperZ hz i i₁ z* hz j j₁ = hz (λ k → i k * j k + i₁ k * j₁ k ) (λ k → i k * j₁ k - i₁ k * j k ) -- x0 - y0 ≡ x1 - y1 -- x0 + y1 ≡ x1 + y0 -- _z=_ : (i j : HyperZ ) → Set _z=_ (hz x0 y0) (hz x1 y1) = (x0 n+ y1) n= (x1 n+ y0) _z≤_ : (i j : HyperZ ) → Set _z≤_ (hz x0 y0) (hz x1 y1) = (x0 n+ y1) n≤ (x1 n+ y0) _z<_ : (i j : HyperZ ) → Set _z<_ (hz x0 y0) (hz x1 y1) = (x0 n+ y1) n< (x1 n+ y0) <-cmpz : Trichotomous {Level.zero} _z=_ _z<_ <-cmpz (hz x0 y0) (hz x1 y1) = <-cmpn (x0 n+ y1) (x1 n+ y0) -z : (i : HyperZ ) → HyperZ -z (hz x y) = hz y x z-z=0 : (i : HyperZ ) → (i z+ (-z i)) z= hZ 0 0 z-z=0 = {!!} z+infinite : (i : HyperZ ) → Set z+infinite i = (j : ℕ ) → hZ j 0 z≤ i z-infinite : (i : HyperZ ) → Set z-infinite i = (j : ℕ ) → i z≤ hZ 0 j import Axiom.Extensionality.Propositional postulate f-extensionality : { n m : Level} → Axiom.Extensionality.Propositional.Extensionality n m --- x*y ...... 0 0 0 0 ... --- x ...... 0 0 1 0 1 .... --- y ...... 0 1 0 1 0 .... HNnzero* : {x y : HyperNat } → ¬ ( x n= h 0 ) → ¬ ( y n= h 0 ) → ¬ ( (x n* y) n= h 0 ) HNnzero* {x} {y} nzx nzy xy0 = hn1 where hn2 : ( h 0 n< x ) → ( h 0 n< y ) → ¬ ( (x n* y) n= h 0 ) hn2 0<x 0<y xy0 = ⊥-elim ( nat-≡< (sym (is-n= xy0 (suc mxy) {!!} )) {!!} ) where mxy : ℕ mxy = <-m 0<x ⊔ <-m 0<y ⊔ =-m xy0 hn1 : ⊥ hn1 with <-cmpn x (h 0) ... | tri≈ ¬a b ¬c = nzx b ... | tri< a ¬b ¬c = ⊥-elim ( ¬hn<0 a) hn1 | tri> ¬a ¬b c with <-cmpn y (h 0) ... | tri< a ¬b₁ ¬c = ⊥-elim ( ¬hn<0 a) ... | tri≈ ¬a₁ b ¬c = nzy b ... | tri> ¬a₁ ¬b₁ c₁ = hn2 c c₁ xy0 HZzero : HyperZ → Set HZzero z = hZ 0 0 z= z HZzero? : ( i : HyperZ ) → Dec (HZzero i) HZzero? = {!!} data HyperR : Set where hr : HyperZ → (k : HyperNat ) → ((i : ℕ) → 0 < k i) → HyperR HZnzero* : {x y : HyperZ } → ¬ ( HZzero x ) → ¬ ( HZzero y ) → ¬ ( HZzero (x z* y) ) HZnzero* {x} {y} nzx nzy nzx*y = {!!} HRzero : HyperR → Set HRzero (hr i j nz ) = HZzero i R0 : HyperR R0 = hr (hZ 0 0) (h 1) {!!} record Rational : Set where field rp rm k : ℕ 0<k : 0 < k hR : ℕ → ℕ → (k : HyperNat ) → ((i : ℕ) → 0 < k i) → HyperR hR x y k ne = hr (hZ x y) k ne rH : (r : Rational ) → HyperR rH r = hr (hZ (Rational.rp r) (Rational.rm r)) (h (Rational.k r)) {!!} -- -- z0 / y0 = z1 / y1 ← z0 * y1 = z1 * y0 -- _h=_ : (i j : HyperR ) → Set hr z0 k0 ne0 h= hr z1 k1 ne1 = (z0 z* (hz k1 (h 0))) z= (z1 z* (hz k0 (h 0))) _h≤_ : (i j : HyperR ) → Set hr z0 k0 ne0 h≤ hr z1 k1 ne1 = (z0 z* (hz k1 (h 0))) z≤ (z1 z* (hz k0 (h 0))) _h<_ : (i j : HyperR ) → Set hr z0 k0 ne0 h< hr z1 k1 ne1 = (z0 z* (hz k1 (h 0))) z< (z1 z* (hz k0 (h 0))) <-cmph : Trichotomous {Level.zero} _h=_ _h<_ <-cmph (hr z0 k0 ne0 ) ( hr z1 k1 ne1 ) = <-cmpz (z0 z* (hz k1 (h 0))) (z1 z* (hz k0 (h 0))) _h*_ : (i j : HyperR) → HyperR hr x k nz h* hr y k₁ nz₁ = hr ( x z* y ) ( k n* k₁ ) {!!} _h+_ : (i j : HyperR) → HyperR hr x k nz h+ hr y k₁ nz₁ = hr ( (x z* (hz k hzero)) z+ (y z* (hz k₁ hzero)) ) (k n* k₁) {!!} -h : (i : HyperR) → HyperR -h (hr x k nz) = hr (-z x) k nz inifinitesimal-R : (inf : HyperR) → Set inifinitesimal-R inf = ( r : Rational ) → R0 h< rH r → ( -h (rH r) h< inf ) ∧ ( inf h< rH r) 1/x : HyperR 1/x = hr (hZ 1 0) n-linear {!!} 1/x-is-inifinitesimal : inifinitesimal-R 1/x 1/x-is-inifinitesimal r 0<r = ⟪ {!!} , {!!} ⟫ HyperReal : Set HyperReal = ℕ → HyperR HR→HRl : HyperR → HyperReal HR→HRl (hr (hz x y) k ne) k1 = hr (hz (λ k2 → (x k1)) (λ k2 → (x k1))) k ne HRl→HR : HyperReal → HyperR HRl→HR r = hr (hz (λ k → {!!}) (λ k → {!!}) ) factor {!!} where factor : HyperNat factor n = {!!} fne : (n : ℕ) → ¬ (factor n= h 0) fne = {!!} _≈_ : (x y : HyperR ) → Set x ≈ y = inifinitesimal-R (x h+ ( -h y )) is-inifinitesimal : {x : HyperR } → inifinitesimal-R x → x ≈ R0 is-inifinitesimal {x} inf = {!!} record Standard : Set where field standard : HyperR → HyperR is-standard : {x : HyperR } → x ≈ standard x standard-unique : {x y : HyperR } → x ≈ y → standard x ≡ standard y st-inifinitesimal : {x : HyperR } → inifinitesimal-R x → st x ≡ R0 postulate ST : Standard open Standard st : HyperR → HyperR st x = standard ST x
{ "alphanum_fraction": 0.5033729088, "avg_line_length": 27.3505535055, "ext": "agda", "hexsha": "f6dbf3b5ea1ceb39bf9b114b1cb5f68a2fa0cf76", "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/HyperReal.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/HyperReal.agda", "max_line_length": 118, "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/HyperReal.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3302, "size": 7412 }
module Data.Tuple.Equiv.Id where import Lvl open import Data.Tuple as Tuple using (_⨯_ ; _,_) open import Data.Tuple.Equiv open import Relator.Equals open import Relator.Equals.Proofs.Equiv open import Structure.Function open import Structure.Function.Domain open import Structure.Operator open import Type private variable ℓ ℓₒ₁ ℓₒ₂ : Lvl.Level private variable A B : Type{ℓ} private variable f g : A → B private variable p : A ⨯ B instance Tuple-Id-extensionality : Extensionality{A = A}{B = B}([≡]-equiv) Tuple-Id-extensionality = intro Tuple-left-map : (Tuple.left(Tuple.map f g p) ≡ f(Tuple.left(p))) Tuple-left-map = [≡]-intro Tuple-right-map : (Tuple.right(Tuple.map f g p) ≡ g(Tuple.right(p))) Tuple-right-map = [≡]-intro
{ "alphanum_fraction": 0.7311827957, "avg_line_length": 27.5555555556, "ext": "agda", "hexsha": "5a1212b3f99cf483672423ae84dfd4f3b865d92c", "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/Tuple/Equiv/Id.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/Tuple/Equiv/Id.agda", "max_line_length": 68, "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/Tuple/Equiv/Id.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": 221, "size": 744 }
-- Syntax of a second-order language module SOAS.Metatheory.Syntax {T : Set} where open import SOAS.Families.Core {T} open import SOAS.Families.Build open import SOAS.Common open import SOAS.Context open import Categories.Object.Initial open import SOAS.Construction.Structure open import SOAS.ContextMaps.Inductive open import SOAS.Coalgebraic.Strength open import SOAS.Abstract.ExpStrength open import SOAS.Metatheory.MetaAlgebra -- Data characterising a second-order syntax: -- * a signature endofunctor ⅀ -- * coalgebraic and exponential strength -- * initial (⅀,𝔛)-meta-algebra for each 𝔛 -- + an inductive metavariable constructor for convenience record Syntax : Set₁ where field ⅀F : Functor 𝔽amiliesₛ 𝔽amiliesₛ ⅀:CS : CompatStrengths ⅀F 𝕋:Init : (𝔛 : Familyₛ) → Initial (𝕄etaAlgebras ⅀F 𝔛) mvarᵢ : {𝔛 : Familyₛ}{τ : T}{Π Γ : Ctx} (open Initial (𝕋:Init 𝔛)) → 𝔛 τ Π → Sub (𝐶 ⊥) Π Γ → 𝐶 ⊥ τ Γ module _ {𝔛 : Familyₛ} where open Initial (𝕋:Init 𝔛) private variable α α₁ α₂ α₃ α₄ α₅ α₆ α₇ α₈ α₉ : T Γ Π Π₁ Π₂ Π₃ Π₄ Π₅ Π₆ Π₇ Π₈ Π₉ : Ctx 𝔐 : MCtx Tm : MCtx → Familyₛ Tm 𝔐 = 𝐶 (Initial.⊥ (𝕋:Init ∥ 𝔐 ∥)) -- Shorthands for metavariables associated with a metavariable environment infix 100 𝔞⟨_ 𝔟⟨_ 𝔠⟨_ 𝔡⟨_ 𝔢⟨_ infix 100 ◌ᵃ⟨_ ◌ᵇ⟨_ ◌ᶜ⟨_ ◌ᵈ⟨_ ◌ᵉ⟨_ 𝔞⟨_ : Sub (Tm (⁅ Π ⊩ₙ α ⁆ 𝔐)) Π Γ → Tm (⁅ Π ⊩ₙ α ⁆ 𝔐) α Γ 𝔞⟨ ε = mvarᵢ ↓ ε 𝔟⟨_ : Sub (Tm (⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐)) Π Γ → Tm (⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐) α Γ 𝔟⟨ ε = mvarᵢ (↑ ↓) ε 𝔠⟨_ : Sub (Tm (⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐)) Π Γ → Tm (⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐) α Γ 𝔠⟨ ε = mvarᵢ (↑ ↑ ↓) ε 𝔡⟨_ : Sub (Tm (⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐)) Π Γ → Tm (⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐) α Γ 𝔡⟨ ε = mvarᵢ (↑ ↑ ↑ ↓) ε 𝔢⟨_ : Sub (Tm (⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐)) Π Γ → Tm (⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐) α Γ 𝔢⟨ ε = mvarᵢ (↑ ↑ ↑ ↑ ↓) ε 𝔣⟨_ : Sub (Tm (⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐)) Π Γ → Tm (⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐) α Γ 𝔣⟨ ε = mvarᵢ (↑ ↑ ↑ ↑ ↑ ↓) ε 𝔤⟨_ : Sub (Tm (⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐)) Π Γ → Tm (⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐) α Γ 𝔤⟨ ε = mvarᵢ (↑ ↑ ↑ ↑ ↑ ↑ ↓) ε 𝔥⟨_ : Sub (Tm (⁅ Π₇ ⊩ₙ α₇ ⁆ ⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐)) Π Γ → Tm (⁅ Π₇ ⊩ₙ α₇ ⁆ ⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐) α Γ 𝔥⟨ ε = mvarᵢ (↑ ↑ ↑ ↑ ↑ ↑ ↑ ↓) ε 𝔦⟨_ : Sub (Tm (⁅ Π₈ ⊩ₙ α₈ ⁆ ⁅ Π₇ ⊩ₙ α₇ ⁆ ⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐)) Π Γ → Tm (⁅ Π₈ ⊩ₙ α₈ ⁆ ⁅ Π₇ ⊩ₙ α₇ ⁆ ⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐) α Γ 𝔦⟨ ε = mvarᵢ (↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↓) ε 𝔧⟨_ : Sub (Tm (⁅ Π₉ ⊩ₙ α₉ ⁆ ⁅ Π₈ ⊩ₙ α₈ ⁆ ⁅ Π₇ ⊩ₙ α₇ ⁆ ⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐)) Π Γ → Tm (⁅ Π₉ ⊩ₙ α₉ ⁆ ⁅ Π₈ ⊩ₙ α₈ ⁆ ⁅ Π₇ ⊩ₙ α₇ ⁆ ⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ Π ⊩ₙ α ⁆ 𝔐) α Γ 𝔧⟨ ε = mvarᵢ (↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↑ ↓) ε -- Shorthands for metavariables with an empty metavariable environment 𝔞 : Tm (⁅ α ⁆ 𝔐) α Γ 𝔞 = 𝔞⟨ • 𝔟 : Tm (⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ α ⁆ 𝔐) α Γ 𝔟 = 𝔟⟨ • 𝔠 : Tm (⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ α ⁆ 𝔐) α Γ 𝔠 = 𝔠⟨ • 𝔡 : Tm (⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ α ⁆ 𝔐) α Γ 𝔡 = 𝔡⟨ • 𝔢 : Tm (⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ α ⁆ 𝔐) α Γ 𝔢 = 𝔢⟨ • 𝔣 : Tm (⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ α ⁆ 𝔐) α Γ 𝔣 = 𝔣⟨ • 𝔤 : Tm (⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ α ⁆ 𝔐) α Γ 𝔤 = 𝔤⟨ • 𝔥 : Tm (⁅ Π₇ ⊩ₙ α₇ ⁆ ⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ α ⁆ 𝔐) α Γ 𝔥 = 𝔥⟨ • 𝔦 : Tm (⁅ Π₈ ⊩ₙ α₈ ⁆ ⁅ Π₇ ⊩ₙ α₇ ⁆ ⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ α ⁆ 𝔐) α Γ 𝔦 = 𝔦⟨ • 𝔧 : Tm (⁅ Π₉ ⊩ₙ α₉ ⁆ ⁅ Π₈ ⊩ₙ α₈ ⁆ ⁅ Π₇ ⊩ₙ α₇ ⁆ ⁅ Π₆ ⊩ₙ α₆ ⁆ ⁅ Π₅ ⊩ₙ α₅ ⁆ ⁅ Π₄ ⊩ₙ α₄ ⁆ ⁅ Π₃ ⊩ₙ α₃ ⁆ ⁅ Π₂ ⊩ₙ α₂ ⁆ ⁅ Π₁ ⊩ₙ α₁ ⁆ ⁅ α ⁆ 𝔐) α Γ 𝔧 = 𝔧⟨ • -- Synonyms for holes ◌ᵃ = 𝔞 ; ◌ᵇ = 𝔟 ; ◌ᶜ = 𝔠 ; ◌ᵈ = 𝔡 ; ◌ᵉ = 𝔢 ◌ᵃ⟨_ = 𝔞⟨_ ; ◌ᵇ⟨_ = 𝔟⟨_ ; ◌ᶜ⟨_ = 𝔠⟨_ ; ◌ᵈ⟨_ = 𝔡⟨_ ; ◌ᵉ⟨_ = 𝔢⟨_
{ "alphanum_fraction": 0.4487318448, "avg_line_length": 38.1239669421, "ext": "agda", "hexsha": "87d1431378c27b4632418037a5e5502b81231c17", "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": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "SOAS/Metatheory/Syntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "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": "JoeyEremondi/agda-soas", "max_issues_repo_path": "SOAS/Metatheory/Syntax.agda", "max_line_length": 152, "max_stars_count": null, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "SOAS/Metatheory/Syntax.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3747, "size": 4613 }
{-# OPTIONS --inversion-max-depth=10 #-} open import Agda.Builtin.Nat data _×_ (A B : Set) : Set where _,_ : A → B → A × B F : Nat → Set F zero = Nat F (suc n) = Nat × F n f : (n : Nat) → F n f zero = zero f (suc n) = n , f n mutual n : Nat n = _ test : F n test = f (suc n)
{ "alphanum_fraction": 0.5067114094, "avg_line_length": 12.9565217391, "ext": "agda", "hexsha": "73ae4ec92980ca3eda8d900db2ac803a4f30b5fa", "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/Issue431b.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/Issue431b.agda", "max_line_length": 40, "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/Issue431b.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": 125, "size": 298 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- Nils' idea about databases in the Agda mailing list. -- http://thread.gmane.org/gmane.comp.lang.agda/2911/focus=2917 module DataBase where infixr 7 _,_ _,′_ infixr 5 _∧_ data _∧_ (A B : Set) : Set where _,_ : A → B → A ∧ B _,′_ : ∀ {A B} → A → B → A ∧ B _,′_ = _,_ postulate P Q R S : Set h₁ : P → Q h₂ : Q → R h₃ : R → S postulate thm₁ : P → S {-# ATP prove thm₁ h₁ h₂ h₃ #-} db = h₁ ,′ h₂ ,′ h₃ postulate thm₂ : P → S {-# ATP prove thm₂ db #-}
{ "alphanum_fraction": 0.5251908397, "avg_line_length": 19.8484848485, "ext": "agda", "hexsha": "355fe32b3e3966c725e6240995fe12e64864fc61", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/DataBase.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/DataBase.agda", "max_line_length": 63, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/DataBase.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": 239, "size": 655 }
-------------------------------------------------------------------------------- -- White or blacklisting of characters -------------------------------------------------------------------------------- module Parse.MultiChar where import Data.List.NonEmpty as NE open import Data.String hiding (show) open import Prelude -- TODO: Groups of characters, such as digits or lower case letters MultiCharGroup : Set MultiCharGroup = ⊥ matchCharGroup : MultiCharGroup → Char → Bool matchCharGroup () data CharMatcher : Set where Single : Char → CharMatcher Group : MultiCharGroup → CharMatcher instance CharMatcher-Show : Show CharMatcher CharMatcher-Show = record { show = helper } where helper : CharMatcher → String helper (Single c) = fromChar c parseCharMatcher : String → Maybe CharMatcher parseCharMatcher s with uncons s ... | just (c , "") = just (Single c) ... | _ = nothing matchCharMatcher : CharMatcher → Char → Bool matchCharMatcher (Single x) c = x ≣ c matchCharMatcher (Group g) c = matchCharGroup g c record MultiChar : Set where field matches : List CharMatcher negated : Bool instance MultiChar-Show : Show MultiChar MultiChar-Show = record { show = helper } where helper : MultiChar → String helper m = (if negated then "!" else "") + show matches where open MultiChar m parseMultiChar : Bool → List String → MultiChar parseMultiChar b l = record { matches = mapMaybe parseCharMatcher l ; negated = b } parseMultiCharNE : Bool → NE.List⁺ String → MultiChar parseMultiCharNE b l = parseMultiChar b (NE.toList l) matchMulti : MultiChar → Char → Bool matchMulti m c = negated xor (or $ map (flip matchCharMatcher c) matches) where open MultiChar m
{ "alphanum_fraction": 0.6472269868, "avg_line_length": 28.6721311475, "ext": "agda", "hexsha": "8b4ad2904d59c3d7a46a0caae4b5268322b3cdfd", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "src/Parse/MultiChar.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "src/Parse/MultiChar.agda", "max_line_length": 83, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "src/Parse/MultiChar.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 420, "size": 1749 }
module #4 where open import Data.Nat open import Data.Product {- Exercise 1.4. Assuming as given only the iterator for natural numbers iter : ∏ C → (C → C) → N → C C:U with the defining equations iter(C, c0, cs, 0) :≡ c0 iter(C, c0, cs, succ(n)) :≡ cs(iter(C, c0, cs, n)), derive a function having the type of the recursor recN. Show that the defining equations of the recursor hold propositionally for this function, using the induction principle for N. -} iter : ∀{k}{C : Set k} → C → (C → C) → ℕ → C iter c0 cs zero = c0 iter c0 cs (suc n) = cs (iter c0 cs n) ind-ℕ : ∀{k}{C : ℕ → Set k} → C zero → ((n : ℕ) → C n → C (suc n)) → (n : ℕ) → C n ind-ℕ c0 cs zero = c0 ind-ℕ c0 cs (suc n) = cs n (ind-ℕ c0 cs n) rec : ∀{k}{C : Set k} → C → (ℕ → C → C) → ℕ → C rec {i}{C} c0 f n = proj₂ (iter z (λ p → (suc (proj₁ p) , f (proj₁ p) (proj₂ p))) n) where z : ℕ × C z = (0 , c0)
{ "alphanum_fraction": 0.5714285714, "avg_line_length": 26.7647058824, "ext": "agda", "hexsha": "16eea886c66ff7f916b2ea570ad7606dfe5a8a00", "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": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_path": "Chapter1/#4.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "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": "CodaFi/HoTT-Exercises", "max_issues_repo_path": "Chapter1/#4.agda", "max_line_length": 95, "max_stars_count": null, "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_path": "Chapter1/#4.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 365, "size": 910 }
------------------------------------------------------------------------ -- The Agda standard library -- -- An example showing how the Debug.Trace module can be used ------------------------------------------------------------------------ {-# OPTIONS --without-K #-} module README.Debug.Trace where ------------------------------------------------------------------------ -- Sometimes compiled code can contain bugs. -- Whether caused by the compiler or present in the source code already, they -- can be hard to track. A primitive debugging technique is to strategically -- insert calls to tracing functions which will display their String argument -- upon evaluation. open import Data.String.Base using (_++_) open import Debug.Trace -- We can for instance add tracing messages to make sure an invariant is -- respected or check in which order evaluation takes place in the backend -- (which can inform our decision to use, or not, strictness primitives). -- In the following example, we define a division operation on natural numbers -- using the original dividend as the termination measure. We: -- 1. check in the base case that when the fuel runs out then the updated dividend -- is already zero. -- 2. wrap the calls to _∸_ and go in respective calls to trace to see when all -- of these thunks are forced: are we building a big thunk in go's second -- argument or evaluating it as we go? open import Data.Maybe.Base open import Data.Nat.Base open import Data.Nat.Show using (show) div : ℕ → ℕ → Maybe ℕ div m zero = nothing div m n = just (go m m) where -- invariants: m ≤ fuel -- result : m / n go : (fuel : ℕ) (m : ℕ) → ℕ go zero m = trace ("Invariant: " ++ show m ++ " should be zero.") zero go (suc fuel) m = let m' = trace ("Thunk for step " ++ show fuel ++ " forced") (m ∸ n) in trace ("Recursive call for step " ++ show fuel) (suc (go fuel m')) -- To observe the behaviour of this code, we need to compile it and run it. -- To run it, we need a main function. We define a very basic one: run div, -- and display its result if the run was successful. -- We add two calls to trace to see when div is evaluated and when the returned -- number is forced (by a call to show). open import IO main = let r = trace "Call to div" (div 4 2) j = λ n → trace "Forcing the result wrapped in just." (putStrLn (show n)) in run (maybe′ j (return _) r) -- We get the following trace where we can see that checking that the -- maybe-solution is just-headed does not force the natural number. Once forced, -- we observe that we indeed build a big thunk on go's second argument (all the -- recursive calls happen first and then we force the thunks one by one). -- Call to div -- Forcing the result wrapped in just. -- Recursive call for step 3 -- Recursive call for step 2 -- Recursive call for step 1 -- Recursive call for step 0 -- Thunk for step 0 forced -- Thunk for step 1 forced -- Thunk for step 2 forced -- Thunk for step 3 forced -- Invariant: 0 should be zero. -- 4 -- We also notice that the result is incorrect: 4/2 is 2 and not 4. We quickly -- notice that (div m (suc n)) will perform m recursive calls no matter what. -- And at each call it will put add 1. We can fix this bug by adding a new first -- equation to go: -- go fuel zero = zero -- Running the example again we observe that because we now need to check -- whether go's second argument is zero, the function is more strict: we see -- that recursive calls and thunk forcings are interleaved. -- Call to div -- Forcing the result wrapped in just. -- Recursive call for step 3 -- Thunk for step 3 forced -- Recursive call for step 2 -- Thunk for step 2 forced -- 2
{ "alphanum_fraction": 0.6652256147, "avg_line_length": 36.2843137255, "ext": "agda", "hexsha": "f9181a99d11e203ce95a559cff99639945abcde4", "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/README/Debug/Trace.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/README/Debug/Trace.agda", "max_line_length": 82, "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/README/Debug/Trace.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": 901, "size": 3701 }
open import Nat open import Prelude open import dynamics-core open import lemmas-gcomplete module lemmas-complete where -- no term is both complete and indeterminate lem-ind-comp : ∀{d} → d dcomplete → d indet → ⊥ lem-ind-comp DCNum () lem-ind-comp (DCPlus comp comp₁) (IPlus1 ind fin) = lem-ind-comp comp ind lem-ind-comp (DCPlus comp comp₁) (IPlus2 fin ind) = lem-ind-comp comp₁ ind lem-ind-comp DCVar () lem-ind-comp (DCLam comp x₁) () lem-ind-comp (DCAp comp comp₁) (IAp x ind x₁) = lem-ind-comp comp ind lem-ind-comp (DCCast comp x x₁) (ICastArr x₂ ind) = lem-ind-comp comp ind lem-ind-comp (DCCast comp x x₁) (ICastGroundHole x₂ ind) = lem-ind-comp comp ind lem-ind-comp (DCCast comp x x₁) (ICastHoleGround x₂ ind x₃) = lem-ind-comp comp ind lem-ind-comp (DCInl x comp) (IInl ind) = lem-ind-comp comp ind lem-ind-comp (DCInr x comp) (IInr ind) = lem-ind-comp comp ind lem-ind-comp (DCCase comp comp₁ comp₂) (ICase x x₁ x₂ ind) = lem-ind-comp comp ind lem-ind-comp (DCCast comp x x₁) (ICastSum x₂ ind) = lem-ind-comp comp ind lem-ind-comp (DCPair comp comp₁) (IPair1 ind x) = lem-ind-comp comp ind lem-ind-comp (DCPair comp comp₁) (IPair2 x ind) = lem-ind-comp comp₁ ind lem-ind-comp (DCFst comp) (IFst x x₁ ind) = lem-ind-comp comp ind lem-ind-comp (DCSnd comp) (ISnd x x₁ ind) = lem-ind-comp comp ind lem-ind-comp (DCCast comp x x₁) (ICastProd x₂ ind) = lem-ind-comp comp ind -- complete types that are consistent are equal complete-consistency : ∀{τ1 τ2} → τ1 ~ τ2 → τ1 tcomplete → τ2 tcomplete → τ1 == τ2 complete-consistency TCRefl TCNum comp2 = refl complete-consistency TCRefl (TCArr comp1 comp2) comp3 = refl complete-consistency TCRefl (TCSum tc1 tc3) comp2 = refl complete-consistency TCHole1 comp1 () complete-consistency (TCArr consis consis₁) (TCArr comp1 comp2) (TCArr comp3 comp4) with complete-consistency consis comp1 comp3 | complete-consistency consis₁ comp2 comp4 ... | refl | refl = refl complete-consistency (TCSum consis consis₁) (TCSum comp1 comp2) (TCSum comp3 comp4) with complete-consistency consis comp1 comp3 | complete-consistency consis₁ comp2 comp4 ... | refl | refl = refl complete-consistency TCRefl (TCProd comp comp₁) comp2 = refl complete-consistency TCHole2 () comp2 complete-consistency (TCProd consis consis₁) (TCProd comp1 comp2) (TCProd comp3 comp4) with complete-consistency consis comp1 comp3 | complete-consistency consis₁ comp2 comp4 ... | refl | refl = refl -- a well typed complete term is assigned a complete type complete-ta : ∀{Γ Δ d τ} → (Γ gcomplete) → (Δ , Γ ⊢ d :: τ) → d dcomplete → τ tcomplete complete-ta gc TANum comp = TCNum complete-ta gc (TAPlus wt wt₁) comp = TCNum complete-ta gc (TAVar x₁) DCVar = gc _ _ x₁ complete-ta gc (TALam a wt) (DCLam comp x₁) = TCArr x₁ (complete-ta (gcomp-extend gc x₁ a ) wt comp) complete-ta gc (TAAp wt wt₁) (DCAp comp comp₁) with complete-ta gc wt comp ... | TCArr qq qq₁ = qq₁ complete-ta gc (TAEHole x x₁) () complete-ta gc (TANEHole x wt x₁) () complete-ta gc (TACast wt x) (DCCast comp x₁ x₂) = x₂ complete-ta gc (TAFailedCast wt x x₁ x₂) () complete-ta gc (TAInl wt) (DCInl x comp) = TCSum (complete-ta gc wt comp) x complete-ta gc (TAInr wt) (DCInr x comp) = TCSum x (complete-ta gc wt comp) complete-ta gc (TACase wt apt₁ wt₁ apt₂ wt₂) (DCCase comp comp₁ comp₂) with complete-ta gc wt comp ... | TCSum τc1 τc2 = complete-ta (gcomp-extend gc τc1 apt₁) wt₁ comp₁ complete-ta gc (TAPair wt wt₁) (DCPair comp comp₁) = TCProd (complete-ta gc wt comp) (complete-ta gc wt₁ comp₁) complete-ta gc (TAFst wt) (DCFst comp) with complete-ta gc wt comp ... | TCProd τc1 τc2 = τc1 complete-ta gc (TASnd wt) (DCSnd comp) with complete-ta gc wt comp ... | TCProd τc1 τc2 = τc2 -- a well typed term synthesizes a complete type comp-synth : ∀{Γ e τ} → Γ gcomplete → e ecomplete → Γ ⊢ e => τ → τ tcomplete comp-synth gc ec SNum = TCNum comp-synth gc ec (SPlus x x₁) = TCNum comp-synth gc (ECAsc x ec) (SAsc x₁) = x comp-synth gc ec (SVar x) = gc _ _ x comp-synth gc (ECAp ec ec₁) (SAp wt MAHole x₁) with comp-synth gc ec wt ... | () comp-synth gc (ECAp ec ec₁) (SAp wt MAArr x₁) with comp-synth gc ec wt comp-synth gc (ECAp ec ec₁) (SAp wt MAArr x₁) | TCArr qq qq₁ = qq₁ comp-synth gc () SEHole comp-synth gc () (SNEHole wt) comp-synth gc (ECLam2 ec x₁) (SLam x₂ wt) = TCArr x₁ (comp-synth (gcomp-extend gc x₁ x₂) ec wt) comp-synth gc (ECPair ec ec₁) (SPair wt wt₁) with comp-synth gc ec wt | comp-synth gc ec₁ wt₁ ... | τc1 | τc2 = TCProd τc1 τc2 comp-synth gc (ECFst ec) (SFst wt MPHole) with comp-synth gc ec wt ... | () comp-synth gc (ECFst ec) (SFst wt MPProd) with comp-synth gc ec wt ... | TCProd τc1 τc2 = τc1 comp-synth gc (ECSnd ec) (SSnd wt MPHole) with comp-synth gc ec wt ... | () comp-synth gc (ECSnd ec) (SSnd wt MPProd) with comp-synth gc ec wt ... | TCProd τc1 τc2 = τc2
{ "alphanum_fraction": 0.6680983991, "avg_line_length": 49.25, "ext": "agda", "hexsha": "0e86adec58c711bd388f4c219b10027f5f09b721", "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": "lemmas-complete.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": "lemmas-complete.agda", "max_line_length": 113, "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": "lemmas-complete.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1839, "size": 5122 }
{-# OPTIONS --cubical #-} module Issue4365 where open import Agda.Primitive.Cubical open import Agda.Builtin.Cubical.Path open import Agda.Builtin.String postulate s : String _ : primTransp (\ i → String) i0 s ≡ s _ = \ _ → s
{ "alphanum_fraction": 0.70995671, "avg_line_length": 17.7692307692, "ext": "agda", "hexsha": "8a37277381716eccff6320572d35fd8c1f33d068", "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/Issue4365.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/Issue4365.agda", "max_line_length": 38, "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/Issue4365.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": 74, "size": 231 }
{- An simpler definition of truncation ∥ A ∥ n from n ≥ -1 Note that this uses the HoTT book's indexing, so it will be off from `∥_∥_` in HITs.Truncation.Base by -2 -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Truncation.FromNegOne.Base where open import Cubical.Data.NatMinusOne renaming (suc₋₁ to suc) open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.HITs.Sn data ∥_∥_ {ℓ} (A : Type ℓ) (n : ℕ₋₁) : Type ℓ where ∣_∣ : A → ∥ A ∥ n hub : (f : S (suc n) → ∥ A ∥ n) → ∥ A ∥ n spoke : (f : S (suc n) → ∥ A ∥ n) (x : S (suc n)) → hub f ≡ f x
{ "alphanum_fraction": 0.6402535658, "avg_line_length": 30.0476190476, "ext": "agda", "hexsha": "802529d5837b5a0a95b567aa732ce815ad177837", "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": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/HITs/Truncation/FromNegOne/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/HITs/Truncation/FromNegOne/Base.agda", "max_line_length": 65, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/HITs/Truncation/FromNegOne/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 251, "size": 631 }
module CantOpenConstructorsFromRecordModule where module Datatypes where record Foo : Set where constructor foo ok : Datatypes.Foo ok = Datatypes.foo open Datatypes.Foo bad : Datatypes.Foo bad = foo
{ "alphanum_fraction": 0.7799043062, "avg_line_length": 14.9285714286, "ext": "agda", "hexsha": "feb4f7921a30973da1305ddcfe80425de60ecb31", "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/CantOpenConstructorsFromRecordModule.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/CantOpenConstructorsFromRecordModule.agda", "max_line_length": 49, "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/CantOpenConstructorsFromRecordModule.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": 56, "size": 209 }
-- ASR (29 September 2014). Adapted from the example in issue 1269. -- Case: quote η-reduced and quoteTerm η-reduced. open import Common.Equality open import Common.Level open import Common.Prelude renaming (Nat to ℕ) open import Common.Product open import Common.Reflection data Even : ℕ → Set where isEven0 : Even 0 isEven+2 : ∀ {n} → Even n → Even (suc (suc n)) pattern expected = def (quote Σ) ( arg (argInfo hidden relevant) (def (quote Common.Level.lzero) []) ∷ arg (argInfo hidden relevant) (def (quote Common.Level.lzero) []) ∷ arg (argInfo visible relevant) (def (quote ℕ) []) ∷ arg (argInfo visible relevant) (def (quote Even) []) ∷ [] ) isExpected : Term → Bool isExpected expected = true isExpected _ = false `_ : Bool → Term ` true = con (quote true) [] ` false = con (quote false) [] macro checkExpectedType : QName → Tactic checkExpectedType i hole = bindTC (getType i) λ t → bindTC (normalise t) λ t → give (` isExpected t) hole input0 : ∃ Even input0 = 0 , isEven0 input1 : ∃ (λ n → Even n) input1 = 0 , isEven0 quote0 : Bool quote0 = checkExpectedType input0 quote1 : Bool quote1 = checkExpectedType input1 ok0 : quote0 ≡ true ok0 = refl ok1 : quote1 ≡ true ok1 = refl ------------------------------------------------------------------------------ -- For debugging purpose quotedTerm0 : Term quotedTerm0 = quoteTerm (∃ Even) quotedTerm1 : Term quotedTerm1 = quoteTerm (∃ (λ n → Even n)) b : quotedTerm0 ≡ expected b = refl c : quotedTerm1 ≡ expected c = refl
{ "alphanum_fraction": 0.6321177223, "avg_line_length": 22.652173913, "ext": "agda", "hexsha": "55d08ef82226c973a5b77067edfb84d4363ce4f4", "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/Issue1269.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/Issue1269.agda", "max_line_length": 78, "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/Issue1269.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 464, "size": 1563 }
-- Author: David Darais -- -- This is a dependent de Bruijn encoding of STLC with proofs for -- progress and preservation. This file has zero dependencies and is -- 100% self-contained. -- -- Because there is only a notion of well-typed terms (non-well-typed -- terms do not exist), preservation is merely by observation that -- substitution (i.e., cut) can be defined. -- -- A small-step evaluation semantics is defined after the definition of cut. -- -- Progress is proved w.r.t. the evaluation semantics. -- -- Some ideas for extensions or homeworks are given at the end. -- -- A few helper definitions are required. -- * Basic Agda constructions (like booleans, products, dependent sums, -- and lists) are defined first in a Prelude module which is -- immediately opened. -- * Binders (x : τ ∈ Γ) are proofs that the element τ is contained in -- the list of types Γ. Helper functions for weakening and -- introducing variables into contexts which are reusable are -- defined in the Prelude. Helpers for weakening terms are defined -- below. Some of the non-general helpers (like cut[∈]) could be -- defined in a generic way to be reusable, but I decided against -- this to keep things simple. module Darais where open import Agda.Primitive using (_⊔_) module Prelude where infixr 3 ∃𝑠𝑡 infixl 5 _∨_ infix 10 _∈_ infixl 15 _⧺_ infixl 15 _⊟_ infixl 15 _∾_ infixr 20 _∷_ data 𝔹 : Set where T : 𝔹 F : 𝔹 data _∨_ {ℓ₁ ℓ₂} (A : Set ℓ₁) (B : Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where Inl : A → A ∨ B Inr : B → A ∨ B syntax ∃𝑠𝑡 A (λ x → B) = ∃ x ⦂ A 𝑠𝑡 B data ∃𝑠𝑡 {ℓ₁ ℓ₂} (A : Set ℓ₁) (B : A → Set ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where ⟨∃_,_⟩ : ∀ (x : A) → B x → ∃ x ⦂ A 𝑠𝑡 B x data ⟬_⟭ {ℓ} (A : Set ℓ) : Set ℓ where [] : ⟬ A ⟭ _∷_ : A → ⟬ A ⟭ → ⟬ A ⟭ _⧺_ : ∀ {ℓ} {A : Set ℓ} → ⟬ A ⟭ → ⟬ A ⟭ → ⟬ A ⟭ [] ⧺ ys = ys x ∷ xs ⧺ ys = x ∷ (xs ⧺ ys) _∾_ : ∀ {ℓ} {A : Set ℓ} → ⟬ A ⟭ → ⟬ A ⟭ → ⟬ A ⟭ [] ∾ ys = ys (x ∷ xs) ∾ ys = xs ∾ x ∷ ys data _∈_ {ℓ} {A : Set ℓ} (x : A) : ∀ (xs : ⟬ A ⟭) → Set ℓ where Z : ∀ {xs} → x ∈ x ∷ xs S : ∀ {x′ xs} → x ∈ xs → x ∈ x′ ∷ xs _⊟_ : ∀ {ℓ} {A : Set ℓ} (xs : ⟬ A ⟭) {x} → x ∈ xs → ⟬ A ⟭ x ∷ xs ⊟ Z = xs x ∷ xs ⊟ S ε = x ∷ (xs ⊟ ε) wk[∈] : ∀ {ℓ} {A : Set ℓ} {xs : ⟬ A ⟭} {x : A} xs′ → x ∈ xs → x ∈ xs′ ∾ xs wk[∈] [] x = x wk[∈] (x′ ∷ xs) x = wk[∈] xs (S x) i[∈][_] : ∀ {ℓ} {A : Set ℓ} {xs : ⟬ A ⟭} {x x′ : A} (ε′ : x′ ∈ xs) → x ∈ xs ⊟ ε′ → x ∈ xs i[∈][ Z ] x = S x i[∈][ S ε′ ] Z = Z i[∈][ S ε′ ] (S x) = S (i[∈][ ε′ ] x) open Prelude -- ============================ -- -- Simply Typed Lambda Calculus -- -- ============================ -- -- A dependent de Bruijn encoding -- Or, the dynamic semantics of natural deduction as seen through Curry-Howard -- types -- data type : Set where ⟨𝔹⟩ : type _⟨→⟩_ : type → type → type -- terms -- infix 10 _⊢_ data _⊢_ : ∀ (Γ : ⟬ type ⟭) (τ : type) → Set where ⟨𝔹⟩ : ∀ {Γ} (b : 𝔹) → Γ ⊢ ⟨𝔹⟩ ⟨if⟩_❴_❵❴_❵ : ∀ {Γ τ} (e₁ : Γ ⊢ ⟨𝔹⟩) (e₂ : Γ ⊢ τ) (e₃ : Γ ⊢ τ) → Γ ⊢ τ Var : ∀ {Γ τ} (x : τ ∈ Γ) → Γ ⊢ τ ⟨λ⟩ : ∀ {Γ τ₁ τ₂} (e : τ₁ ∷ Γ ⊢ τ₂) → Γ ⊢ τ₁ ⟨→⟩ τ₂ _⟨⋅⟩_ : ∀ {Γ τ₁ τ₂} (e₁ : Γ ⊢ τ₁ ⟨→⟩ τ₂) (e₂ : Γ ⊢ τ₁) → Γ ⊢ τ₂ -- introducing a new variable to the context -- i[⊢][_] : ∀ {Γ τ τ′} (x′ : τ′ ∈ Γ) → Γ ⊟ x′ ⊢ τ → Γ ⊢ τ i[⊢][ x′ ] (⟨𝔹⟩ b) = ⟨𝔹⟩ b i[⊢][ x′ ] ⟨if⟩ e₁ ❴ e₂ ❵❴ e₃ ❵ = ⟨if⟩ i[⊢][ x′ ] e₁ ❴ i[⊢][ x′ ] e₂ ❵❴ i[⊢][ x′ ] e₃ ❵ i[⊢][ x′ ] (Var x) = Var (i[∈][ x′ ] x) i[⊢][ x′ ] (⟨λ⟩ e) = ⟨λ⟩ (i[⊢][ S x′ ] e) i[⊢][ x′ ] (e₁ ⟨⋅⟩ e₂) = i[⊢][ x′ ] e₁ ⟨⋅⟩ i[⊢][ x′ ] e₂ i[⊢] : ∀ {Γ τ τ′} → Γ ⊢ τ → τ′ ∷ Γ ⊢ τ i[⊢] = i[⊢][ Z ] -- substitution for variables -- cut[∈]<_>[_] : ∀ {Γ τ₁ τ₂} (x : τ₁ ∈ Γ) Γ′ → Γ′ ∾ (Γ ⊟ x) ⊢ τ₁ → τ₂ ∈ Γ → Γ′ ∾ (Γ ⊟ x) ⊢ τ₂ cut[∈]< Z >[ Γ′ ] e Z = e cut[∈]< Z >[ Γ′ ] e (S y) = Var (wk[∈] Γ′ y) cut[∈]< S x′ >[ Γ′ ] e Z = Var (wk[∈] Γ′ Z) cut[∈]< S x′ >[ Γ′ ] e (S x) = cut[∈]< x′ >[ _ ∷ Γ′ ] e x cut[∈]<_> : ∀ {Γ τ₁ τ₂} (x : τ₁ ∈ Γ) → Γ ⊟ x ⊢ τ₁ → τ₂ ∈ Γ → Γ ⊟ x ⊢ τ₂ cut[∈]< x′ > = cut[∈]< x′ >[ [] ] -- substitution for terms -- cut[⊢][_] : ∀ {Γ τ₁ τ₂} (x : τ₁ ∈ Γ) → Γ ⊟ x ⊢ τ₁ → Γ ⊢ τ₂ → Γ ⊟ x ⊢ τ₂ cut[⊢][ x′ ] e′ (⟨𝔹⟩ b) = ⟨𝔹⟩ b cut[⊢][ x′ ] e′ ⟨if⟩ e₁ ❴ e₂ ❵❴ e₃ ❵ = ⟨if⟩ cut[⊢][ x′ ] e′ e₁ ❴ cut[⊢][ x′ ] e′ e₂ ❵❴ cut[⊢][ x′ ] e′ e₃ ❵ cut[⊢][ x′ ] e′ (Var x) = cut[∈]< x′ > e′ x cut[⊢][ x′ ] e′ (⟨λ⟩ e) = ⟨λ⟩ (cut[⊢][ S x′ ] (i[⊢] e′) e) cut[⊢][ x′ ] e′ (e₁ ⟨⋅⟩ e₂) = cut[⊢][ x′ ] e′ e₁ ⟨⋅⟩ cut[⊢][ x′ ] e′ e₂ cut[⊢] : ∀ {Γ τ₁ τ₂} → Γ ⊢ τ₁ → τ₁ ∷ Γ ⊢ τ₂ → Γ ⊢ τ₂ cut[⊢] = cut[⊢][ Z ] -- values -- data value {Γ} : ∀ {τ} → Γ ⊢ τ → Set where ⟨𝔹⟩ : ∀ b → value (⟨𝔹⟩ b) ⟨λ⟩ : ∀ {τ τ′} (e : τ′ ∷ Γ ⊢ τ) → value (⟨λ⟩ e) -- CBV evaluation for terms -- -- (borrowing some notation and style from Wadler: https://wenkokke.github.io/sf/Stlc) infix 10 _↝_ data _↝_ {Γ τ} : Γ ⊢ τ → Γ ⊢ τ → Set where ξ⋅₁ : ∀ {τ′} {e₁ e₁′ : Γ ⊢ τ′ ⟨→⟩ τ} {e₂ : Γ ⊢ τ′} → e₁ ↝ e₁′ → e₁ ⟨⋅⟩ e₂ ↝ e₁′ ⟨⋅⟩ e₂ ξ⋅₂ : ∀ {τ′} {e₁ : Γ ⊢ τ′ ⟨→⟩ τ} {e₂ e₂′ : Γ ⊢ τ′} → value e₁ → e₂ ↝ e₂′ → e₁ ⟨⋅⟩ e₂ ↝ e₁ ⟨⋅⟩ e₂′ βλ : ∀ {τ′} {e₁ : τ′ ∷ Γ ⊢ τ} {e₂ : Γ ⊢ τ′} → value e₂ → ⟨λ⟩ e₁ ⟨⋅⟩ e₂ ↝ cut[⊢] e₂ e₁ ξif : ∀ {e₁ e₁′ : Γ ⊢ ⟨𝔹⟩} {e₂ e₃ : Γ ⊢ τ} → e₁ ↝ e₁′ → ⟨if⟩ e₁ ❴ e₂ ❵❴ e₃ ❵ ↝ ⟨if⟩ e₁′ ❴ e₂ ❵❴ e₃ ❵ ξif-T : ∀ {e₂ e₃ : Γ ⊢ τ} → ⟨if⟩ ⟨𝔹⟩ T ❴ e₂ ❵❴ e₃ ❵ ↝ e₂ ξif-F : ∀ {e₂ e₃ : Γ ⊢ τ} → ⟨if⟩ ⟨𝔹⟩ F ❴ e₂ ❵❴ e₃ ❵ ↝ e₃ -- progress -- progress : ∀ {τ} (e : [] ⊢ τ) → value e ∨ (∃ e′ ⦂ [] ⊢ τ 𝑠𝑡 e ↝ e′) progress (⟨𝔹⟩ b) = Inl (⟨𝔹⟩ b) progress ⟨if⟩ e ❴ e₁ ❵❴ e₂ ❵ with progress e … | Inl (⟨𝔹⟩ T) = Inr ⟨∃ e₁ , ξif-T ⟩ … | Inl (⟨𝔹⟩ F) = Inr ⟨∃ e₂ , ξif-F ⟩ … | Inr ⟨∃ e′ , ε ⟩ = Inr ⟨∃ ⟨if⟩ e′ ❴ e₁ ❵❴ e₂ ❵ , ξif ε ⟩ progress (Var ()) progress (⟨λ⟩ e) = Inl (⟨λ⟩ e) progress (e₁ ⟨⋅⟩ e₂) with progress e₁ … | Inr ⟨∃ e₁′ , ε ⟩ = Inr ⟨∃ e₁′ ⟨⋅⟩ e₂ , ξ⋅₁ ε ⟩ … | Inl (⟨λ⟩ e) with progress e₂ … | Inl x = Inr ⟨∃ cut[⊢] e₂ e , βλ x ⟩ … | Inr ⟨∃ e₂′ , ε ⟩ = Inr ⟨∃ e₁ ⟨⋅⟩ e₂′ , ξ⋅₂ (⟨λ⟩ e) ε ⟩ -- Some ideas for possible extensions or homework assignments -- 1. A. Write a conversion from the dependent de Bruijn encoding (e : Γ ⊢ τ) -- to the untyped lambda calculus (e : term). -- B. Prove that the image of this conversion is well typed. -- C. Write a conversion from well-typed untyped lambda calculus -- terms ([e : term] and [ε : (Γ ⊢ e ⦂ τ)] into the dependent de -- Bruijn encoding (e : Γ ⊢ τ) -- 2. A. Write a predicate analogous to 'value' for strongly reduced -- terms (reduction under lambda) -- B. Prove "strong" progress: A term is either fully beta-reduced -- (including under lambda) or it can take a step -- 3. Relate this semantics to a big-step semantics. -- 4. Prove strong normalization. -- 5. Relate this semantics to a definitional interpreter into Agda's Set.
{ "alphanum_fraction": 0.4738231412, "avg_line_length": 31.5694444444, "ext": "agda", "hexsha": "bca27ac72b7b2e78d9d05bf2860decd6161227de", "lang": "Agda", "max_forks_count": 304, "max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z", "max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z", "max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "manikdv/plfa.github.io", "max_forks_repo_path": "extra/extra/Darais.agda", "max_issues_count": 323, "max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z", "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "manikdv/plfa.github.io", "max_issues_repo_path": "extra/extra/Darais.agda", "max_line_length": 107, "max_stars_count": 1003, "max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "manikdv/plfa.github.io", "max_stars_repo_path": "extra/extra/Darais.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z", "max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z", "num_tokens": 3458, "size": 6819 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of Rational numbers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Rational.Properties where open import Function using (_∘_ ; _$_) open import Data.Integer as ℤ using (ℤ; ∣_∣; +_; -[1+_]) open import Data.Integer.Coprimality using (coprime-divisor) import Data.Integer.Properties as ℤ open import Data.Rational.Base open import Data.Nat as ℕ using (ℕ; zero; suc) import Data.Nat.Properties as ℕ open import Data.Nat.Coprimality as C using (Coprime; coprime?) open import Data.Nat.Divisibility hiding (/-cong) open import Data.Product using (_,_) open import Data.Sum open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Relation.Nullary using (Dec; yes; no; recompute) open import Relation.Nullary.Decidable as Dec′ using (True; fromWitness) open import Algebra.FunctionProperties {A = ℚ} _≡_ open import Algebra.FunctionProperties.Consequences.Propositional ------------------------------------------------------------------------ -- Helper lemmas private recomputeCP : ∀ {n d} → .(Coprime n (suc d)) → Coprime n (suc d) recomputeCP {n} {d-1} c = recompute (coprime? n (suc d-1)) c ------------------------------------------------------------------------ -- Equality ≡⇒≃ : _≡_ ⇒ _≃_ ≡⇒≃ refl = refl ≃⇒≡ : _≃_ ⇒ _≡_ ≃⇒≡ {i = mkℚ n₁ d₁ c₁} {j = mkℚ n₂ d₂ c₂} eq = helper where open ≡-Reasoning 1+d₁∣1+d₂ : suc d₁ ∣ suc d₂ 1+d₁∣1+d₂ = coprime-divisor (+ suc d₁) n₁ (+ suc d₂) (C.sym (recomputeCP c₁)) $ divides ∣ n₂ ∣ $ begin ∣ n₁ ℤ.* + suc d₂ ∣ ≡⟨ cong ∣_∣ eq ⟩ ∣ n₂ ℤ.* + suc d₁ ∣ ≡⟨ ℤ.abs-*-commute n₂ (+ suc d₁) ⟩ ∣ n₂ ∣ ℕ.* suc d₁ ∎ 1+d₂∣1+d₁ : suc d₂ ∣ suc d₁ 1+d₂∣1+d₁ = coprime-divisor (+ suc d₂) n₂ (+ suc d₁) (C.sym (recomputeCP c₂)) $ divides ∣ n₁ ∣ (begin ∣ n₂ ℤ.* + suc d₁ ∣ ≡⟨ cong ∣_∣ (sym eq) ⟩ ∣ n₁ ℤ.* + suc d₂ ∣ ≡⟨ ℤ.abs-*-commute n₁ (+ suc d₂) ⟩ ∣ n₁ ∣ ℕ.* suc d₂ ∎) helper : mkℚ n₁ d₁ c₁ ≡ mkℚ n₂ d₂ c₂ helper with ∣-antisym 1+d₁∣1+d₂ 1+d₂∣1+d₁ ... | refl with ℤ.*-cancelʳ-≡ n₁ n₂ (+ suc d₁) (λ ()) eq ... | refl = refl infix 4 _≟_ _≟_ : Decidable {A = ℚ} _≡_ p ≟ q with (↥ p ℤ.* ↧ q) ℤ.≟ (↥ q ℤ.* ↧ p) ... | yes pq≃qp = yes (≃⇒≡ pq≃qp) ... | no ¬pq≃qp = no (¬pq≃qp ∘ ≡⇒≃) ------------------------------------------------------------------------ -- _≤_ infix 4 _≤?_ drop-*≤* : ∀ {p q} → p ≤ q → (↥ p ℤ.* ↧ q) ℤ.≤ (↥ q ℤ.* ↧ p) drop-*≤* (*≤* pq≤qp) = pq≤qp ≤-reflexive : _≡_ ⇒ _≤_ ≤-reflexive refl = *≤* ℤ.≤-refl ≤-refl : Reflexive _≤_ ≤-refl = ≤-reflexive refl ≤-trans : Transitive _≤_ ≤-trans {i = p@(mkℚ n₁ d₁ c₁)} {j = q@(mkℚ n₂ d₂ c₂)} {k = r@(mkℚ n₃ d₃ c₃)} (*≤* eq₁) (*≤* eq₂) = *≤* $ ℤ.*-cancelʳ-≤-pos (n₁ ℤ.* ℤ.+ suc d₃) (n₃ ℤ.* ℤ.+ suc d₁) d₂ $ begin let sd₁ = ↧ p; sd₂ = ↧ q; sd₃ = ↧ r in (n₁ ℤ.* sd₃) ℤ.* sd₂ ≡⟨ ℤ.*-assoc n₁ sd₃ sd₂ ⟩ n₁ ℤ.* (sd₃ ℤ.* sd₂) ≡⟨ cong (n₁ ℤ.*_) (ℤ.*-comm sd₃ sd₂) ⟩ n₁ ℤ.* (sd₂ ℤ.* sd₃) ≡⟨ sym (ℤ.*-assoc n₁ sd₂ sd₃) ⟩ (n₁ ℤ.* sd₂) ℤ.* sd₃ ≤⟨ ℤ.*-monoʳ-≤-pos d₃ eq₁ ⟩ (n₂ ℤ.* sd₁) ℤ.* sd₃ ≡⟨ cong (ℤ._* sd₃) (ℤ.*-comm n₂ sd₁) ⟩ (sd₁ ℤ.* n₂) ℤ.* sd₃ ≡⟨ ℤ.*-assoc sd₁ n₂ sd₃ ⟩ sd₁ ℤ.* (n₂ ℤ.* sd₃) ≤⟨ ℤ.*-monoˡ-≤-pos d₁ eq₂ ⟩ sd₁ ℤ.* (n₃ ℤ.* sd₂) ≡⟨ sym (ℤ.*-assoc sd₁ n₃ sd₂) ⟩ (sd₁ ℤ.* n₃) ℤ.* sd₂ ≡⟨ cong (ℤ._* sd₂) (ℤ.*-comm sd₁ n₃) ⟩ (n₃ ℤ.* sd₁) ℤ.* sd₂ ∎ where open ℤ.≤-Reasoning ≤-antisym : Antisymmetric _≡_ _≤_ ≤-antisym (*≤* le₁) (*≤* le₂) = ≃⇒≡ (ℤ.≤-antisym le₁ le₂) ≤-total : Total _≤_ ≤-total p q = [ inj₁ ∘ *≤* , inj₂ ∘ *≤* ]′ (ℤ.≤-total (↥ p ℤ.* ↧ q) (↥ q ℤ.* ↧ p)) _≤?_ : Decidable _≤_ p ≤? q = Dec′.map′ *≤* drop-*≤* ((↥ p ℤ.* ↧ q) ℤ.≤? (↥ q ℤ.* ↧ p)) ≤-isPreorder : IsPreorder _≡_ _≤_ ≤-isPreorder = record { isEquivalence = isEquivalence ; reflexive = ≤-reflexive ; trans = ≤-trans } ≤-isPartialOrder : IsPartialOrder _≡_ _≤_ ≤-isPartialOrder = record { isPreorder = ≤-isPreorder ; antisym = ≤-antisym } ≤-isTotalOrder : IsTotalOrder _≡_ _≤_ ≤-isTotalOrder = record { isPartialOrder = ≤-isPartialOrder ; total = ≤-total } ≤-isDecTotalOrder : IsDecTotalOrder _≡_ _≤_ ≤-isDecTotalOrder = record { isTotalOrder = ≤-isTotalOrder ; _≟_ = _≟_ ; _≤?_ = _≤?_ } ≤-decTotalOrder : DecTotalOrder _ _ _ ≤-decTotalOrder = record { Carrier = ℚ ; _≈_ = _≡_ ; _≤_ = _≤_ ; isDecTotalOrder = ≤-isDecTotalOrder } ≤-irrelevant : Irrelevant _≤_ ≤-irrelevant (*≤* x₁) (*≤* x₂) = cong *≤* (ℤ.≤-irrelevant x₁ x₂) ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.0 ≤-irrelevance = ≤-irrelevant {-# WARNING_ON_USAGE ≤-irrelevance "Warning: ≤-irrelevance was deprecated in v1.0. Please use ≤-irrelevant instead." #-}
{ "alphanum_fraction": 0.5127500981, "avg_line_length": 30.5269461078, "ext": "agda", "hexsha": "748c801412f1e96d48b29294483d521fb0832a42", "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/Rational/Properties.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/Rational/Properties.agda", "max_line_length": 96, "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/Rational/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2236, "size": 5098 }
module Common.UntypedContext where open import Common.Context public -- Naturals, as a projection of contexts. ᴺ⌊_⌋ : ∀ {U} → Cx U → ℕ ᴺ⌊ ∅ ⌋ = zero ᴺ⌊ Γ , A ⌋ = suc ᴺ⌊ Γ ⌋ -- Inversion principle for naturals. invsuc : ∀ {n n′} → ℕ.suc n ≡ suc n′ → n ≡ n′ invsuc refl = refl -- Finite naturals, or nameless untyped de Bruijn indices, as a projection of context membership. ⁱ⌊_⌋ : ∀ {U} {A : U} {Γ} → A ∈ Γ → Fin ᴺ⌊ Γ ⌋ ⁱ⌊ top ⌋ = zero ⁱ⌊ pop i ⌋ = suc ⁱ⌊ i ⌋ -- Preorder on naturals, as a projection of context inclusion. infix 3 _≤_ data _≤_ : ℕ → ℕ → Set where done : zero ≤ zero skip : ∀ {n n′} → n ≤ n′ → n ≤ suc n′ keep : ∀ {n n′} → n ≤ n′ → suc n ≤ suc n′ ≤⌊_⌋ : ∀ {U} {Γ Γ′ : Cx U} → Γ ⊆ Γ′ → ᴺ⌊ Γ ⌋ ≤ ᴺ⌊ Γ′ ⌋ ≤⌊ done ⌋ = done ≤⌊ skip η ⌋ = skip ≤⌊ η ⌋ ≤⌊ keep η ⌋ = keep ≤⌊ η ⌋ refl≤ : ∀ {n} → n ≤ n refl≤ {zero} = done refl≤ {suc n} = keep refl≤ trans≤ : ∀ {n n′ n″} → n ≤ n′ → n′ ≤ n″ → n ≤ n″ trans≤ η done = η trans≤ η (skip η′) = skip (trans≤ η η′) trans≤ (skip η) (keep η′) = skip (trans≤ η η′) trans≤ (keep η) (keep η′) = keep (trans≤ η η′) unskip≤ : ∀ {n n′} → suc n ≤ n′ → n ≤ n′ unskip≤ (skip η) = skip (unskip≤ η) unskip≤ (keep η) = skip η unkeep≤ : ∀ {n n′} → suc n ≤ suc n′ → n ≤ n′ unkeep≤ (skip η) = unskip≤ η unkeep≤ (keep η) = η weak≤ : ∀ {n} → n ≤ suc n weak≤ = skip refl≤ bot≤ : ∀ {n} → zero ≤ n bot≤ {zero} = done bot≤ {suc n} = skip bot≤ -- Monotonicity of finite naturals with respect to preorder on naturals. monoFin : ∀ {n n′} → n ≤ n′ → Fin n → Fin n′ monoFin done () monoFin (skip η) i = suc (monoFin η i) monoFin (keep η) zero = zero monoFin (keep η) (suc i) = suc (monoFin η i) reflmonoFin : ∀ {n} → (i : Fin n) → i ≡ monoFin refl≤ i reflmonoFin zero = refl reflmonoFin (suc i) = cong suc (reflmonoFin i) transmonoFin : ∀ {n n′ n″} → (η : n ≤ n′) (η′ : n′ ≤ n″) (i : Fin n) → monoFin η′ (monoFin η i) ≡ monoFin (trans≤ η η′) i transmonoFin done η′ () transmonoFin η (skip η′) i = cong suc (transmonoFin η η′ i) transmonoFin (skip η) (keep η′) i = cong suc (transmonoFin η η′ i) transmonoFin (keep η) (keep η′) zero = refl transmonoFin (keep η) (keep η′) (suc i) = cong suc (transmonoFin η η′ i) -- Addition of naturals, as a projection of context concatenation. _+_ : ℕ → ℕ → ℕ n + zero = n n + (suc n′) = suc (n + n′) id+₁ : ∀ {n} → n + zero ≡ n id+₁ = refl id+₂ : ∀ {n} → zero + n ≡ n id+₂ {zero} = refl id+₂ {suc n} = cong suc id+₂ weak≤+₁ : ∀ {n} n′ → n ≤ n + n′ weak≤+₁ zero = refl≤ weak≤+₁ (suc n′) = skip (weak≤+₁ n′) weak≤+₂ : ∀ {n n′} → n′ ≤ n + n′ weak≤+₂ {n} {zero} = bot≤ weak≤+₂ {n} {suc n′} = keep weak≤+₂ -- Subtraction of naturals, as a projection of context thinning. _-_ : (n : ℕ) → Fin n → ℕ zero - () suc n - zero = n suc n - suc i = suc (n - i) thin≤ : ∀ {n} → (i : Fin n) → n - i ≤ n thin≤ zero = weak≤ thin≤ (suc i) = keep (thin≤ i) -- Decidable equality of finite naturals. data _=Fin_ {n} (i : Fin n) : Fin n → Set where same : i =Fin i diff : (j : Fin (n - i)) → i =Fin monoFin (thin≤ i) j _≟Fin_ : ∀ {n} → (i j : Fin n) → i =Fin j zero ≟Fin zero = same zero ≟Fin suc j rewrite reflmonoFin j = diff j suc i ≟Fin zero = diff zero suc i ≟Fin suc j with i ≟Fin j suc i ≟Fin suc .i | same = same suc i ≟Fin suc ._ | diff j = diff (suc j)
{ "alphanum_fraction": 0.5343239227, "avg_line_length": 25.3007518797, "ext": "agda", "hexsha": "139cb0004d1a393ebf2cf6222fe6510ad1418c37", "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": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "Common/UntypedContext.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "Common/UntypedContext.agda", "max_line_length": 97, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "Common/UntypedContext.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 1589, "size": 3365 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Foundations.HLevels' where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Nat open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Equiv open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Homotopy.Connected open import Cubical.Homotopy.Loopspace open import Cubical.Data.Nat open import Cubical.Data.Sigma open import Cubical.Data.Unit open import Cubical.Foundations.Structure private variable ℓ : Level isOfHLevel' : HLevel → Type ℓ → Type ℓ isOfHLevel' 0 A = isOfHLevel 0 A isOfHLevel' (suc n) A = (x y : A) → isOfHLevel' n (x ≡ y) isOfHLevel'→ : {n : HLevel} {A : Type ℓ} (l : isOfHLevel' n A) → isOfHLevel n A isOfHLevel'→ {n = 0} l = l isOfHLevel'→ {n = 1} l a b = l a b .fst isOfHLevel'→ {n = suc (suc _)} l a b = isOfHLevel'→ (l a b) isOfHLevel→' : {n : HLevel} {A : Type ℓ} (l : isOfHLevel n A) → isOfHLevel' n A isOfHLevel→' {n = 0} l = l isOfHLevel→' {n = 1} l = isProp→isContrPath l isOfHLevel→' {n = suc (suc _)} l = λ x y → isOfHLevel→' (l x y) isPropIsOfHLevel' : (n : HLevel) {A : Type ℓ} → isProp (isOfHLevel' n A) isPropIsOfHLevel' 0 = isPropIsOfHLevel 0 isPropIsOfHLevel' 1 p q = funExt (λ a → funExt (λ b → isPropIsContr (p a b) (q a b))) isPropIsOfHLevel' (suc (suc n)) f g i a b = isPropIsOfHLevel' (suc n) (f a b) (g a b) i -- isPropIsOfHLevel (suc (suc n)) isOfHLevel≡' : (n : HLevel) {A : Type ℓ} → isOfHLevel n A ≡ isOfHLevel' n A isOfHLevel≡' n = isoToPath (iso isOfHLevel→' isOfHLevel'→ (λ p' → isPropIsOfHLevel' n _ p') λ p → isPropIsOfHLevel n _ p) HL→ = isOfHLevel→' HL← = isOfHLevel'→ module _ {X : Type ℓ} where -- Lemma 7.2.8 in the HoTT book -- For n >= -1, if X being inhabited implies X is an n-type, then X is an n-type inh→ntype→ntype : {n : ℕ} (t : X → isOfHLevel (suc n) X) → isOfHLevel (suc n) X inh→ntype→ntype {n = 0} t = λ x y → t x x y inh→ntype→ntype {n = suc _} t = λ x y → t x x y module _ {X : Type ℓ} where -- Theorem 7.2.7 in the HoTT book -- For n >= -1, X is an (n+1)-type if all its loop spaces are n-types truncSelfId→truncId : {n : ℕ} → ((x : X) → isOfHLevel (suc n) (x ≡ x)) → isOfHLevel (suc (suc n)) X truncSelfId→truncId {n = 0} t = λ x x' → inh→ntype→ntype {n = 0} λ p → J (λ y q → isOfHLevel 1 (x ≡ y)) (t x) p truncSelfId→truncId {n = suc m} t = λ x x' → inh→ntype→ntype {n = suc m} λ p → J (λ y q → isOfHLevel (suc (suc m)) (x ≡ y)) (t x) p EquivPresHLevel : {Y : Type ℓ} → {n : ℕ} → (X≃Y : X ≃ Y) → (hX : isOfHLevel n X) → isOfHLevel n Y EquivPresHLevel {Y} {n} X≃Y hX = subst (λ x → isOfHLevel n x) (ua X≃Y) hX
{ "alphanum_fraction": 0.6001234187, "avg_line_length": 41.0253164557, "ext": "agda", "hexsha": "4e0d82542dc5df323814877d2b921104addbb8b5", "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": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Schippmunk/cubical", "max_forks_repo_path": "Cubical/Foundations/HLevels'.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "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": "Schippmunk/cubical", "max_issues_repo_path": "Cubical/Foundations/HLevels'.agda", "max_line_length": 121, "max_stars_count": null, "max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Schippmunk/cubical", "max_stars_repo_path": "Cubical/Foundations/HLevels'.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1237, "size": 3241 }
{-# OPTIONS --allow-unsolved-metas #-} module _ where open import Agda.Primitive postulate Applicative : ∀ {a b} (F : Set a → Set b) → Set (lsuc a ⊔ b) record Traversable {a} (T : Set a) : Set (lsuc a) where constructor mkTrav field traverse : ∀ {F} {{AppF : Applicative F}} → T → F T -- unsolved metas in type of F postulate V : ∀ {a} → Set a travV : ∀ {a} {F : Set a → Set a} {{AppF : Applicative F}} → V → F V module M (a : Level) where TravV : Traversable {a} V TravV = mkTrav travV postulate a : Level F : Set → Set instance AppF : Applicative F mapM : V → F V mapM = Traversable.traverse (M.TravV _) -- Here we try to cast (TypeChecking.Constraints.castConstraintToCurrentContext) -- a level constraint from M talking about the local (a : Level) to the top-level -- (empty) context. This ought not result in an __IMPOSSIBLE__.
{ "alphanum_fraction": 0.6513761468, "avg_line_length": 28.1290322581, "ext": "agda", "hexsha": "0e6476d713e1243440cc9f72bb425596232443c5", "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/Issue2223b.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/Issue2223b.agda", "max_line_length": 83, "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/Issue2223b.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": 291, "size": 872 }
record _×_ (A B : Set) : Set where constructor _,_ field fst : A snd : B open _×_ app : {A B : Set} → (A → B) × A → B app (f , x) = f x data D : Set where d : D postulate P : {A : Set} → A → Set p : (f : D → D) → P f → P (f d) foo : (F : Set → Set) → F D bar : (F : Set → Set) → P (foo F) q : P (app (foo (λ A → (A → A) × A))) q = let H : Set → Set H = _ in p (foo H) (bar H) -- An internal error has occurred. Please report this as a bug. -- Location of the error: src/full/Agda/TypeChecking/Conversion.hs:668
{ "alphanum_fraction": 0.5108695652, "avg_line_length": 19.0344827586, "ext": "agda", "hexsha": "a066938f2b88e0674076206be3feb530d7dbd6e4", "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/Issue1467.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/Issue1467.agda", "max_line_length": 70, "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/Issue1467.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": 220, "size": 552 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use Data.Vec.Recursive instead. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Product.N-ary where {-# WARNING_ON_IMPORT "Data.Product.N-ary was deprecated in v1.1. Use Data.Vec.Recursive instead." #-} open import Data.Vec.Recursive public
{ "alphanum_fraction": 0.4989106754, "avg_line_length": 27, "ext": "agda", "hexsha": "2647e8fcc7ec6ccc035784ab695245f8215179a3", "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/Product/N-ary.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/Product/N-ary.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/Product/N-ary.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": 83, "size": 459 }
-- Andreas, 2011-04-11 adapted from Data.Nat.Properties {-# OPTIONS --universe-polymorphism #-} module FrozenMVar2 where open import Imports.Level data _≡_ {a} {A : Set a} (x : A) : A → Set a where refl : x ≡ x {-# BUILTIN EQUALITY _≡_ #-} {-# BUILTIN REFL refl #-} cong : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {x y} → x ≡ y → f x ≡ f y cong f refl = refl Rel : ∀ {a} → Set a → (ℓ : Level) → Set (a ⊔ suc ℓ) Rel A ℓ = A → A → Set ℓ Op₂ : ∀ {ℓ} → Set ℓ → Set ℓ Op₂ A = A → A → A module FunctionProperties {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where Associative : Op₂ A → Set _ Associative _∙_ = ∀ x y z → ((x ∙ y) ∙ z) ≈ (x ∙ (y ∙ z)) open FunctionProperties _≡_ -- THIS produces frozen metas data ℕ : Set where zℕ : ℕ sℕ : (n : ℕ) → ℕ infixl 6 _+_ _+_ : ℕ → ℕ → ℕ zℕ + n = n sℕ m + n = sℕ (m + n) +-assoc : Associative _+_ -- +-assoc : ∀ x y z -> ((x + y) + z) ≡ (x + (y + z)) -- this works +-assoc zℕ _ _ = refl +-assoc (sℕ m) n o = cong sℕ (+-assoc m n o) -- Due to a frozen meta we get: -- Type mismatch when checking that the pattern zℕ has type _95
{ "alphanum_fraction": 0.5389492754, "avg_line_length": 22.5306122449, "ext": "agda", "hexsha": "c20397e4061279cc2728342dc9e3299fbf043d17", "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": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "np/agda-git-experiment", "max_forks_repo_path": "test/fail/FrozenMVar2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "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": "np/agda-git-experiment", "max_issues_repo_path": "test/fail/FrozenMVar2.agda", "max_line_length": 67, "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/FrozenMVar2.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": 459, "size": 1104 }
module Numeral.Natural.Inductions where import Lvl open import Logic open import Logic.Propositional open import Logic.Predicate open import Functional open import Numeral.Natural import Numeral.Natural.Induction open import Numeral.Natural.Oper open import Numeral.Natural.Oper.Proofs open import Numeral.Natural.Oper.Proofs.Order open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs open import Structure.Relator.Ordering open import Structure.Relator.Properties open import Syntax.Transitivity open import Syntax.Type open import Type module _ {ℓ} where open Numeral.Natural.Induction{ℓ} [ℕ]-unnecessary-induction : ∀{b : ℕ}{φ : ℕ → Stmt{ℓ}} → (∀(i : ℕ) → (i ≤ b) → φ(i)) → (∀(i : ℕ) → φ(i) → φ(𝐒(i))) → (∀{n} → φ(n)) [ℕ]-unnecessary-induction {𝟎} {φ} (base) (next) = [ℕ]-induction {φ} (base(𝟎) ([≤]-minimum)) (next) [ℕ]-unnecessary-induction {𝐒(b)}{φ} (base) (next) = [ℕ]-unnecessary-induction {b}{φ} (base-prev) (next) where base-prev : ∀(i : ℕ) → (i ≤ b) → φ(i) base-prev(𝟎) (proof) = base(𝟎) ([≤]-minimum) base-prev(𝐒(i)) (proof) = next(i) (base-prev(i) ([≤]-predecessor {i}{b} proof)) [ℕ]-multiple-base-cases-induction : ∀{b : ℕ}{φ : ℕ → Stmt{ℓ}} → (∀(i : ℕ) → (i ≤ b) → φ(i)) → (∀(i : ℕ) → (b ≤ i) → φ(i) → φ(𝐒(i))) → (∀{n} → φ(n)) [ℕ]-multiple-base-cases-induction {𝟎} {φ} base next = [ℕ]-induction {φ} (base(𝟎) ([≤]-minimum)) (i ↦ next(i) ([≤]-minimum)) [ℕ]-multiple-base-cases-induction {𝐒(b)}{φ} base next = [ℕ]-multiple-base-cases-induction {b}{φ} (base-prev) (next-prev) where base-prev : ∀(i : ℕ) → (i ≤ b) → φ(i) base-prev(i) (proof) = base(i) ([≤]-successor proof) next-prev : ∀(i : ℕ) → (b ≤ i) → φ(i) → φ(𝐒(i)) next-prev(i) (proof) (φi) with [≤]-to-[<][≡] proof ... | [∨]-introₗ a<b = next(i) (a<b) φi ... | [∨]-introᵣ [≡]-intro = base(𝐒(b)) (reflexivity(_≤_)) [ℕ]-strong-induction : ∀{φ : ℕ → Stmt{ℓ}} → φ(𝟎) → (∀{i : ℕ} → (∀{j : ℕ} → (j ≤ i) → φ(j)) → φ(𝐒(i))) → (∀{n} → φ(n)) [ℕ]-strong-induction {φ} (base) (next) {n} = ([ℕ]-inductionᵢ {Q} (Q0) (QS) {n}) {n} (reflexivity(_≤_)) where Q : ℕ → Stmt Q(k) = (∀{n} → (n ≤ k) → φ(n)) Q0 : Q(𝟎) Q0{𝟎} (_) = base Q0{𝐒(j)} (proof) = [⊥]-elim([≤][0]ᵣ-negation {j} (proof)) QS : ∀{k : ℕ} → Q(k) → Q(𝐒(k)) QS{k} (qk) {𝟎} (0≤Sk) = base QS{k} (qk) {𝐒(n)} (Sn≤Sk) = (next{n} (qn)) :of: φ(𝐒(n)) where n≤k : n ≤ k n≤k = [≤]-without-[𝐒] {n}{k} (Sn≤Sk) qn : Q(n) qn{a} (a≤n) = qk{a} ((a≤n) 🝖 (n≤k)) [ℕ]-multiple-base-cases-strong-induction : ∀{b : ℕ}{φ : ℕ → Stmt{ℓ}} → (∀{i : ℕ} → (i ≤ b) → φ(i)) → (∀{i : ℕ} → (b ≤ i) → (∀{j : ℕ} → (b ≤ j) → (j ≤ i) → φ(j)) → φ(𝐒(i))) → (∀{n} → φ(n)) [ℕ]-multiple-base-cases-strong-induction {𝟎} {φ} base next {n} = [ℕ]-strong-induction{φ} ((base [≤]-minimum)) (\{i} → φj ↦ next{i} [≤]-minimum (\{j} _ → φj{j})) [ℕ]-multiple-base-cases-strong-induction {𝐒(b)} {φ} base next {n} = [ℕ]-multiple-base-cases-strong-induction {b} {φ} base-prev next-prev {n} where base-prev : {i : ℕ} → i ≤ b → φ i base-prev{i} ib = base{i} ([≤]-successor ib) next-prev : {i : ℕ} → b ≤ i → ({j : ℕ} → b ≤ j → j ≤ i → φ j) → φ (𝐒 i) next-prev{i} bi φj with [≤]-to-[<][≡] bi ... | [∨]-introₗ b<i = next{i} (b<i) (\{j} → bj ↦ φj{j} ([≤]-predecessor bj)) ... | [∨]-introᵣ [≡]-intro = base{𝐒(i)} (reflexivity(_≤_)) [ℕ]-strong-induction-with-monus : ∀{φ : ℕ → Stmt{ℓ}} → φ(𝟎) → (∀{i : ℕ} → (∀{j : ℕ} → φ(i −₀ j)) → φ(𝐒(i))) → (∀{n} → φ(n)) [ℕ]-strong-induction-with-monus {φ} (base) (next) {n} = [ℕ]-strong-induction {φ} (base) (next2) {n} where convert-assumption : ∀{i} → (∀{j} → (j ≤ i) → φ(j)) → (∀{j} → φ(i −₀ j)) convert-assumption {i} assumption {j} = assumption{i −₀ j} ([−₀]-lesser {i}{j}) next2 : ∀{i} → (∀{j} → (j ≤ i) → φ(j)) → φ(𝐒(i)) next2{i} assumption = next{i} (\{j} → convert-assumption{i} assumption {j}) -- TODO: This is just a generalisation of [ℕ]-strong-induction-with-monus. If a function (T → 𝕟(i)) is surjective for every i∊ℕ, then f could be used in the induction step -- [ℕ]-induction-with-surjection : ∀{φ : ℕ → Stmt}{ℓT}{T : Type{ℓT}}{f : ℕ → T → ℕ}{f⁻¹ : (i : ℕ) → (n : ℕ) → ⦃ _ : n ≤ i ⦄ → T} -- → (∀{i n} → (proof : (n ≤ i)) → (f(i)(f⁻¹(i)(n) ⦃ proof ⦄) ≡ n)) -- → φ(𝟎) -- → (∀{i : ℕ} -- → (∀{t : T} → (φ ∘ f(i))(t)) -- → φ(𝐒(i)) -- ) -- → (∀{n} → φ(n)) -- [ℕ]-induction-with-surjection {φ}{ℓT}{T}{f}{f⁻¹} surj base next {n} = [ℕ]-strong-induction {φ} (base) (next2) {n} where -- postulate convert-assumption : ∀{i} → (∀{j} → (j ≤ i) → φ(j)) → (∀{t} → φ(f(i)(t))) -- -- convert-assumption {i} assumption {j} = assumption{i −₀ j} ([−₀]-lesser {i}{j}) -- -- next2 : ∀{i} → (∀{j} → (j ≤ i) → φ(j)) → φ(𝐒(i)) -- next2{i} assumption = next{i} (\{j} → convert-assumption{i} assumption {j}) module _ where open Strict.Properties instance [ℕ]-accessibleₗ : ∀{n} → Accessibleₗ(_<_)(n) [ℕ]-accessibleₗ{n} = intro ⦃ proof{n} ⦄ where proof : ∀{n m} → ⦃ _ : (m < n) ⦄ → Accessibleₗ(_<_)(m) proof {𝟎} {m} ⦃ ⦄ proof{𝐒(n)} {𝟎} ⦃ succ mn ⦄ = intro ⦃ \ ⦃ ⦄ ⦄ proof{𝐒(n)} {𝐒(m)} ⦃ succ mn ⦄ = intro ⦃ \{k} ⦃ xsm ⦄ → Accessibleₗ.proof ([ℕ]-accessibleₗ {n}) ⦃ transitivity(_≤_) xsm mn ⦄ ⦄ [ℕ]-wellfounded : WellFounded(_<_) [ℕ]-wellfounded = [ℕ]-accessibleₗ
{ "alphanum_fraction": 0.4931960921, "avg_line_length": 52.1090909091, "ext": "agda", "hexsha": "d5bb528825437eea509c9e88f71aaf028e71a03b", "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/Natural/Inductions.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/Natural/Inductions.agda", "max_line_length": 189, "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/Natural/Inductions.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": 2465, "size": 5732 }
open import Prelude module Implicits.Resolution.Deterministic.Resolution where open import Data.Fin.Substitution open import Data.List open import Data.List.All open import Implicits.Syntax open import Implicits.Syntax.Type.Unification open import Implicits.Substitutions open import Extensions.ListFirst infixl 4 _⊢ᵣ_ _⊢_↓_ _⟨_⟩=_ infixl 6 _◁_ data _◁_ {ν} : Type ν → SimpleType ν → Set where m-simp : ∀ {a} → simpl a ◁ a m-tabs : ∀ {a r} b → r tp[/tp b ] ◁ a → ∀' r ◁ a m-iabs : ∀ {a b r} → r ◁ a → b ⇒ r ◁ a _⟨_⟩=_ : ∀ {ν} (Δ : ICtx ν) → SimpleType ν → Type ν → Set Δ ⟨ τ ⟩= r = first r ∈ Δ ⇔ (flip _◁_ τ) mutual data _⊢_↓_ {ν} (K : ICtx ν) : Type ν → SimpleType ν → Set where i-simp : ∀ a → K ⊢ simpl a ↓ a i-iabs : ∀ {ρ₁ ρ₂ a} → K ⊢ᵣ ρ₁ → K ⊢ ρ₂ ↓ a → K ⊢ ρ₁ ⇒ ρ₂ ↓ a i-tabs : ∀ {ρ a} b → K ⊢ ρ tp[/tp b ] ↓ a → K ⊢ ∀' ρ ↓ a data _⊢ᵣ_ {ν} (K : ICtx ν) : Type ν → Set where r-simp : ∀ {τ ρ} → K ⟨ τ ⟩= ρ → K ⊢ ρ ↓ τ → K ⊢ᵣ simpl τ r-iabs : ∀ ρ₁ {ρ₂} → ρ₁ ∷ K ⊢ᵣ ρ₂ → K ⊢ᵣ ρ₁ ⇒ ρ₂ r-tabs : ∀ {ρ} → ictx-weaken K ⊢ᵣ ρ → K ⊢ᵣ ∀' ρ _⊢ᵣ[_] : ∀ {ν} → (K : ICtx ν) → List (Type ν) → Set _⊢ᵣ[_] K ρs = All (λ r → K ⊢ᵣ r) ρs r↓a⟶r◁a : ∀ {ν} {K : ICtx ν} {r a} → K ⊢ r ↓ a → r ◁ a r↓a⟶r◁a (i-simp a) = m-simp r↓a⟶r◁a (i-iabs _ x) = m-iabs (r↓a⟶r◁a x) r↓a⟶r◁a (i-tabs b x) = m-tabs b (r↓a⟶r◁a x)
{ "alphanum_fraction": 0.5343796712, "avg_line_length": 31.1162790698, "ext": "agda", "hexsha": "663fd6fb5734f7958f69e1b1c3aa23ff51d86db3", "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/Deterministic/Resolution.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/Deterministic/Resolution.agda", "max_line_length": 65, "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/Deterministic/Resolution.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": 699, "size": 1338 }
module WrongNumberOfConstructorArguments where data Nat : Set where zero : Nat suc : Nat -> Nat f : Nat -> Nat f (zero n) = n f suc = zero
{ "alphanum_fraction": 0.6339869281, "avg_line_length": 12.75, "ext": "agda", "hexsha": "9c16b2e1306fafb9375a3c3130b20eb3268c5601", "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/WrongNumberOfConstructorArguments.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/WrongNumberOfConstructorArguments.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/Fail/WrongNumberOfConstructorArguments.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": 153 }
{-# OPTIONS --subtyping #-} open import Agda.Builtin.Equality record _↠_ (A B : Set) : Set where field to : A → B from : B → A to∘from : ∀ x → to (from x) ≡ x record Erased (@0 A : Set) : Set where constructor [_] field @0 erased : A open Erased -- fails : {A : Set} → A ↠ Erased A -- fails = record -- { to = [_] -- ; from = erased -- ; to∘from = λ _ → refl -- } works : {A : Set} → A ↠ Erased A works = record { to = [_] ; from = _ ; to∘from = λ _ → refl }
{ "alphanum_fraction": 0.4876660342, "avg_line_length": 17, "ext": "agda", "hexsha": "8a5ffb6cf72540fd9f8dd6b5388db58aac6bb564", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue3855d.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_issues_event_min_datetime": "2015-09-15T15:49:15.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue3855d.agda", "max_line_length": 38, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue3855d.agda", "max_stars_repo_stars_event_max_datetime": "2016-05-20T13:58:52.000Z", "max_stars_repo_stars_event_min_datetime": "2016-05-20T13:58:52.000Z", "num_tokens": 197, "size": 527 }
{-# OPTIONS --universe-polymorphism #-} module Categories.Categories where open import Level open import Categories.Category open import Categories.Functor Categories : ∀ o ℓ e → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e) Categories o ℓ e = record { Obj = Category o ℓ e ; _⇒_ = Functor ; _≡_ = _≡_ ; _∘_ = _∘_ ; id = id ; assoc = λ {_} {_} {_} {_} {F} {G} {H} → assoc {F = F} {G} {H} ; identityˡ = λ {_} {_} {F} → identityˡ {F = F} ; identityʳ = λ {_} {_} {F} → identityʳ {F = F} ; equiv = λ {X} {Y} → equiv {C = X} {D = Y} ; ∘-resp-≡ = λ {_} {_} {_} {f} {h} {g} {i} → ∘-resp-≡ {F = f} {h} {g} {i} } {- module Agda where open import Category.Agda open import Category.Discrete D : ∀ o → Functor (Agda o) (Categories o o zero) D o = record { F₀ = Discrete ; F₁ = λ f → record { F₀ = λ x → f x ; F₁ = ≣-cong f ; identity = tt ; homomorphism = tt ; F-resp-≡ = λ _ → tt } ; identity = λ _ → refl tt ; homomorphism = λ _ → refl tt ; F-resp-≡ = F-resp-≡′ } where F-resp-≡′ : {A B : Set o} {F G : A → B} → (∀ x → F x ≣ G x) → ∀ {X Y : A} (f : X ≣ Y) → [ Discrete B ] ≣-cong F f ∼ ≣-cong G f F-resp-≡′ {A} {B} {F} {G} f {x} ≣-refl = helper {F = F} {G} (f x) where helper : {F G : A → B} → {p q : B} → p ≣ q → [ Discrete B ] ≣-refl {x = p} ∼ ≣-refl {x = q} helper ≣-refl = refl tt Ob : ∀ o → Functor (Categories o o zero) (Agda o) Ob o = record { F₀ = Category.Obj ; F₁ = Functor.F₀ ; identity = λ _ → ≣-refl ; homomorphism = λ _ → ≣-refl ; F-resp-≡ = λ {_} {_} {F} {G} → F-resp-≡′ {F = F} {G} } where F-resp-≡′ : {A B : Category o o zero} {F G : Functor A B} → ({X Y : Category.Obj A} (f : Category.Hom A X Y) → [ B ] Functor.F₁ F f ∼ Functor.F₁ G f) → ((x : Category.Obj A) → Functor.F₀ F x ≣ Functor.F₀ G x) F-resp-≡′ {A} {B} {F} {G} F∼G x = helper (F∼G (Category.id A {x})) where helper : ∀ {X Y} {p : Category.Hom B X X} {q : Category.Hom B Y Y} → [ B ] p ∼ q → X ≣ Y helper (refl q) = ≣-refl open import Category.Adjunction D⊣Ob : ∀ o → Adjunction (D o) (Ob o) D⊣Ob o = record { unit = record { η = λ _ x → x ; commute = λ _ _ → ≣-refl } ; counit = record { η = λ X → record { F₀ = λ x → x ; F₁ = counit-id′ {X} ; identity = IsEquivalence.refl (Category.equiv X) ; homomorphism = {!!} ; F-resp-≡ = {!!} } ; commute = {!!} } ; zig = {!!} ; zag = λ _ → ≣-refl } where counit-id′ : {X : Category o o zero} → {A B : Category.Obj X} → A ≣ B → Category.Hom X A B counit-id′ {X} ≣-refl = Category.id X -}
{ "alphanum_fraction": 0.4672489083, "avg_line_length": 30.5333333333, "ext": "agda", "hexsha": "19a91cb4927c49ec13974e9811c9a1fec42c3987", "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/Categories.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/Categories.agda", "max_line_length": 130, "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/Categories.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": 1156, "size": 2748 }
------------------------------------------------------------------------ -- A sequential colimit for which everything except for the "base -- case" is erased ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} -- The definition of sequential colimits and the statement of the -- non-dependent universal property are based on those in van Doorn's -- "Constructing the Propositional Truncation using Non-recursive -- HITs". -- The module is parametrised by a notion of equality. The higher -- constructor of the HIT defining sequential colimits uses path -- equality, but the supplied notion of equality is used for many -- other things. import Equality.Path as P module Colimit.Sequential.Very-erased {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq hiding (elim) open import Prelude hiding ([_,_]) open import Bijection equality-with-J using (_↔_) open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) open import Erased.Cubical eq private variable a b p₀ p₊ q : Level A B P₀ : Type a P₊ : A → Type p₊ n : ℕ e step₀ x : A ------------------------------------------------------------------------ -- The type -- A sequential colimit for which everything except for the "base -- case" is erased. data Colimitᴱ (P₀ : Type p₀) (@0 P₊ : ℕ → Type p₊) (@0 step₀ : P₀ → P₊ zero) (@0 step₊ : ∀ {n} → P₊ n → P₊ (suc n)) : Type (p₀ ⊔ p₊) where ∣_∣₀ : P₀ → Colimitᴱ P₀ P₊ step₀ step₊ @0 ∣_∣₊ : P₊ n → Colimitᴱ P₀ P₊ step₀ step₊ @0 ∣∣₊≡∣∣₀ᴾ : (x : P₀) → ∣ step₀ x ∣₊ P.≡ ∣ x ∣₀ @0 ∣∣₊≡∣∣₊ᴾ : (x : P₊ n) → ∣ step₊ x ∣₊ P.≡ ∣ x ∣₊ -- A variant of ∣∣₊≡∣∣₀ᴾ. @0 ∣∣₊≡∣∣₀ : {step₊ : ∀ {n} → P₊ n → P₊ (suc n)} (x : P₀) → _≡_ {A = Colimitᴱ P₀ P₊ step₀ step₊} ∣ step₀ x ∣₊ ∣ x ∣₀ ∣∣₊≡∣∣₀ x = _↔_.from ≡↔≡ (∣∣₊≡∣∣₀ᴾ x) -- A variant of ∣∣₊≡∣∣₊ᴾ. @0 ∣∣₊≡∣∣₊ : {step₊ : ∀ {n} → P₊ n → P₊ (suc n)} (x : P₊ n) → _≡_ {A = Colimitᴱ P₀ P₊ step₀ step₊} ∣ step₊ x ∣₊ ∣ x ∣₊ ∣∣₊≡∣∣₊ x = _↔_.from ≡↔≡ (∣∣₊≡∣∣₊ᴾ x) ------------------------------------------------------------------------ -- Eliminators -- A dependent eliminator, expressed using paths. record Elimᴾ {P₀ : Type p₀} {@0 P₊ : ℕ → Type p₊} {@0 step₀ : P₀ → P₊ zero} {@0 step₊ : ∀ {n} → P₊ n → P₊ (suc n)} (Q : Colimitᴱ P₀ P₊ step₀ step₊ → Type q) : Type (p₀ ⊔ p₊ ⊔ q) where no-eta-equality field ∣∣₀ʳ : (x : P₀) → Q ∣ x ∣₀ @0 ∣∣₊ʳ : (x : P₊ n) → Q ∣ x ∣₊ @0 ∣∣₊≡∣∣₀ʳ : (x : P₀) → P.[ (λ i → Q (∣∣₊≡∣∣₀ᴾ x i)) ] ∣∣₊ʳ (step₀ x) ≡ ∣∣₀ʳ x @0 ∣∣₊≡∣∣₊ʳ : (x : P₊ n) → P.[ (λ i → Q (∣∣₊≡∣∣₊ᴾ x i)) ] ∣∣₊ʳ (step₊ x) ≡ ∣∣₊ʳ x open Elimᴾ public elimᴾ : {@0 P₊ : ℕ → Type p₊} {@0 step₀ : P₀ → P₊ zero} {@0 step₊ : ∀ {n} → P₊ n → P₊ (suc n)} {Q : Colimitᴱ P₀ P₊ step₀ step₊ → Type q} → Elimᴾ Q → (x : Colimitᴱ P₀ P₊ step₀ step₊) → Q x elimᴾ {P₀ = P₀} {P₊ = P₊} {step₀ = step₀} {step₊ = step₊} {Q = Q} e = helper where module E = Elimᴾ e helper : (x : Colimitᴱ P₀ P₊ step₀ step₊) → Q x helper ∣ x ∣₀ = E.∣∣₀ʳ x helper ∣ x ∣₊ = E.∣∣₊ʳ x helper (∣∣₊≡∣∣₀ᴾ x i) = E.∣∣₊≡∣∣₀ʳ x i helper (∣∣₊≡∣∣₊ᴾ x i) = E.∣∣₊≡∣∣₊ʳ x i -- A non-dependent eliminator, expressed using paths. record Recᴾ (P₀ : Type p₀) (@0 P₊ : ℕ → Type p₊) (@0 step₀ : P₀ → P₊ zero) (@0 step₊ : ∀ {n} → P₊ n → P₊ (suc n)) (B : Type b) : Type (p₀ ⊔ p₊ ⊔ b) where no-eta-equality field ∣∣₀ʳ : P₀ → B @0 ∣∣₊ʳ : P₊ n → B @0 ∣∣₊≡∣∣₀ʳ : (x : P₀) → ∣∣₊ʳ (step₀ x) P.≡ ∣∣₀ʳ x @0 ∣∣₊≡∣∣₊ʳ : (x : P₊ n) → ∣∣₊ʳ (step₊ x) P.≡ ∣∣₊ʳ x open Recᴾ public recᴾ : {@0 P₊ : ℕ → Type p₊} {@0 step₀ : P₀ → P₊ zero} {@0 step₊ : ∀ {n} → P₊ n → P₊ (suc n)} → Recᴾ P₀ P₊ step₀ step₊ B → Colimitᴱ P₀ P₊ step₀ step₊ → B recᴾ r = elimᴾ λ where .∣∣₀ʳ → R.∣∣₀ʳ .∣∣₊ʳ → R.∣∣₊ʳ .∣∣₊≡∣∣₀ʳ → R.∣∣₊≡∣∣₀ʳ .∣∣₊≡∣∣₊ʳ → R.∣∣₊≡∣∣₊ʳ where module R = Recᴾ r -- A dependent eliminator. record Elim {P₀ : Type p₀} {@0 P₊ : ℕ → Type p₊} {@0 step₀ : P₀ → P₊ zero} {@0 step₊ : ∀ {n} → P₊ n → P₊ (suc n)} (Q : Colimitᴱ P₀ P₊ step₀ step₊ → Type q) : Type (p₀ ⊔ p₊ ⊔ q) where no-eta-equality field ∣∣₀ʳ : (x : P₀) → Q ∣ x ∣₀ @0 ∣∣₊ʳ : (x : P₊ n) → Q ∣ x ∣₊ @0 ∣∣₊≡∣∣₀ʳ : (x : P₀) → subst Q (∣∣₊≡∣∣₀ x) (∣∣₊ʳ (step₀ x)) ≡ ∣∣₀ʳ x @0 ∣∣₊≡∣∣₊ʳ : (x : P₊ n) → subst Q (∣∣₊≡∣∣₊ x) (∣∣₊ʳ (step₊ x)) ≡ ∣∣₊ʳ x open Elim public elim : {@0 P₊ : ℕ → Type p₊} {@0 step₀ : P₀ → P₊ zero} {@0 step₊ : ∀ {n} → P₊ n → P₊ (suc n)} {Q : Colimitᴱ P₀ P₊ step₀ step₊ → Type q} → Elim Q → (x : Colimitᴱ P₀ P₊ step₀ step₊) → Q x elim e = elimᴾ λ where .∣∣₀ʳ → E.∣∣₀ʳ .∣∣₊ʳ → E.∣∣₊ʳ .∣∣₊≡∣∣₀ʳ x → subst≡→[]≡ (E.∣∣₊≡∣∣₀ʳ x) .∣∣₊≡∣∣₊ʳ x → subst≡→[]≡ (E.∣∣₊≡∣∣₊ʳ x) where module E = Elim e -- Two "computation" rules. @0 elim-∣∣₊≡∣∣₀ : dcong (elim e) (∣∣₊≡∣∣₀ x) ≡ Elim.∣∣₊≡∣∣₀ʳ e x elim-∣∣₊≡∣∣₀ = dcong-subst≡→[]≡ (refl _) @0 elim-∣∣₊≡∣∣₊ : dcong (elim e) (∣∣₊≡∣∣₊ x) ≡ Elim.∣∣₊≡∣∣₊ʳ e x elim-∣∣₊≡∣∣₊ = dcong-subst≡→[]≡ (refl _) -- A non-dependent eliminator. record Rec (P₀ : Type p₀) (@0 P₊ : ℕ → Type p₊) (@0 step₀ : P₀ → P₊ zero) (@0 step₊ : ∀ {n} → P₊ n → P₊ (suc n)) (B : Type b) : Type (p₀ ⊔ p₊ ⊔ b) where no-eta-equality field ∣∣₀ʳ : P₀ → B @0 ∣∣₊ʳ : P₊ n → B @0 ∣∣₊≡∣∣₀ʳ : (x : P₀) → ∣∣₊ʳ (step₀ x) ≡ ∣∣₀ʳ x @0 ∣∣₊≡∣∣₊ʳ : (x : P₊ n) → ∣∣₊ʳ (step₊ x) ≡ ∣∣₊ʳ x open Rec public rec : {@0 P₊ : ℕ → Type p₊} {@0 step₀ : P₀ → P₊ zero} {@0 step₊ : ∀ {n} → P₊ n → P₊ (suc n)} → Rec P₀ P₊ step₀ step₊ B → Colimitᴱ P₀ P₊ step₀ step₊ → B rec r = recᴾ λ where .∣∣₀ʳ → R.∣∣₀ʳ .∣∣₊ʳ → R.∣∣₊ʳ .∣∣₊≡∣∣₀ʳ x → _↔_.to ≡↔≡ (R.∣∣₊≡∣∣₀ʳ x) .∣∣₊≡∣∣₊ʳ x → _↔_.to ≡↔≡ (R.∣∣₊≡∣∣₊ʳ x) where module R = Rec r -- Two "computation" rules. @0 rec-∣∣₊≡∣∣₀ : {step₊ : ∀ {n} → P₊ n → P₊ (suc n)} {r : Rec P₀ P₊ step₀ step₊ B} {x : P₀} → cong (rec r) (∣∣₊≡∣∣₀ x) ≡ Rec.∣∣₊≡∣∣₀ʳ r x rec-∣∣₊≡∣∣₀ = cong-≡↔≡ (refl _) @0 rec-∣∣₊≡∣∣₊ : {step₊ : ∀ {n} → P₊ n → P₊ (suc n)} {r : Rec P₀ P₊ step₀ step₊ B} {x : P₊ n} → cong (rec r) (∣∣₊≡∣∣₊ x) ≡ Rec.∣∣₊≡∣∣₊ʳ r x rec-∣∣₊≡∣∣₊ = cong-≡↔≡ (refl _) ------------------------------------------------------------------------ -- The universal property -- The universal property of the sequential colimit. universal-property : {@0 P₊ : ℕ → Type p₊} {@0 step₀ : P₀ → P₊ zero} {@0 step₊ : ∀ {n} → P₊ n → P₊ (suc n)} → (Colimitᴱ P₀ P₊ step₀ step₊ → B) ≃ (∃ λ (f₀ : P₀ → B) → Erased (∃ λ (f₊ : ∀ n → P₊ n → B) → (∀ x → f₊ zero (step₀ x) ≡ f₀ x) × (∀ n x → f₊ (suc n) (step₊ x) ≡ f₊ n x))) universal-property {P₀ = P₀} {B = B} {P₊ = P₊} {step₀ = step₀} {step₊ = step₊} = Eq.↔→≃ to from to∘from from∘to where to : (Colimitᴱ P₀ P₊ step₀ step₊ → B) → ∃ λ (f₀ : P₀ → B) → Erased (∃ λ (f₊ : ∀ n → P₊ n → B) → (∀ x → f₊ zero (step₀ x) ≡ f₀ x) × (∀ n x → f₊ (suc n) (step₊ x) ≡ f₊ n x)) to h = h ∘ ∣_∣₀ , [ (λ _ → h ∘ ∣_∣₊) , (λ x → h ∣ step₀ x ∣₊ ≡⟨ cong h (∣∣₊≡∣∣₀ x) ⟩∎ h ∣ x ∣₀ ∎) , (λ _ x → h ∣ step₊ x ∣₊ ≡⟨ cong h (∣∣₊≡∣∣₊ x) ⟩∎ h ∣ x ∣₊ ∎) ] from : (∃ λ (f₀ : P₀ → B) → Erased (∃ λ (f₊ : ∀ n → P₊ n → B) → (∀ x → f₊ zero (step₀ x) ≡ f₀ x) × (∀ n x → f₊ (suc n) (step₊ x) ≡ f₊ n x))) → Colimitᴱ P₀ P₊ step₀ step₊ → B from (f₀ , [ f₊ , g₀ , g₊ ]) = rec λ where .∣∣₀ʳ → f₀ .∣∣₊ʳ → f₊ _ .∣∣₊≡∣∣₀ʳ → g₀ .∣∣₊≡∣∣₊ʳ → g₊ _ to∘from : ∀ p → to (from p) ≡ p to∘from (f₀ , [ f₊ , g₀ , g₊ ]) = cong (f₀ ,_) $ []-cong [ cong (f₊ ,_) $ cong₂ _,_ (⟨ext⟩ λ x → cong (rec _) (∣∣₊≡∣∣₀ x) ≡⟨ rec-∣∣₊≡∣∣₀ ⟩∎ g₀ x ∎) (⟨ext⟩ λ n → ⟨ext⟩ λ x → cong (rec _) (∣∣₊≡∣∣₊ x) ≡⟨ rec-∣∣₊≡∣∣₊ ⟩∎ g₊ n x ∎) ] from∘to : ∀ h → from (to h) ≡ h from∘to h = ⟨ext⟩ $ elim λ where .∣∣₀ʳ _ → refl _ .∣∣₊ʳ _ → refl _ .∣∣₊≡∣∣₀ʳ x → subst (λ z → from (to h) z ≡ h z) (∣∣₊≡∣∣₀ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (from (to h)) (∣∣₊≡∣∣₀ x))) (trans (refl _) (cong h (∣∣₊≡∣∣₀ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) rec-∣∣₊≡∣∣₀ (trans-reflˡ _) ⟩ trans (sym (cong h (∣∣₊≡∣∣₀ x))) (cong h (∣∣₊≡∣∣₀ x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎ .∣∣₊≡∣∣₊ʳ x → subst (λ z → from (to h) z ≡ h z) (∣∣₊≡∣∣₊ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (from (to h)) (∣∣₊≡∣∣₊ x))) (trans (refl _) (cong h (∣∣₊≡∣∣₊ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) rec-∣∣₊≡∣∣₊ (trans-reflˡ _) ⟩ trans (sym (cong h (∣∣₊≡∣∣₊ x))) (cong h (∣∣₊≡∣∣₊ x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎ -- A dependently typed variant of the sequential colimit's universal -- property. universal-property-Π : {@0 P₊ : ℕ → Type p₊} {@0 step₀ : P₀ → P₊ zero} {@0 step₊ : ∀ {n} → P₊ n → P₊ (suc n)} {Q : Colimitᴱ P₀ P₊ step₀ step₊ → Type q} → ((x : Colimitᴱ P₀ P₊ step₀ step₊) → Q x) ≃ (∃ λ (f₀ : (x : P₀) → Q ∣ x ∣₀) → Erased (∃ λ (f₊ : ∀ n (x : P₊ n) → Q ∣ x ∣₊) → (∀ x → subst Q (∣∣₊≡∣∣₀ x) (f₊ zero (step₀ x)) ≡ f₀ x) × (∀ n x → subst Q (∣∣₊≡∣∣₊ x) (f₊ (suc n) (step₊ x)) ≡ f₊ n x))) universal-property-Π {P₀ = P₀} {P₊ = P₊} {step₀ = step₀} {step₊ = step₊} {Q = Q} = Eq.↔→≃ to from to∘from from∘to where RHS = ∃ λ (f₀ : (x : P₀) → Q ∣ x ∣₀) → Erased (∃ λ (f₊ : ∀ n (x : P₊ n) → Q ∣ x ∣₊) → (∀ x → subst Q (∣∣₊≡∣∣₀ x) (f₊ zero (step₀ x)) ≡ f₀ x) × (∀ n x → subst Q (∣∣₊≡∣∣₊ x) (f₊ (suc n) (step₊ x)) ≡ f₊ n x)) to : ((x : Colimitᴱ P₀ P₊ step₀ step₊) → Q x) → RHS to h = h ∘ ∣_∣₀ , [ (λ _ → h ∘ ∣_∣₊) , (λ x → subst Q (∣∣₊≡∣∣₀ x) (h ∣ step₀ x ∣₊) ≡⟨ dcong h (∣∣₊≡∣∣₀ x) ⟩∎ h ∣ x ∣₀ ∎) , (λ _ x → subst Q (∣∣₊≡∣∣₊ x) (h ∣ step₊ x ∣₊) ≡⟨ dcong h (∣∣₊≡∣∣₊ x) ⟩∎ h ∣ x ∣₊ ∎) ] from : RHS → (x : Colimitᴱ P₀ P₊ step₀ step₊) → Q x from (f₀ , [ f₊ , g₀ , g₊ ]) = elim λ where .∣∣₀ʳ → f₀ .∣∣₊ʳ → f₊ _ .∣∣₊≡∣∣₀ʳ → g₀ .∣∣₊≡∣∣₊ʳ → g₊ _ to∘from : ∀ p → to (from p) ≡ p to∘from (f₀ , [ f₊ , g₀ , g₊ ]) = cong (f₀ ,_) $ []-cong [ cong (f₊ ,_) $ cong₂ _,_ (⟨ext⟩ λ x → dcong (elim _) (∣∣₊≡∣∣₀ x) ≡⟨ elim-∣∣₊≡∣∣₀ ⟩∎ g₀ x ∎) (⟨ext⟩ λ n → ⟨ext⟩ λ x → dcong (elim _) (∣∣₊≡∣∣₊ x) ≡⟨ elim-∣∣₊≡∣∣₊ ⟩∎ g₊ n x ∎) ] from∘to : ∀ h → from (to h) ≡ h from∘to h = ⟨ext⟩ $ elim λ where .∣∣₀ʳ _ → refl _ .∣∣₊ʳ _ → refl _ .∣∣₊≡∣∣₀ʳ x → subst (λ z → from (to h) z ≡ h z) (∣∣₊≡∣∣₀ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩ trans (sym (dcong (from (to h)) (∣∣₊≡∣∣₀ x))) (trans (cong (subst Q (∣∣₊≡∣∣₀ x)) (refl _)) (dcong h (∣∣₊≡∣∣₀ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) elim-∣∣₊≡∣∣₀ (trans (cong (flip trans _) $ cong-refl _) $ trans-reflˡ _) ⟩ trans (sym (dcong h (∣∣₊≡∣∣₀ x))) (dcong h (∣∣₊≡∣∣₀ x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎ .∣∣₊≡∣∣₊ʳ x → subst (λ z → from (to h) z ≡ h z) (∣∣₊≡∣∣₊ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩ trans (sym (dcong (from (to h)) (∣∣₊≡∣∣₊ x))) (trans (cong (subst Q (∣∣₊≡∣∣₊ x)) (refl _)) (dcong h (∣∣₊≡∣∣₊ x))) ≡⟨ cong₂ (λ p q → trans (sym p) q) elim-∣∣₊≡∣∣₊ (trans (cong (flip trans _) $ cong-refl _) $ trans-reflˡ _) ⟩ trans (sym (dcong h (∣∣₊≡∣∣₊ x))) (dcong h (∣∣₊≡∣∣₊ x)) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎
{ "alphanum_fraction": 0.3645833333, "avg_line_length": 32.9552238806, "ext": "agda", "hexsha": "6d4406d51d54cfded1b2b59942d715ff74056d7f", "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/Colimit/Sequential/Very-erased.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/Colimit/Sequential/Very-erased.agda", "max_line_length": 112, "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/Colimit/Sequential/Very-erased.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": 6821, "size": 13248 }
open import Agda.Builtin.Nat data Vec (A : Set) : Nat -> Set where [] : Vec A 0 cons : {n : Nat} -> A -> Vec A n -> Vec A (suc n) empty : Vec Nat 0 empty = []
{ "alphanum_fraction": 0.5421686747, "avg_line_length": 16.6, "ext": "agda", "hexsha": "4c156fe33145f20e48c6f71b44b5b0825baf1eea", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-31T08:40:41.000Z", "max_forks_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "omega12345/RefactorAgda", "max_forks_repo_path": "RefactorAgdaEngine/Test/Tests/input/Vector.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_issues_repo_issues_event_max_datetime": "2019-02-05T12:53:36.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-31T08:03:07.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "omega12345/RefactorAgda", "max_issues_repo_path": "RefactorAgdaEngine/Test/Tests/input/Vector.agda", "max_line_length": 51, "max_stars_count": 5, "max_stars_repo_head_hexsha": "52d1034aed14c578c9e077fb60c3db1d0791416b", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "omega12345/RefactorAgda", "max_stars_repo_path": "RefactorAgdaEngine/Test/Tests/input/Vector.agda", "max_stars_repo_stars_event_max_datetime": "2019-05-03T10:03:36.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-31T14:10:18.000Z", "num_tokens": 62, "size": 166 }
------------------------------------------------------------------------------ -- The unary numbers are FOTC total natural numbers ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOTC.Data.Nat.UnaryNumbers.TotalityATP where open import FOTC.Base open import FOTC.Data.Nat.Type open import FOTC.Data.Nat.UnaryNumbers ------------------------------------------------------------------------------ postulate 0-N : N 0' 1-N : N 1' 2-N : N 2' 3-N : N 3' 4-N : N 4' 5-N : N 5' {-# ATP prove 0-N #-} {-# ATP prove 1-N #-} {-# ATP prove 2-N #-} {-# ATP prove 3-N #-} {-# ATP prove 4-N #-} {-# ATP prove 5-N #-} postulate 10-N : N 10' 11-N : N 11' {-# ATP prove 10-N #-} {-# ATP prove 11-N #-} postulate 89-N : N 89' {-# ATP prove 89-N #-} postulate 90-N : N 90' 91-N : N 91' 92-N : N 92' 93-N : N 93' 94-N : N 94' 95-N : N 95' 96-N : N 96' 97-N : N 97' 98-N : N 98' 99-N : N 99' {-# ATP prove 90-N #-} {-# ATP prove 91-N #-} {-# ATP prove 92-N #-} {-# ATP prove 93-N #-} {-# ATP prove 94-N #-} {-# ATP prove 95-N #-} {-# ATP prove 96-N #-} {-# ATP prove 97-N #-} {-# ATP prove 98-N #-} {-# ATP prove 99-N #-} postulate 100-N : N 100' 101-N : N 101' {-# ATP prove 100-N #-} {-# ATP prove 101-N #-} postulate 111-N : N 111' {-# ATP prove 111-N #-}
{ "alphanum_fraction": 0.4412550067, "avg_line_length": 21.0985915493, "ext": "agda", "hexsha": "1121769cc332fcc346ee07da001ba145571daa37", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/FOTC/Data/Nat/UnaryNumbers/TotalityATP.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/FOTC/Data/Nat/UnaryNumbers/TotalityATP.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/FOTC/Data/Nat/UnaryNumbers/TotalityATP.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": 461, "size": 1498 }
{-# OPTIONS --without-K --exact-split --safe #-} open import Fragment.Equational.Theory module Fragment.Equational.Model (Θ : Theory) where open import Fragment.Equational.Model.Base Θ public open import Fragment.Equational.Model.Synthetic Θ public open import Fragment.Equational.Model.Properties Θ public open import Fragment.Equational.Model.Satisfaction public
{ "alphanum_fraction": 0.8097826087, "avg_line_length": 33.4545454545, "ext": "agda", "hexsha": "16894545dcf97eed58869c3740097771ad8c7234", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-06-16T08:04:31.000Z", "max_forks_repo_forks_event_min_datetime": "2021-06-15T15:34:50.000Z", "max_forks_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "yallop/agda-fragment", "max_forks_repo_path": "src/Fragment/Equational/Model.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_issues_repo_issues_event_max_datetime": "2021-06-16T10:24:15.000Z", "max_issues_repo_issues_event_min_datetime": "2021-06-16T09:44:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "yallop/agda-fragment", "max_issues_repo_path": "src/Fragment/Equational/Model.agda", "max_line_length": 57, "max_stars_count": 18, "max_stars_repo_head_hexsha": "f2a6b1cf4bc95214bd075a155012f84c593b9496", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "yallop/agda-fragment", "max_stars_repo_path": "src/Fragment/Equational/Model.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T17:26:09.000Z", "max_stars_repo_stars_event_min_datetime": "2021-06-15T15:45:39.000Z", "num_tokens": 83, "size": 368 }
{- This file contains: - Some alternative inductive definitions of James, and they give the same results. The most relevant one is called `𝕁Red` because it is much simpler. It has fewer constructors, among which the 2-dimensional constructor `coh` has a form essentially more clearer, and it avoids indexes. -} {-# OPTIONS --safe #-} module Cubical.HITs.James.Inductive.Reduced where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Pointed open import Cubical.Foundations.Univalence open import Cubical.Data.Nat open import Cubical.HITs.SequentialColimit open import Cubical.HITs.James.Inductive.Base renaming (𝕁ames to 𝕁amesConstruction ; 𝕁ames∞ to 𝕁ames∞Construction) private variable ℓ : Level module _ ((X , x₀) : Pointed ℓ) where infixr 5 _∷_ -- Inductive James with fewer constructors data 𝕁Red : Type ℓ where [] : 𝕁Red _∷_ : X → 𝕁Red → 𝕁Red unit : (x : X)(xs : 𝕁Red) → x₀ ∷ x ∷ xs ≡ x ∷ x₀ ∷ xs coh : (xs : 𝕁Red) → refl ≡ unit x₀ xs data 𝕁Red∞ : Type ℓ where inl : 𝕁Red → 𝕁Red∞ push : (xs : 𝕁Red) → inl xs ≡ inl (x₀ ∷ xs) -- Auxiliary constructions -- The following square of types is defined as HIT over I × I. -- Notice that the constructor `incl∷` can be seen parametrized by i, `coh` by both i j, -- and other constructors are constant. data 𝕁Square (i j : I) : Type ℓ where [] : 𝕁Square i j _∷_ : X → 𝕁Square i j → 𝕁Square i j incl : 𝕁Square i j → 𝕁Square i j unit : (xs : 𝕁Square i j) → incl xs ≡ x₀ ∷ xs incl∷ : (x : X)(xs : 𝕁Square i j) → unit (x ∷ xs) i ≡ x ∷ unit xs i coh : (xs : 𝕁Square i j) → PathP (λ k → unit (unit xs (i ∨ k)) i ≡ unit (unit xs i) (i ∨ j ∨ k)) (λ k → unit (unit xs i) (i ∨ j ∧ k)) (incl∷ x₀ xs) -- What we need actually is its diagonal. 𝕁Path : I → Type ℓ 𝕁Path i = 𝕁Square i (~ i) -- If you expand the very definition at end points, -- you will find that `𝕁Red` is almost a deformation retraction of `𝕁1`, -- and `𝕁0` is almost the same as the original inductive definition of James. -- That explains why the isomorphisms given bellow are mainly of c-c, c-v and refls. 𝕁0 = 𝕁Path i0 𝕁1 = 𝕁Path i1 data 𝕁Path∞ (i : I) : Type ℓ where inl : 𝕁Path i → 𝕁Path∞ i push : (xs : 𝕁Path i) → inl xs ≡ inl (unit xs i) 𝕁0∞ = 𝕁Path∞ i0 𝕁1∞ = 𝕁Path∞ i1 -- The equivalence 𝕁1 ≃ 𝕁Red -- This part reduces the constructors. 𝕁1→𝕁Red : 𝕁1 → 𝕁Red 𝕁1→𝕁Red [] = [] 𝕁1→𝕁Red (x ∷ xs) = x ∷ 𝕁1→𝕁Red xs 𝕁1→𝕁Red (incl xs) = x₀ ∷ 𝕁1→𝕁Red xs 𝕁1→𝕁Red (incl∷ x xs i) = unit x (𝕁1→𝕁Red xs) i 𝕁1→𝕁Red (unit xs i) = x₀ ∷ 𝕁1→𝕁Red xs 𝕁1→𝕁Red (coh xs i j) = coh (𝕁1→𝕁Red xs) i j 𝕁Red→𝕁1 : 𝕁Red → 𝕁1 𝕁Red→𝕁1 [] = [] 𝕁Red→𝕁1 (x ∷ xs) = x ∷ 𝕁Red→𝕁1 xs 𝕁Red→𝕁1 (unit x xs i) = incl∷ x (𝕁Red→𝕁1 xs) i 𝕁Red→𝕁1 (coh xs i j) = coh (𝕁Red→𝕁1 xs) i j 𝕁Red→𝕁1→𝕁Red : (xs : 𝕁Red) → 𝕁1→𝕁Red (𝕁Red→𝕁1 xs) ≡ xs 𝕁Red→𝕁1→𝕁Red [] = refl 𝕁Red→𝕁1→𝕁Red (x ∷ xs) t = x ∷ 𝕁Red→𝕁1→𝕁Red xs t 𝕁Red→𝕁1→𝕁Red (unit x xs i) t = unit x (𝕁Red→𝕁1→𝕁Red xs t) i 𝕁Red→𝕁1→𝕁Red (coh xs i j) t = coh (𝕁Red→𝕁1→𝕁Red xs t) i j 𝕁1→𝕁Red→𝕁1 : (xs : 𝕁1) → 𝕁Red→𝕁1 (𝕁1→𝕁Red xs) ≡ xs 𝕁1→𝕁Red→𝕁1 [] = refl 𝕁1→𝕁Red→𝕁1 (x ∷ xs) t = x ∷ 𝕁1→𝕁Red→𝕁1 xs t 𝕁1→𝕁Red→𝕁1 (incl xs) = (λ t → x₀ ∷ 𝕁1→𝕁Red→𝕁1 xs t) ∙ sym (unit xs) 𝕁1→𝕁Red→𝕁1 (incl∷ x xs i) t = incl∷ x (𝕁1→𝕁Red→𝕁1 xs t) i 𝕁1→𝕁Red→𝕁1 (unit xs i) j = hcomp (λ k → λ { (i = i0) → compPath-filler (λ t → x₀ ∷ 𝕁1→𝕁Red→𝕁1 xs t) (sym (unit xs)) k j ; (i = i1) → x₀ ∷ 𝕁1→𝕁Red→𝕁1 xs j ; (j = i0) → x₀ ∷ 𝕁Red→𝕁1 (𝕁1→𝕁Red xs) ; (j = i1) → unit xs (i ∨ ~ k)}) (x₀ ∷ 𝕁1→𝕁Red→𝕁1 xs j) 𝕁1→𝕁Red→𝕁1 (coh xs i j) t = coh (𝕁1→𝕁Red→𝕁1 xs t) i j 𝕁Red∞→𝕁1∞ : 𝕁Red∞ → 𝕁1∞ 𝕁Red∞→𝕁1∞ (inl xs) = inl (𝕁Red→𝕁1 xs) 𝕁Red∞→𝕁1∞ (push xs i) = push (𝕁Red→𝕁1 xs) i 𝕁1∞→𝕁Red∞ : 𝕁1∞ → 𝕁Red∞ 𝕁1∞→𝕁Red∞ (inl xs) = inl (𝕁1→𝕁Red xs) 𝕁1∞→𝕁Red∞ (push xs i) = push (𝕁1→𝕁Red xs) i 𝕁Red∞→𝕁1∞→𝕁Red∞ : (xs : 𝕁Red∞) → 𝕁1∞→𝕁Red∞ (𝕁Red∞→𝕁1∞ xs) ≡ xs 𝕁Red∞→𝕁1∞→𝕁Red∞ (inl xs) t = inl (𝕁Red→𝕁1→𝕁Red xs t) 𝕁Red∞→𝕁1∞→𝕁Red∞ (push xs i) t = push (𝕁Red→𝕁1→𝕁Red xs t) i 𝕁1∞→𝕁Red∞→𝕁1∞ : (xs : 𝕁1∞) → 𝕁Red∞→𝕁1∞ (𝕁1∞→𝕁Red∞ xs) ≡ xs 𝕁1∞→𝕁Red∞→𝕁1∞ (inl xs) t = inl (𝕁1→𝕁Red→𝕁1 xs t) 𝕁1∞→𝕁Red∞→𝕁1∞ (push xs i) t = push (𝕁1→𝕁Red→𝕁1 xs t) i 𝕁1∞≃𝕁Red∞ : 𝕁1∞ ≃ 𝕁Red∞ 𝕁1∞≃𝕁Red∞ = isoToEquiv (iso 𝕁1∞→𝕁Red∞ 𝕁Red∞→𝕁1∞ 𝕁Red∞→𝕁1∞→𝕁Red∞ 𝕁1∞→𝕁Red∞→𝕁1∞) -- The equivalence 𝕁ames ≃ 𝕁0 -- This part removes the indexes. private 𝕁ames = 𝕁amesConstruction (X , x₀) 𝕁ames∞ = 𝕁ames∞Construction (X , x₀) index : 𝕁0 → ℕ index [] = 0 index (x ∷ xs) = 1 + index xs index (incl xs) = 1 + index xs index (incl∷ x xs i) = 2 + index xs index (unit xs i) = 1 + index xs index (coh xs i j) = 2 + index xs 𝕁ames→𝕁0 : {n : ℕ} → 𝕁ames n → 𝕁0 𝕁ames→𝕁0 [] = [] 𝕁ames→𝕁0 (x ∷ xs) = x ∷ 𝕁ames→𝕁0 xs 𝕁ames→𝕁0 (incl xs) = incl (𝕁ames→𝕁0 xs) 𝕁ames→𝕁0 (incl∷ x xs i) = incl∷ x (𝕁ames→𝕁0 xs) i 𝕁ames→𝕁0 (unit xs i) = unit (𝕁ames→𝕁0 xs) i 𝕁ames→𝕁0 (coh xs i j) = coh (𝕁ames→𝕁0 xs) i j 𝕁0→𝕁ames : (xs : 𝕁0) → 𝕁ames (index xs) 𝕁0→𝕁ames [] = [] 𝕁0→𝕁ames (x ∷ xs) = x ∷ 𝕁0→𝕁ames xs 𝕁0→𝕁ames (incl xs) = incl (𝕁0→𝕁ames xs) 𝕁0→𝕁ames (incl∷ x xs i) = incl∷ x (𝕁0→𝕁ames xs) i 𝕁0→𝕁ames (unit xs i) = unit (𝕁0→𝕁ames xs) i 𝕁0→𝕁ames (coh xs i j) = coh (𝕁0→𝕁ames xs) i j 𝕁0→𝕁ames→𝕁0 : (xs : 𝕁0) → 𝕁ames→𝕁0 (𝕁0→𝕁ames xs) ≡ xs 𝕁0→𝕁ames→𝕁0 [] = refl 𝕁0→𝕁ames→𝕁0 (x ∷ xs) t = x ∷ 𝕁0→𝕁ames→𝕁0 xs t 𝕁0→𝕁ames→𝕁0 (incl xs) t = incl (𝕁0→𝕁ames→𝕁0 xs t) 𝕁0→𝕁ames→𝕁0 (incl∷ x xs i) t = incl∷ x (𝕁0→𝕁ames→𝕁0 xs t) i 𝕁0→𝕁ames→𝕁0 (unit xs i) t = unit (𝕁0→𝕁ames→𝕁0 xs t) i 𝕁0→𝕁ames→𝕁0 (coh xs i j) t = coh (𝕁0→𝕁ames→𝕁0 xs t) i j index-path : {n : ℕ}(xs : 𝕁ames n) → index (𝕁ames→𝕁0 xs) ≡ n index-path [] = refl index-path (x ∷ xs) t = 1 + index-path xs t index-path (incl xs) t = 1 + index-path xs t index-path (incl∷ x xs i) t = 2 + index-path xs t index-path (unit xs i) t = 1 + index-path xs t index-path (coh xs i j) t = 2 + index-path xs t 𝕁ames→𝕁0→𝕁ames : {n : ℕ}(xs : 𝕁ames n) → PathP (λ i → 𝕁ames (index-path xs i)) (𝕁0→𝕁ames (𝕁ames→𝕁0 xs)) xs 𝕁ames→𝕁0→𝕁ames [] = refl 𝕁ames→𝕁0→𝕁ames (x ∷ xs) t = x ∷ 𝕁ames→𝕁0→𝕁ames xs t 𝕁ames→𝕁0→𝕁ames (incl xs) t = incl (𝕁ames→𝕁0→𝕁ames xs t) 𝕁ames→𝕁0→𝕁ames (incl∷ x xs i) t = incl∷ x (𝕁ames→𝕁0→𝕁ames xs t) i 𝕁ames→𝕁0→𝕁ames (unit xs i) t = unit (𝕁ames→𝕁0→𝕁ames xs t) i 𝕁ames→𝕁0→𝕁ames (coh xs i j) t = coh (𝕁ames→𝕁0→𝕁ames xs t) i j 𝕁ames∞→𝕁0∞ : 𝕁ames∞ → 𝕁0∞ 𝕁ames∞→𝕁0∞ (inl xs) = inl (𝕁ames→𝕁0 xs) 𝕁ames∞→𝕁0∞ (push xs i) = push (𝕁ames→𝕁0 xs) i 𝕁0∞→𝕁ames∞ : 𝕁0∞ → 𝕁ames∞ 𝕁0∞→𝕁ames∞ (inl xs) = inl (𝕁0→𝕁ames xs) 𝕁0∞→𝕁ames∞ (push xs i) = push (𝕁0→𝕁ames xs) i 𝕁ames∞→𝕁0∞→𝕁ames∞ : (xs : 𝕁ames∞) → 𝕁0∞→𝕁ames∞ (𝕁ames∞→𝕁0∞ xs) ≡ xs 𝕁ames∞→𝕁0∞→𝕁ames∞ (inl xs) t = inl (𝕁ames→𝕁0→𝕁ames xs t) 𝕁ames∞→𝕁0∞→𝕁ames∞ (push xs i) t = push (𝕁ames→𝕁0→𝕁ames xs t) i 𝕁0∞→𝕁ames∞→𝕁0∞ : (xs : 𝕁0∞) → 𝕁ames∞→𝕁0∞ (𝕁0∞→𝕁ames∞ xs) ≡ xs 𝕁0∞→𝕁ames∞→𝕁0∞ (inl xs) t = inl (𝕁0→𝕁ames→𝕁0 xs t) 𝕁0∞→𝕁ames∞→𝕁0∞ (push xs i) t = push (𝕁0→𝕁ames→𝕁0 xs t) i 𝕁ames∞≃𝕁0∞ : 𝕁ames∞ ≃ 𝕁0∞ 𝕁ames∞≃𝕁0∞ = isoToEquiv (iso 𝕁ames∞→𝕁0∞ 𝕁0∞→𝕁ames∞ 𝕁0∞→𝕁ames∞→𝕁0∞ 𝕁ames∞→𝕁0∞→𝕁ames∞) -- The main equivalence: 𝕁ames∞≃𝕁Red∞ : 𝕁ames∞ ≃ 𝕁Red∞ 𝕁ames∞≃𝕁Red∞ = compEquiv 𝕁ames∞≃𝕁0∞ (compEquiv (pathToEquiv (λ i → 𝕁Path∞ i)) 𝕁1∞≃𝕁Red∞) -- Test of canonicity private -- It's good for []. eq1 : 𝕁ames∞≃𝕁Red∞ .fst (inl []) ≡ inl [] eq1 = refl -- Without regularity, "obvious" equality doesn't hold definitionally. eq2 : (x : X) → 𝕁ames∞≃𝕁Red∞ .fst (inl (x ∷ [])) ≡ inl (x ∷ []) eq2 _ = transportRefl _
{ "alphanum_fraction": 0.5877783532, "avg_line_length": 33.7292576419, "ext": "agda", "hexsha": "cc721a0db950022add0729c2fa16a9a1483b2460", "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/HITs/James/Inductive/Reduced.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/HITs/James/Inductive/Reduced.agda", "max_line_length": 90, "max_stars_count": 1, "max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "thomas-lamiaux/cubical", "max_stars_repo_path": "Cubical/HITs/James/Inductive/Reduced.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z", "num_tokens": 4714, "size": 7724 }
{-# OPTIONS --allow-unsolved-metas #-} module Issue3256.B where f : (a : Set) -> a -> a f a y = {!!} y
{ "alphanum_fraction": 0.5428571429, "avg_line_length": 15, "ext": "agda", "hexsha": "6fa6934cc087a06d292a3234f3cd6b4e47744147", "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/Issue3256/B.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/Issue3256/B.agda", "max_line_length": 38, "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/Issue3256/B.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": 105 }
module examplesPaperJFP.SpaceShipAdvanced where open import SizedIO.Base open import StateSizedIO.GUI.BaseStateDependent open import Data.Bool.Base open import Data.List.Base open import Data.Integer open import Data.Product hiding (map) open import SizedIO.Object open import SizedIO.IOObject open import NativeIO open import Size open import StateSizedIO.GUI.WxBindingsFFI open import StateSizedIO.GUI.VariableList open import StateSizedIO.GUI.WxGraphicsLib open import StateSized.GUI.BitMaps data GraphicServerMethod : Set where onPaintM : DC → Rect → GraphicServerMethod moveSpaceShipM : Frame → GraphicServerMethod callRepaintM : Frame → GraphicServerMethod GraphicServerResult : GraphicServerMethod → Set GraphicServerResult _ = Unit GraphicServerInterface : Interface Method GraphicServerInterface = GraphicServerMethod Result GraphicServerInterface = GraphicServerResult GraphicServerObject : ∀{i} → Set GraphicServerObject {i} = IOObject GuiLev1Interface GraphicServerInterface i graphicServerObject : ∀{i} → ℤ → GraphicServerObject {i} method (graphicServerObject z) (onPaintM dc rect) = exec (drawBitmap dc ship (z , (+ 150)) true) λ _ → return (unit , graphicServerObject z) method (graphicServerObject z) (moveSpaceShipM fra) = return (unit , graphicServerObject (z + (+ 20))) method (graphicServerObject z) (callRepaintM fra) = exec (repaint fra) λ _ → return (unit , graphicServerObject z) VarType = GraphicServerObject {∞} varInit : VarType varInit = graphicServerObject (+ 150) onPaint : ∀{i} → VarType → DC → Rect → IO GuiLev1Interface i VarType onPaint obj dc rect = mapIO proj₂ (method obj (onPaintM dc rect)) moveSpaceShip : ∀{i} → Frame → VarType → IO GuiLev1Interface i VarType moveSpaceShip fra obj = mapIO proj₂ (method obj (moveSpaceShipM fra)) callRepaint : ∀{i} → Frame → VarType → IO GuiLev1Interface i VarType callRepaint fra obj = mapIO proj₂ (method obj (callRepaintM fra)) buttonHandler : ∀{i} → Frame → List (VarType → IO GuiLev1Interface i VarType) buttonHandler fra = moveSpaceShip fra ∷ [ callRepaint fra ] program : ∀{i} → IOˢ GuiLev2Interface i (λ _ → Unit) [] program = execˢ (level1C makeFrame) λ fra → execˢ (level1C (makeButton fra)) λ bt → execˢ (level1C (addButton fra bt)) λ _ → execˢ (createVar varInit) λ _ → execˢ (setButtonHandler bt (moveSpaceShip fra ∷ [ callRepaint fra ])) λ _ → execˢ (setOnPaint fra [ onPaint ]) returnˢ main : NativeIO Unit main = start (translateLev2 program)
{ "alphanum_fraction": 0.6999631404, "avg_line_length": 32.2976190476, "ext": "agda", "hexsha": "5d0310c70fd26c3a14752b6fc9481701c85f2d9c", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "examples/examplesPaperJFP/SpaceShipAdvanced.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "examples/examplesPaperJFP/SpaceShipAdvanced.agda", "max_line_length": 78, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "examples/examplesPaperJFP/SpaceShipAdvanced.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 756, "size": 2713 }
data Nat : Set where zero : Nat suc : Nat → Nat pattern plus-two n = suc (suc n) f : Nat → Nat f (plus-two n) = f n f (suc zero) = plus-two zero f zero = zero
{ "alphanum_fraction": 0.5928143713, "avg_line_length": 13.9166666667, "ext": "agda", "hexsha": "327c8a660b30169194ff9ee7752ed8243748c195", "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/Issue758.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/Issue758.agda", "max_line_length": 32, "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/Issue758.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": 167 }
module chap0 where open import Data.List open import Data.Nat hiding (_⊔_) -- open import Data.Integer hiding (_⊔_ ; _≟_ ; _+_ ) open import Data.Product A : List ℕ A = 1 ∷ 2 ∷ [] data Literal : Set where x : Literal y : Literal z : Literal B : List Literal B = x ∷ y ∷ z ∷ [] ListProduct : {A B : Set } → List A → List B → List ( A × B ) ListProduct = {!!} ex05 : List ( ℕ × Literal ) ex05 = ListProduct A B -- (1 , x) ∷ (1 , y) ∷ (1 , z) ∷ (2 , x) ∷ (2 , y) ∷ (2 , z) ∷ [] ex06 : List ( ℕ × Literal × ℕ ) ex06 = ListProduct A (ListProduct B A) ex07 : Set ex07 = ℕ × ℕ data ex08-f : ℕ → ℕ → Set where ex08f0 : ex08-f 0 1 ex08f1 : ex08-f 1 2 ex08f2 : ex08-f 2 3 ex08f3 : ex08-f 3 4 ex08f4 : ex08-f 4 0 data ex09-g : ℕ → ℕ → ℕ → ℕ → Set where ex09g0 : ex09-g 0 1 2 3 ex09g1 : ex09-g 1 2 3 0 ex09g2 : ex09-g 2 3 0 1 ex09g3 : ex09-g 3 0 1 2 open import Data.Nat.DivMod open import Relation.Binary.PropositionalEquality open import Relation.Binary.Core open import Data.Nat.Properties -- _%_ : ℕ → ℕ → ℕ -- _%_ a b with <-cmp a b -- _%_ a b | tri< a₁ ¬b ¬c = a -- _%_ a b | tri≈ ¬a b₁ ¬c = 0 -- _%_ a b | tri> ¬a ¬b c = _%_ (a - b) b _≡7_ : ℕ → ℕ → Set n ≡7 m = (n % 7) ≡ (m % 7 ) refl7 : { n : ℕ} → n ≡7 n refl7 = {!!} sym7 : { n m : ℕ} → n ≡7 m → m ≡7 n sym7 = {!!} trans7 : { n m o : ℕ} → n ≡7 m → m ≡7 o → n ≡7 o trans7 = {!!} open import Level renaming ( zero to Zero ; suc to Suc ) record Graph { v v' : Level } : Set (Suc v ⊔ Suc v' ) where field vertex : Set v edge : vertex → vertex → Set v' open Graph -- open import Data.Fin hiding ( _≟_ ) open import Data.Empty open import Relation.Nullary open import Data.Unit hiding ( _≟_ ) -- data Dec (P : Set) : Set where -- yes : P → Dec P -- no : ¬ P → Dec P -- -- _≟_ : (s t : ℕ ) → Dec ( s ≡ t ) -- ¬ A = A → ⊥ _n≟_ : (s t : ℕ ) → Dec ( s ≡ t ) zero n≟ zero = yes refl zero n≟ suc t = no (λ ()) suc s n≟ zero = no (λ ()) suc s n≟ suc t with s n≟ t ... | yes refl = yes refl ... | no n = no (λ k → n (tt1 k) ) where tt1 : suc s ≡ suc t → s ≡ t tt1 refl = refl open import Data.Bool hiding ( _≟_ ) conn : List ( ℕ × ℕ ) → ℕ → ℕ → Bool conn [] _ _ = false conn ((n1 , m1 ) ∷ t ) n m with n ≟ n1 | m ≟ m1 conn ((n1 , m1) ∷ t) n m | yes refl | yes refl = true conn ((n1 , m1) ∷ t) n m | _ | _ = conn t n m list012a : List ( ℕ × ℕ ) list012a = (1 , 2) ∷ (2 , 3) ∷ (3 , 4) ∷ (4 , 5) ∷ (5 , 1) ∷ [] graph012a : Graph {Zero} {Zero} graph012a = record { vertex = ℕ ; edge = λ s t → (conn list012a s t) ≡ true } data edge012b : ℕ → ℕ → Set where e012b-1 : edge012b 1 2 e012b-2 : edge012b 1 3 e012b-3 : edge012b 1 4 e012b-4 : edge012b 2 3 e012b-5 : edge012b 2 4 e012b-6 : edge012b 3 4 edge? : (E : ℕ → ℕ → Set) → ( a b : ℕ ) → Set edge? E a b = Dec ( E a b ) lemma3 : ( a b : ℕ ) → edge? edge012b a b lemma3 1 2 = yes e012b-1 lemma3 1 3 = yes e012b-2 lemma3 1 4 = yes e012b-3 lemma3 2 3 = yes e012b-4 lemma3 2 4 = yes e012b-5 lemma3 3 4 = yes e012b-6 lemma3 1 1 = no ( λ () ) lemma3 2 1 = no ( λ () ) lemma3 2 2 = no ( λ () ) lemma3 3 1 = no ( λ () ) lemma3 3 2 = no ( λ () ) lemma3 3 3 = no ( λ () ) lemma3 0 _ = no ( λ () ) lemma3 _ 0 = no ( λ () ) lemma3 _ (suc (suc (suc (suc (suc _))))) = no ( λ () ) lemma3 (suc (suc (suc (suc _)))) _ = no ( λ () ) graph012b : Graph {Zero} {Zero} graph012b = record { vertex = ℕ ; edge = edge012b } data connected { V : Set } ( E : V -> V -> Set ) ( x y : V ) : Set where direct : E x y → connected E x y indirect : ( z : V ) -> E x z → connected {V} E z y → connected E x y lemma1 : connected ( edge graph012a ) 1 2 lemma1 = direct refl where lemma1-2 : connected ( edge graph012a ) 1 3 lemma1-2 = indirect 2 refl (direct refl ) lemma2 : connected ( edge graph012b ) 1 2 lemma2 = direct e012b-1 reachable : { V : Set } ( E : V -> V -> Set ) ( x y : V ) -> Set reachable {V} E X Y = Dec ( connected {V} E X Y ) dag : { V : Set } ( E : V -> V -> Set ) -> Set dag {V} E = ∀ (n : V) → ¬ ( connected E n n ) open import Function lemma4 : ¬ ( dag ( edge graph012a) ) lemma4 neg = neg 1 $ indirect 2 refl $ indirect 3 refl $ indirect 4 refl $ indirect 5 refl $ direct refl dgree : List ( ℕ × ℕ ) → ℕ → ℕ dgree [] _ = 0 dgree ((e , e1) ∷ t) e0 with e0 ≟ e | e0 ≟ e1 dgree ((e , e1) ∷ t) e0 | yes _ | _ = 1 + (dgree t e0) dgree ((e , e1) ∷ t) e0 | _ | yes p = 1 + (dgree t e0) dgree ((e , e1) ∷ t) e0 | no _ | no _ = dgree t e0 dgree-c : {t : Set} → List ( ℕ × ℕ ) → ℕ → (ℕ → t) → t dgree-c {t} [] e0 next = next 0 dgree-c {t} ((e , e1) ∷ tail ) e0 next with e0 ≟ e | e0 ≟ e1 ... | yes _ | _ = dgree-c tail e0 ( λ n → next (n + 1 )) ... | _ | yes _ = dgree-c tail e0 ( λ n → next (n + 1 )) ... | no _ | no _ = dgree-c tail e0 next lemma6 = dgree list012a 2 lemma7 = dgree-c list012a 2 ( λ n → n ) even2 : (n : ℕ ) → n % 2 ≡ 0 → (n + 2) % 2 ≡ 0 even2 0 refl = refl even2 1 () even2 (suc (suc n)) eq = trans ([a+n]%n≡a%n n _) eq -- [a+n]%n≡a%n : ∀ a n → (a + suc n) % suc n ≡ a % suc n sum-of-dgree : ( g : List ( ℕ × ℕ )) → ℕ sum-of-dgree [] = 0 sum-of-dgree ((e , e1) ∷ t) = 2 + sum-of-dgree t dgree-even : ( g : List ( ℕ × ℕ )) → sum-of-dgree g % 2 ≡ 0 dgree-even [] = refl dgree-even ((e , e1) ∷ t) = begin sum-of-dgree ((e , e1) ∷ t) % 2 ≡⟨⟩ (2 + sum-of-dgree t ) % 2 ≡⟨ cong ( λ k → k % 2 ) ( +-comm 2 (sum-of-dgree t) ) ⟩ (sum-of-dgree t + 2) % 2 ≡⟨ [a+n]%n≡a%n (sum-of-dgree t) _ ⟩ sum-of-dgree t % 2 ≡⟨ dgree-even t ⟩ 0 ∎ where open ≡-Reasoning
{ "alphanum_fraction": 0.5162210339, "avg_line_length": 26.5876777251, "ext": "agda", "hexsha": "c54303d2e37d17a015ffefac355cce82980c2694", "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": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/automaton-in-agda", "max_forks_repo_path": "src/chap0.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "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/automaton-in-agda", "max_issues_repo_path": "src/chap0.agda", "max_line_length": 108, "max_stars_count": null, "max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/automaton-in-agda", "max_stars_repo_path": "src/chap0.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2488, "size": 5610 }
{-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} ------------------------------------------------------------------------------ -- The translation from pattern matching equations to equational -- axioms requires some care because the pattern matching equations -- are processed from top to bottom and from left to right. -- From: Herbert P. Sander. A logic of functional programs with an -- application to concurrency. PhD thesis, Chalmers University of -- Technology and University of Gothenburg, Department of Computer -- Sciences, 1992. pp. 12-13. ------------------------------------------------------------------------------ module Berry.Berry where infix 7 _≡_ postulate D : Set zero loop : D succ : D → D data _≡_ (x : D) : D → Set where refl : x ≡ x -- For example, the translation of the Haskell function -- f ∷ Nat → Nat → Nat → Nat -- f Zero (Succ Zero) x = Succ Zero -- f (Succ Zero) x Zero = Succ (Succ Zero) -- f x Zero (Succ Zero) = Succ (Succ (Succ Zero)) -- to the equational axioms postulate f : D → D → D → D f-eq₁ : ∀ x → f zero (succ zero) x ≡ succ zero f-eq₂ : ∀ x → f (succ zero) x zero ≡ succ (succ zero) f-eq₃ : ∀ x → f x zero (succ zero) ≡ succ (succ (succ zero)) {-# ATP axioms f-eq₁ f-eq₂ f-eq₃ #-} -- is not correct, because using the Haskell equations we have -- -- f loop zero (succ zero) = *** Non-terminating *** -- -- but using the equational axioms we can proof that postulate bad : f loop zero (succ zero) ≡ succ (succ (succ zero)) {-# ATP prove bad #-}
{ "alphanum_fraction": 0.5402951192, "avg_line_length": 32.6296296296, "ext": "agda", "hexsha": "ac0baa826a8780049ec4537b65181d04cac0efbf", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/Berry/Berry.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/Berry/Berry.agda", "max_line_length": 79, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/Berry/Berry.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": 455, "size": 1762 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Experiments.ZCohomologyOld.KcompPrelims where open import Cubical.ZCohomology.Base open import Cubical.Homotopy.Connected open import Cubical.HITs.Hopf -- open import Cubical.Homotopy.Freudenthal hiding (encode) open import Cubical.HITs.Sn open import Cubical.HITs.S1 open import Cubical.HITs.Truncation renaming (elim to trElim ; rec to trRec ; map to trMap) open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Transport open import Cubical.Foundations.Path open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Univalence open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Data.Int renaming (_+_ to +Int) hiding (_·_) open import Cubical.Data.Nat hiding (_·_) open import Cubical.Data.Unit open import Cubical.HITs.Susp open import Cubical.HITs.Nullification open import Cubical.Data.Prod.Base open import Cubical.Homotopy.Loopspace open import Cubical.Data.Bool open import Cubical.Data.Sum.Base open import Cubical.Data.Sigma hiding (_×_) open import Cubical.Foundations.Function open import Cubical.Foundations.Pointed open import Cubical.HITs.S3 private variable ℓ : Level A : Type ℓ {- We want to prove that Kn≃ΩKn+1. For this we use the map ϕ-} -- Proof of Kₙ ≃ ∥ ΩSⁿ⁺¹ ∥ₙ for $n ≥ 2$ -- Entirely based on Cavallos proof of Freudenthal in Cubical.Homotopy.Freudenthal module miniFreudenthal (n : HLevel) where σ : S₊ (2 + n) → typ (Ω (S₊∙ (3 + n))) σ a = merid a ∙ merid north ⁻¹ S2+n = S₊ (2 + n) 4n+2 = (2 + n) + (2 + n) module WC-S (p : north ≡ north) where P : (a b : S₊ (2 + n)) → Type₀ P a b = σ b ≡ p → hLevelTrunc 4n+2 (fiber (λ x → merid x ∙ merid a ⁻¹) p) hLevelP : (a b : S₊ (2 + n)) → isOfHLevel 4n+2 (P a b) hLevelP _ _ = isOfHLevelΠ 4n+2 λ _ → isOfHLevelTrunc 4n+2 leftFun : (a : S₊ (2 + n)) → P a north leftFun a r = ∣ a , (rCancel' (merid a) ∙ rCancel' (merid north) ⁻¹) ∙ r ∣ rightFun : (b : S₊ (2 + n)) → P north b rightFun b r = ∣ b , r ∣ funsAgree : leftFun north ≡ rightFun north funsAgree = funExt λ r → (λ i → ∣ north , rCancel' (rCancel' (merid north)) i ∙ r ∣) ∙ λ i → ∣ north , lUnit r (~ i) ∣ totalFun : (a b : S2+n) → P a b totalFun = wedgeConSn (suc n) (suc n) hLevelP rightFun leftFun funsAgree .fst leftId : (λ x → totalFun x north) ≡ leftFun leftId x i = wedgeConSn (suc n) (suc n) hLevelP rightFun leftFun funsAgree .snd .snd i x fwd : (p : north ≡ north) (a : S2+n) → hLevelTrunc 4n+2 (fiber σ p) → hLevelTrunc 4n+2 (fiber (λ x → merid x ∙ merid a ⁻¹) p) fwd p a = trRec (isOfHLevelTrunc 4n+2) (uncurry (WC-S.totalFun p a)) fwdnorth : (p : north ≡ north) → fwd p north ≡ idfun _ fwdnorth p = funExt (trElim (λ _ → isOfHLevelPath 4n+2 (isOfHLevelTrunc 4n+2) _ _) λ p → refl) isEquivFwd : (p : north ≡ north) (a : S2+n) → isEquiv (fwd p a) isEquivFwd p = suspToPropElim (ptSn (suc n)) (λ _ → isPropIsEquiv _) helper where helper : isEquiv (fwd p north) helper = subst isEquiv (sym (fwdnorth p)) (idIsEquiv _) interpolate : (a : S2+n) → PathP (λ i → S2+n → north ≡ merid a i) (λ x → merid x ∙ merid a ⁻¹) merid interpolate a i x j = compPath-filler (merid x) (merid a ⁻¹) (~ i) j Code : (y : Susp S2+n) → north ≡ y → Type₀ Code north p = hLevelTrunc 4n+2 (fiber σ p) Code south q = hLevelTrunc 4n+2 (fiber merid q) Code (merid a i) p = Glue (hLevelTrunc 4n+2 (fiber (interpolate a i) p)) (λ { (i = i0) → _ , (fwd p a , isEquivFwd p a) ; (i = i1) → _ , idEquiv _ }) encodeS : (y : S₊ (3 + n)) (p : north ≡ y) → Code y p encodeS y = J Code ∣ north , rCancel' (merid north) ∣ encodeMerid : (a : S2+n) → encodeS south (merid a) ≡ ∣ a , refl ∣ encodeMerid a = cong (transport (λ i → gluePath i)) (funExt⁻ (funExt⁻ (WC-S.leftId refl) a) _ ∙ λ i → ∣ a , lem (rCancel' (merid a)) (rCancel' (merid north)) i ∣) ∙ transport (PathP≡Path gluePath _ _) (λ i → ∣ a , (λ j k → rCancel-filler' (merid a) i j k) ∣) where gluePath : I → Type _ gluePath i = hLevelTrunc 4n+2 (fiber (interpolate a i) (λ j → merid a (i ∧ j))) lem : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : z ≡ y) → (p ∙ q ⁻¹) ∙ q ≡ p lem p q = assoc p (q ⁻¹) q ⁻¹ ∙ cong (p ∙_) (lCancel q) ∙ rUnit p ⁻¹ contractCodeSouth : (p : north ≡ south) (c : Code south p) → encodeS south p ≡ c contractCodeSouth p = trElim (λ _ → isOfHLevelPath 4n+2 (isOfHLevelTrunc 4n+2) _ _) (uncurry λ a → J (λ p r → encodeS south p ≡ ∣ a , r ∣) (encodeMerid a)) isConnectedMerid : isConnectedFun 4n+2 (merid {A = S2+n}) isConnectedMerid p = encodeS south p , contractCodeSouth p isConnectedσ : isConnectedFun 4n+2 σ isConnectedσ = transport (λ i → isConnectedFun 4n+2 (interpolate north (~ i))) isConnectedMerid isConnectedσ-Sn : (n : ℕ) → isConnectedFun (4 + n) (miniFreudenthal.σ n) isConnectedσ-Sn n = isConnectedFunSubtr _ n _ (subst (λ x → isConnectedFun x (miniFreudenthal.σ n)) helper (miniFreudenthal.isConnectedσ n)) where helper : 2 + (n + (2 + n)) ≡ n + (4 + n) helper = cong suc (sym (+-suc n _)) ∙ sym (+-suc n _) stabSpheres-n≥2 : (n : ℕ) → Iso (hLevelTrunc (4 + n) (S₊ (2 + n))) (hLevelTrunc (4 + n) (typ (Ω (S₊∙ (3 + n))))) stabSpheres-n≥2 n = connectedTruncIso (4 + n) (miniFreudenthal.σ n) (isConnectedσ-Sn n) -- ϕ : (pt a : A) → typ (Ω (Susp A , north)) ϕ pt a = (merid a) ∙ sym (merid pt) private Kn→ΩKn+1 : (n : ℕ) → coHomK n → typ (Ω (coHomK-ptd (suc n))) Kn→ΩKn+1 zero x i = ∣ intLoop x i ∣ Kn→ΩKn+1 (suc zero) = trRec (isOfHLevelTrunc 4 ∣ north ∣ ∣ north ∣) λ a i → ∣ ϕ base a i ∣ Kn→ΩKn+1 (suc (suc n)) = trRec (isOfHLevelTrunc (2 + (3 + n)) ∣ north ∣ ∣ north ∣) λ a i → ∣ ϕ north a i ∣ d-map : typ (Ω ((Susp S¹) , north)) → S¹ d-map p = subst HopfSuspS¹ p base d-mapId : (r : S¹) → d-map (ϕ base r) ≡ r d-mapId r = substComposite HopfSuspS¹ (merid r) (sym (merid base)) base ∙ rotLemma r where rotLemma : (r : S¹) → r · base ≡ r rotLemma base = refl rotLemma (loop i) = refl sphereConnectedSpecCase : isConnected 4 (Susp (Susp S¹)) sphereConnectedSpecCase = sphereConnected 3 d-mapComp : Iso (fiber d-map base) (Path (S₊ 3) north north) d-mapComp = compIso (IsoΣPathTransportPathΣ {B = HopfSuspS¹} _ _) (congIso (invIso IsoS³TotalHopf)) is1Connected-dmap : isConnectedFun 3 d-map is1Connected-dmap = toPropElim (λ _ → isPropIsOfHLevel 0) (isConnectedRetractFromIso 3 d-mapComp (isOfHLevelRetractFromIso 0 (invIso (PathIdTruncIso 3)) contrHelper)) where contrHelper : isContr (Path (∥ Susp (Susp S¹) ∥ 4) ∣ north ∣ ∣ north ∣) fst contrHelper = refl snd contrHelper = isOfHLevelPlus {n = 0} 2 (sphereConnected 3) ∣ north ∣ ∣ north ∣ refl d-Iso : Iso (∥ Path (S₊ 2) north north ∥ 3) (coHomK 1) d-Iso = connectedTruncIso _ d-map is1Connected-dmap d-mapId2 : Iso.fun d-Iso ∘ trMap (ϕ base) ≡ idfun (coHomK 1) d-mapId2 = funExt (trElim (λ _ → isOfHLevelPath 3 (isOfHLevelTrunc 3) _ _) λ a i → ∣ d-mapId a i ∣) Iso∥ϕ₁∥ : Iso (coHomK 1) (∥ Path (S₊ 2) north north ∥ 3) Iso∥ϕ₁∥ = composesToId→Iso d-Iso (trMap (ϕ base)) d-mapId2 Iso-Kn-ΩKn+1 : (n : HLevel) → Iso (coHomK n) (typ (Ω (coHomK-ptd (suc n)))) Iso-Kn-ΩKn+1 zero = invIso (compIso (congIso (truncIdempotentIso _ isGroupoidS¹)) ΩS¹IsoInt) Iso-Kn-ΩKn+1 (suc zero) = compIso Iso∥ϕ₁∥ (invIso (PathIdTruncIso 3)) Iso-Kn-ΩKn+1 (suc (suc n)) = compIso (stabSpheres-n≥2 n) (invIso (PathIdTruncIso (4 + n))) where helper : n + (4 + n) ≡ 2 + (n + (2 + n)) helper = +-suc n (3 + n) ∙ (λ i → suc (+-suc n (2 + n) i))
{ "alphanum_fraction": 0.60780964, "avg_line_length": 38.4741784038, "ext": "agda", "hexsha": "9688668c87bad593ac866e5b1544ff34afc0f6ad", "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": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Experiments/ZCohomologyOld/KcompPrelims.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "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": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Experiments/ZCohomologyOld/KcompPrelims.agda", "max_line_length": 116, "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/Experiments/ZCohomologyOld/KcompPrelims.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3176, "size": 8195 }
------------------------------------------------------------------------ -- Unary relations ------------------------------------------------------------------------ module Relation.Unary where open import Data.Empty open import Data.Function open import Data.Unit open import Data.Product open import Data.Sum open import Relation.Nullary ------------------------------------------------------------------------ -- Unary relations Pred : Set → Set₁ Pred a = a → Set ------------------------------------------------------------------------ -- Unary relations can be seen as sets -- I.e., they can be seen as subsets of the universe of discourse. private module Dummy {a : Set} -- The universe of discourse. where -- Set membership. infix 4 _∈_ _∉_ _∈_ : a → Pred a → Set x ∈ P = P x _∉_ : a → Pred a → Set x ∉ P = ¬ x ∈ P -- The empty set. ∅ : Pred a ∅ = λ _ → ⊥ -- The property of being empty. Empty : Pred a → Set Empty P = ∀ x → x ∉ P ∅-Empty : Empty ∅ ∅-Empty x () -- The universe, i.e. the subset containing all elements in a. U : Pred a U = λ _ → ⊤ -- The property of being universal. Universal : Pred a → Set Universal P = ∀ x → x ∈ P U-Universal : Universal U U-Universal = λ _ → _ -- Set complement. ∁ : Pred a → Pred a ∁ P = λ x → x ∉ P ∁∅-Universal : Universal (∁ ∅) ∁∅-Universal = λ x x∈∅ → x∈∅ ∁U-Empty : Empty (∁ U) ∁U-Empty = λ x x∈∁U → x∈∁U _ -- P ⊆ Q means that P is a subset of Q. _⊆′_ is a variant of _⊆_. infix 4 _⊆_ _⊇_ _⊆′_ _⊇′_ _⊆_ : Pred a → Pred a → Set P ⊆ Q = ∀ {x} → x ∈ P → x ∈ Q _⊆′_ : Pred a → Pred a → Set P ⊆′ Q = ∀ x → x ∈ P → x ∈ Q _⊇_ : Pred a → Pred a → Set Q ⊇ P = P ⊆ Q _⊇′_ : Pred a → Pred a → Set Q ⊇′ P = P ⊆′ Q ∅-⊆ : (P : Pred a) → ∅ ⊆ P ∅-⊆ P () ⊆-U : (P : Pred a) → P ⊆ U ⊆-U P _ = _ -- Set union. infixl 6 _∪_ _∪_ : Pred a → Pred a → Pred a P ∪ Q = λ x → x ∈ P ⊎ x ∈ Q -- Set intersection. infixl 7 _∩_ _∩_ : Pred a → Pred a → Pred a P ∩ Q = λ x → x ∈ P × x ∈ Q open Dummy public ------------------------------------------------------------------------ -- Unary relation combinators infixr 2 _⟨×⟩_ infixr 1 _⟨⊎⟩_ infixr 0 _⟨→⟩_ _⟨×⟩_ : ∀ {A B} → Pred A → Pred B → Pred (A × B) (P ⟨×⟩ Q) p = P (proj₁ p) × Q (proj₂ p) _⟨⊎⟩_ : ∀ {A B} → Pred A → Pred B → Pred (A ⊎ B) (P ⟨⊎⟩ Q) (inj₁ p) = P p (P ⟨⊎⟩ Q) (inj₂ q) = Q q _⟨→⟩_ : ∀ {A B} → Pred A → Pred B → Pred (A → B) (P ⟨→⟩ Q) f = P ⊆ Q ∘₀ f
{ "alphanum_fraction": 0.4400320899, "avg_line_length": 19.1769230769, "ext": "agda", "hexsha": "a038ce27028642f6c678c6aa0f0a747e8c3ce276", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z", "max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "isabella232/Lemmachine", "max_forks_repo_path": "vendor/stdlib/src/Relation/Unary.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "larrytheliquid/Lemmachine", "max_issues_repo_path": "vendor/stdlib/src/Relation/Unary.agda", "max_line_length": 72, "max_stars_count": 56, "max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "isabella232/Lemmachine", "max_stars_repo_path": "vendor/stdlib/src/Relation/Unary.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z", "num_tokens": 946, "size": 2493 }
module main where open import prelude open import defns open import lemmas BackTheorem : ∀ {D} {H H′ H″ : NavigationHistory(D)} {δ δ′} → (WellFormed(H)) → (H traverses-by (-ve δ) to H′) → (H′ traverses-by δ′ to H″) → (H traverses-by (-ve δ + δ′) to H″) BackTheorem {δ = zero} H∈WF (back nil ds∈CGB ds∈BT) H′-to-H″ = H′-to-H″ BackTheorem {D} {H} {._} {H″} {δ = succ δ} {δ′} H∈WF (back (d ∷ ds) (d∈CGB , ds∈CGB) d∷ds∈BT) H′-to-H″ = H-to-H″ where H₁ = (H traverse-from d ∵ d∈CGB) H′ = (H₁ traverses-from ds ∵ ds∈CGB) d∈BT : (d ∈ BackTarget(H)) d∈BT = BT-hd {H = H} d ds d∷ds∈BT ds∈BT₁ : (ds ∈ BackTarget*(H₁)) ds∈BT₁ = BT-tl {H = H} d d∈CGB ds d∷ds∈BT H₁∈WF : WellFormed(H₁) H₁∈WF = back-WF H d d∈CGB H∈WF d∈BT H₁-to-H″ : H₁ traverses-by (-ve δ + δ′) to H″ H₁-to-H″ = BackTheorem H₁∈WF (back ds ds∈CGB ds∈BT₁) H′-to-H″ Lemma : ∀ {H″} n → (H₁ traverses-by n to H″) → (H traverses-by pred n to H″) Lemma (succ zero) (fwd (e ∷ nil) e∷es∈FT₁) = H-to-H₀ where H₀ = (H₁ traverse-to e) e∈FT₁ : (e ∈ FwdTarget(H₁)) e∈FT₁ = FT-hd {H = H₁} e nil e∷es∈FT₁ H=H₀ : H ≣ H₀ H=H₀ = from-to d e d∈CGB H∈WF d∈BT e∈FT₁ H₀-to-H₀ : (H₀ traverses-by (-ve zero) to H₀) H₀-to-H₀ = back nil tt (BT-nil {H = H₀}) H-to-H₀ : H traverses-by (-ve zero) to H₀ H-to-H₀ = SUBST (λ ∙ → ∙ traverses-by (-ve zero) to H₀) H=H₀ H₀-to-H₀ Lemma (succ (succ n)) (fwd (e ∷ es) e∷es∈FT₁) = H-to-Hₙ where H₀ = (H₁ traverse-to e) Hₙ = (H₁ traverses-to (e ∷ es)) e∈FT₁ : (e ∈ FwdTarget(H₁)) e∈FT₁ = FT-hd {H = H₁} e es e∷es∈FT₁ es∈FT₀ : (es ∈ FwdTarget*(H₀)) es∈FT₀ = FT-tl {H = H₁} e es e∷es∈FT₁ H=H₀ : H ≣ H₀ H=H₀ = from-to d e d∈CGB H∈WF d∈BT e∈FT₁ H₀-to-Hₙ : H₀ traverses-by (succ n) to Hₙ H₀-to-Hₙ = fwd es es∈FT₀ H-to-Hₙ : H traverses-by (succ n) to Hₙ H-to-Hₙ = SUBST (λ ∙ → ∙ traverses-by succ n to Hₙ) H=H₀ H₀-to-Hₙ Lemma (-ve n) (back es es∈CGB es∈BT₁) = back (d ∷ es) (d∈CGB , es∈CGB) (BT-cons {H = H} d d∈CGB es d∈BT es∈BT₁) H-to-H″ : H traverses-by (-ve (succ δ) + δ′) to H″ H-to-H″ = Lemma (-ve δ + δ′) H₁-to-H″ FwdTheorem : ∀ {D} {H H′ H″ : NavigationHistory(D)} {δ δ′} → (WellFormed(H)) → (H traverses-by (succ δ) to H′) → (H′ traverses-by δ′ to H″) → (H traverses-by (succ δ + δ′) to H″) FwdTheorem {D} {H} {._} {H″} {δ = δ} {δ′} H∈WF (fwd (d ∷ ds) d∷ds∈FT) H′-to-H″ with Lemma where H₁ = (H traverse-to d) H′ = (H₁ traverses-to ds) d∈FT : (d ∈ FwdTarget(H)) d∈FT = FT-hd {H = H} d ds d∷ds∈FT Lemma : ∀ {H″} n → (H₁ traverses-by n to H″) → (H traverses-by sucz n to H″) Lemma (succ n) (fwd es es∈FT₁) = fwd (d ∷ es) (FT-cons {H = H} d es d∈FT es∈FT₁) Lemma (-ve zero) (back nil _ _) = fwd (d ∷ nil) (FT-cons {H = H} d nil d∈FT (FT-nil {H = H₁})) Lemma (-ve (succ n)) (back (e ∷ es) (e∈CGB , es∈CGB) e∷es∈BT₁) = H-to-Hₙ where H₀ = (H₁ traverse-from e ∵ e∈CGB) Hₙ = (H₁ traverses-from (e ∷ es) ∵ (e∈CGB , es∈CGB)) e∈BT₁ : (e ∈ BackTarget(H₁)) e∈BT₁ = BT-hd {H = H₁} e es e∷es∈BT₁ es∈BT₀ : (es ∈ BackTarget*(H₀)) es∈BT₀ = BT-tl {H = H₁} e e∈CGB es e∷es∈BT₁ H=H₀ : H ≣ H₀ H=H₀ = to-from d e e∈CGB H∈WF d∈FT e∈BT₁ H₀-to-Hₙ : H₀ traverses-by (-ve n) to Hₙ H₀-to-Hₙ = back es es∈CGB es∈BT₀ H-to-Hₙ : H traverses-by (-ve n) to Hₙ H-to-Hₙ = SUBST (λ ∙ → ∙ traverses-by (-ve n) to Hₙ) H=H₀ H₀-to-Hₙ FwdTheorem {D} {H} {._} {H″} {δ = zero} {δ′} H∈WF (fwd (d ∷ nil) d∷nil∈FT) H′-to-H″ | Lemma = Lemma δ′ H′-to-H″ FwdTheorem {D} {H} {._} {H″} {δ = succ δ} {δ′} H∈WF (fwd (d ∷ ds) d∷ds∈FT) H′-to-H″ | Lemma = H-to-H″ where H₁ = (H traverse-to d) d∈FT : (d ∈ FwdTarget(H)) d∈FT = FT-hd {H = H} d ds d∷ds∈FT ds∈FT₁ : (ds ∈ FwdTarget*(H₁)) ds∈FT₁ = FT-tl {H = H} d ds d∷ds∈FT H₁∈WF : WellFormed(H₁) H₁∈WF = fwd-WF H d H∈WF d∈FT H₁-to-H″ : H₁ traverses-by (succ δ + δ′) to H″ H₁-to-H″ = FwdTheorem H₁∈WF (fwd ds ds∈FT₁) H′-to-H″ H-to-H″ : H traverses-by sucz (succ δ + δ′) to H″ H-to-H″ = subst (λ ∙ → H traverses-by ∙ to H″) (succ-dist-+ (succ δ) δ′) (Lemma (succ δ + δ′) H₁-to-H″) Theorem : ∀ {D} {H H′ H″ : NavigationHistory(D)} {δ δ′} → (WellFormed(H)) → (H traverses-by δ to H′) → (H′ traverses-by δ′ to H″) → (H traverses-by (δ + δ′) to H″) Theorem {δ = succ δ} = FwdTheorem Theorem {δ = -ve δ} = BackTheorem
{ "alphanum_fraction": 0.5294251307, "avg_line_length": 30.3517241379, "ext": "agda", "hexsha": "d4ef38d1c2a6afbf9a1bc0ef7384aa62a45808b8", "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": "cea700aea1488df1d27092c8f3d79d5d99f7e09a", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "cbrewster/ServoNavigation", "max_forks_repo_path": "notes/main.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cea700aea1488df1d27092c8f3d79d5d99f7e09a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "cbrewster/ServoNavigation", "max_issues_repo_path": "notes/main.agda", "max_line_length": 118, "max_stars_count": 1, "max_stars_repo_head_hexsha": "cea700aea1488df1d27092c8f3d79d5d99f7e09a", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "cbrewster/ServoNavigation", "max_stars_repo_path": "notes/main.agda", "max_stars_repo_stars_event_max_datetime": "2017-04-22T01:51:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-22T01:51:07.000Z", "num_tokens": 2228, "size": 4401 }
{- This file contains: - Properties of 2-groupoid truncations -} {-# OPTIONS --cubical --safe #-} module Cubical.HITs.2GroupoidTruncation.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.HITs.2GroupoidTruncation.Base rec : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (gB : is2Groupoid B) → (A → B) → (∥ A ∥₂ → B) rec gB f ∣ x ∣₂ = f x rec gB f (squash₂ _ _ _ _ _ _ t u i j k l) = gB _ _ _ _ _ _ (λ m n o → rec gB f (t m n o)) (λ m n o → rec gB f (u m n o)) i j k l elim : ∀ {ℓ ℓ'} {A : Type ℓ} {B : ∥ A ∥₂ → Type ℓ'} (bG : (x : ∥ A ∥₂) → is2Groupoid (B x)) (f : (x : A) → B ∣ x ∣₂) (x : ∥ A ∥₂) → B x elim bG f ∣ x ∣₂ = f x elim bG f (squash₂ x y p q r s u v i j k l) = isOfHLevel→isOfHLevelDep 4 bG _ _ _ _ _ _ (λ j k l → elim bG f (u j k l)) (λ j k l → elim bG f (v j k l)) (squash₂ x y p q r s u v) i j k l
{ "alphanum_fraction": 0.5605726872, "avg_line_length": 28.375, "ext": "agda", "hexsha": "190a8b08c18057bc19ad165caaa8271841808363", "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": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/HITs/2GroupoidTruncation/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "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": "borsiemir/cubical", "max_issues_repo_path": "Cubical/HITs/2GroupoidTruncation/Properties.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/HITs/2GroupoidTruncation/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 409, "size": 908 }
------------------------------------------------------------------------ -- The structure identity principle can be used to establish that -- isomorphism coincides with equality (assuming univalence) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Univalence-axiom.Isomorphism-is-equality.Structure-identity-principle {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open import Bijection eq using (_↔_) open import Category eq open Derived-definitions-and-properties eq open import Equivalence eq as Eq using (_≃_) open import Function-universe eq renaming (_∘_ to _⊚_) open import H-level eq open import H-level.Closure eq open import Logical-equivalence using (_⇔_) open import Prelude as P open import Structure-identity-principle eq open import Univalence-axiom eq open import Univalence-axiom.Isomorphism-is-equality.Simple eq using (Assumptions; module Assumptions; Universe; module Universe; module Class) -- The structure identity principle can be used to prove a slightly -- restricted variant of isomorphism-is-equality (which is defined in -- Univalence-axiom.Isomorphism-is-equality.Simple.Class). isomorphism-is-equality′ : (Univ : Universe) → let open Universe Univ in Assumptions → ∀ c X Y → (∀ {B} → Is-set B → Is-set (El (proj₁ c) B)) → -- Extra assumption. Is-set (proj₁ X) → Is-set (proj₁ Y) → -- Extra assumptions. Class.Isomorphic Univ c X Y ↔ (X ≡ Y) isomorphism-is-equality′ Univ ass (a , P) (C , x , p) (D , y , q) El-set C-set D-set = isomorphic module Isomorphism-is-equality′ where open Assumptions ass open Universe Univ open Class Univ using (Carrier; Instance; Isomorphic) -- The category of sets and functions. Fun : Category (# 2) (# 1) Fun = category-Set (# 1) ext (λ _ _ → univ₁) module Fun = Category Fun -- The category of sets and bijections. Bij : Category (# 2) (# 1) Bij = category-Set-≅ (# 1) ext (λ _ _ → univ₁) module Bij = Category Bij -- If two sets are isomorphic, then the underlying types are -- equivalent. ≅⇒≃ : (C D : Fun.Obj) → C Fun.≅ D → ⌞ C ⌟ ≃ ⌞ D ⌟ ≅⇒≃ C D = _≃_.from (≃≃≅-Set (# 1) ext C D) -- The "standard notion of structure" that the structure identity -- principle is instantiated with. S : Standard-notion-of-structure (# 1) (# 1) Bij.precategory S = record { P = El a ∘ ⌞_⌟ ; H = λ {C D} x y C≅D → Is-isomorphism a (≅⇒≃ C D C≅D) x y ; H-prop = λ {C D} → H-prop′ C D ; H-id = λ {C} → H-id′ C ; H-∘ = λ {B C D} → H-∘′ B C D ; H-antisymmetric = λ {C} → H-antisymmetric′ C } where module Separate-abstract-block where abstract H-prop′ : (C D : Set (# 1)) {x : El a ⌞ C ⌟} {y : El a ⌞ D ⌟} (f : Bij.Hom C D) → Is-proposition (Is-isomorphism a (≅⇒≃ C D f) x y) H-prop′ _ D _ = El-set (proj₂ D) H-id′ : (C : Set (# 1)) {x : El a ⌞ C ⌟} → Is-isomorphism a (≅⇒≃ C C (Bij.id {X = C})) x x H-id′ C {x} = resp a (≅⇒≃ C C (Bij.id {X = C})) x ≡⟨ cong (λ eq → resp a eq x) $ Eq.lift-equality ext (refl _) ⟩ resp a Eq.id x ≡⟨ resp-id ass a x ⟩∎ x ∎ H-∘′ : (B C D : Set (# 1)) {x : El a ⌞ B ⌟} {y : El a ⌞ C ⌟} {z : El a ⌞ D ⌟} {B≅C : Bij.Hom B C} {C≅D : Bij.Hom C D} → Is-isomorphism a (≅⇒≃ B C B≅C) x y → Is-isomorphism a (≅⇒≃ C D C≅D) y z → Is-isomorphism a (≅⇒≃ B D (Bij._∙_ {X = B} {Y = C} {Z = D} C≅D B≅C)) x z H-∘′ B C D {x} {y} {z} {B≅C} {C≅D} x≅y y≅z = resp a (≅⇒≃ B D (C≅D Bij.∙ B≅C)) x ≡⟨ cong (λ eq → resp a eq x) $ Eq.lift-equality ext (refl _) ⟩ resp a (≅⇒≃ C D C≅D ⊚ ≅⇒≃ B C B≅C) x ≡⟨ resp-preserves-compositions (El a) (resp a) (resp-id ass a) univ₁ ext (≅⇒≃ B C B≅C) (≅⇒≃ C D C≅D) x ⟩ resp a (≅⇒≃ C D C≅D) (resp a (≅⇒≃ B C B≅C) x) ≡⟨ cong (resp a (≅⇒≃ C D C≅D)) x≅y ⟩ resp a (≅⇒≃ C D C≅D) y ≡⟨ y≅z ⟩∎ z ∎ H-antisymmetric′ : (C : Set (# 1)) (x y : El a ⌞ C ⌟) → Is-isomorphism a (≅⇒≃ C C (Bij.id {X = C})) x y → Is-isomorphism a (≅⇒≃ C C (Bij.id {X = C})) y x → x ≡ y H-antisymmetric′ C x y x≡y _ = x ≡⟨ sym $ resp-id ass a x ⟩ resp a Eq.id x ≡⟨ cong (λ eq → resp a eq x) $ Eq.lift-equality ext (refl _) ⟩ resp a (≅⇒≃ C C (Bij.id {X = C})) x ≡⟨ x≡y ⟩∎ y ∎ open Separate-abstract-block open module S = Standard-notion-of-structure S using (H; Str; module Str) abstract -- Every Str morphism is an isomorphism. Str-homs-are-isos : ∀ {C D x y} (f : ∃ (H {X = C} {Y = D} x y)) → Str.Is-isomorphism {X = C , x} {Y = D , y} f Str-homs-are-isos {C} {D} {x} {y} (C≅D , x≅y) = (D≅C , (resp a (≅⇒≃ D C D≅C) y ≡⟨ cong (λ eq → resp a eq y) $ Eq.lift-equality ext (refl _) ⟩ resp a (inverse $ ≅⇒≃ C D C≅D) y ≡⟨ resp-preserves-inverses (El a) (resp a) (resp-id ass a) univ₁ ext (≅⇒≃ C D C≅D) _ _ x≅y ⟩∎ x ∎)) , S.lift-equality {X = D , y} {Y = D , y} ( C≅D Fun.∙≅ D≅C ≡⟨ _≃_.from (Fun.≡≃≡¹ {X = D} {Y = D}) (Fun._¹⁻¹ {X = C} {Y = D} C≅D) ⟩∎ Fun.id≅ {X = D} ∎) , S.lift-equality {X = C , x} {Y = C , x} ( D≅C Fun.∙≅ C≅D ≡⟨ _≃_.from (Fun.≡≃≡¹ {X = C} {Y = C}) (Fun._⁻¹¹ {X = C} {Y = D} C≅D) ⟩∎ Fun.id≅ {X = C} ∎) where D≅C : D Fun.≅ C D≅C = Fun._⁻¹≅ {X = C} {Y = D} C≅D -- The isomorphism that should be constructed. isomorphic : Isomorphic (a , P) (C , x , p) (D , y , q) ↔ _≡_ {A = Instance (a , P)} (C , x , p) (D , y , q) isomorphic = Σ (C ≃ D) (λ eq → Is-isomorphism a eq x y) ↝⟨ (let ≃≃≅-CD = ≃≃≅-Set (# 1) ext (C , C-set) (D , D-set) in Σ-cong ≃≃≅-CD (λ eq → let eq′ = _≃_.from ≃≃≅-CD (_≃_.to ≃≃≅-CD eq) in Is-isomorphism a eq x y ↝⟨ ≡⇒↝ _ $ cong (λ eq → Is-isomorphism a eq x y) $ sym $ _≃_.left-inverse-of ≃≃≅-CD eq ⟩ Is-isomorphism a eq′ x y □)) ⟩ ∃ (H {X = C , C-set} {Y = D , D-set} x y) ↝⟨ inverse ×-right-identity ⟩ ∃ (H {X = C , C-set} {Y = D , D-set} x y) × ⊤ ↝⟨ ∃-cong (λ X≅Y → inverse $ _⇔_.to contractible⇔↔⊤ $ propositional⇒inhabited⇒contractible (Str.Is-isomorphism-propositional X≅Y) (Str-homs-are-isos X≅Y)) ⟩ (((C , C-set) , x) Str.≅ ((D , D-set) , y)) ↔⟨ inverse Eq.⟨ _ , structure-identity-principle ext Bij S {X = (C , C-set) , x} {Y = (D , D-set) , y} ⟩ ⟩ (((C , λ {_ _} → C-set) , x) ≡ ((D , λ {_ _} → D-set) , y)) ↔⟨ Eq.≃-≡ $ Eq.↔⇒≃ (Σ-assoc ⊚ ∃-cong (λ _ → ×-comm) ⊚ inverse Σ-assoc) ⟩ (((C , x) , λ {_ _} → C-set) ≡ ((D , y) , λ {_ _} → D-set)) ↝⟨ inverse $ ignore-propositional-component (H-level-propositional ext 2) ⟩ ((C , x) ≡ (D , y)) ↝⟨ ignore-propositional-component (proj₂ (P D y) ass) ⟩ (((C , x) , p) ≡ ((D , y) , q)) ↔⟨ Eq.≃-≡ $ Eq.↔⇒≃ Σ-assoc ⟩□ ((C , x , p) ≡ (D , y , q)) □ -- A simplification lemma. proj₁-from-isomorphic : ∀ X≡Y → proj₁ (_↔_.from isomorphic X≡Y) ≡ elim (λ {X Y} _ → proj₁ X ≃ proj₁ Y) (λ _ → Eq.id) X≡Y proj₁-from-isomorphic X≡Y = Eq.lift-equality ext ( _≃_.to (proj₁ (_↔_.from isomorphic X≡Y)) ≡⟨⟩ cast C-set D-set X≡Y ≡⟨ lemma ⟩∎ _≃_.to (elim (λ {X Y} _ → proj₁ X ≃ proj₁ Y) (λ _ → Eq.id) X≡Y) ∎) where cast : ∀ {X Y} → Is-set (Carrier (a , P) X) → Is-set (Carrier (a , P) Y) → X ≡ Y → Carrier (a , P) X → Carrier (a , P) Y cast {C , x , p} {D , y , q} C-set D-set X≡Y = proj₁ $ proj₁ $ proj₁ $ Str.≡→≅ {X = (C , C-set) , x} {Y = (D , D-set) , y} $ cong (λ { ((C , x) , C-set) → (C , C-set) , x }) $ Σ-≡,≡→≡ (proj₁ (Σ-≡,≡←≡ (cong (λ { (C , (x , p)) → (C , x) , p }) X≡Y))) (proj₁ (+⇒≡ $ H-level-propositional ext 2)) lemma : cast C-set D-set X≡Y ≡ _≃_.to (elim (λ {X Y} _ → proj₁ X ≃ proj₁ Y) (λ _ → Eq.id) X≡Y) lemma = elim¹ (λ X≡Y → (D-set : Is-set _) → cast C-set D-set X≡Y ≡ _≃_.to (elim (λ {X Y} _ → proj₁ X ≃ proj₁ Y) (λ _ → Eq.id) X≡Y)) (λ C-set′ → cast C-set C-set′ (refl (C , x , p)) ≡⟨ cong (λ eq → proj₁ $ proj₁ $ proj₁ $ Str.≡→≅ {X = (C , C-set) , x} {Y = (C , C-set′) , x} $ cong (λ { ((C , x) , C-set) → (C , C-set) , x }) $ Σ-≡,≡→≡ (proj₁ (Σ-≡,≡←≡ {B = proj₁ ∘ uncurry P} eq)) (proj₁ (+⇒≡ $ H-level-propositional ext 2))) (cong-refl (λ { (C , (x , p)) → (C , x) , p })) ⟩ (proj₁ $ proj₁ $ proj₁ $ Str.≡→≅ {X = (C , C-set) , x} {Y = (C , C-set′) , x} $ cong (λ { ((C , x) , C-set) → (C , C-set) , x }) $ Σ-≡,≡→≡ (proj₁ (Σ-≡,≡←≡ (refl ((C , x) , p)))) (proj₁ (+⇒≡ $ H-level-propositional ext 2))) ≡⟨ cong proj₁ (S.proj₁-≡→≅-¹ _) ⟩ (proj₁ $ Fun.≡→≅ $ cong proj₁ $ cong (λ { ((C , x) , C-set) → (C , C-set) , x }) $ Σ-≡,≡→≡ (proj₁ (Σ-≡,≡←≡ (refl ((C , x) , p)))) (proj₁ (+⇒≡ $ H-level-propositional ext 2))) ≡⟨ cong (proj₁ ∘ Fun.≡→≅) $ cong-∘ proj₁ (λ { ((C , x) , C-set) → (C , C-set) , x }) _ ⟩ (proj₁ $ Fun.≡→≅ $ cong (λ { ((C , _) , C-set) → C , C-set }) $ Σ-≡,≡→≡ (proj₁ (Σ-≡,≡←≡ (refl ((C , x) , p)))) (proj₁ (+⇒≡ $ H-level-propositional ext 2))) ≡⟨ Fun.≡→≅-¹ _ ⟩ (elim (λ {X Y} _ → Fun.Hom X Y) (λ _ → P.id) $ cong (λ { ((C , _) , C-set) → C , C-set }) $ Σ-≡,≡→≡ (proj₁ (Σ-≡,≡←≡ (refl ((C , x) , p)))) (proj₁ (+⇒≡ $ H-level-propositional ext 2))) ≡⟨ elim¹ (λ eq → elim (λ {X Y} _ → Fun.Hom X Y) (λ _ → P.id) eq ≡ ≡⇒↝ implication (cong proj₁ eq)) ( elim (λ {X Y} _ → Fun.Hom X Y) (λ _ → P.id) (refl (C , λ {_ _} → C-set)) ≡⟨ elim-refl (λ {X Y} _ → Fun.Hom X Y) _ ⟩ P.id ≡⟨ sym $ elim-refl (λ {A B} _ → A → B) _ ⟩ ≡⇒↝ implication (refl C) ≡⟨ cong (≡⇒↝ implication) (sym $ cong-refl proj₁) ⟩∎ ≡⇒↝ implication (cong proj₁ (refl (C , λ {_ _} → C-set))) ∎) _ ⟩ (≡⇒↝ implication $ cong proj₁ $ cong (λ { ((C , _) , C-set) → C , C-set }) $ Σ-≡,≡→≡ (proj₁ (Σ-≡,≡←≡ (refl ((C , x) , p)))) (proj₁ (+⇒≡ $ H-level-propositional ext 2))) ≡⟨ cong (≡⇒↝ implication) (cong-∘ proj₁ (λ { ((C , _) , C-set) → C , C-set }) _) ⟩ (≡⇒↝ implication $ cong (λ { ((C , _) , _) → C }) $ Σ-≡,≡→≡ (proj₁ (Σ-≡,≡←≡ (refl ((C , x) , p)))) (proj₁ (+⇒≡ $ H-level-propositional ext 2))) ≡⟨ cong (λ (eq : ∃ λ q → subst (proj₁ ∘ uncurry P) q p ≡ p) → ≡⇒↝ implication $ cong (λ { ((C , _) , _) → C }) $ Σ-≡,≡→≡ (proj₁ eq) (proj₁ (+⇒≡ $ H-level-propositional ext 2))) (Σ-≡,≡←≡-refl {B = λ { (C , x) → proj₁ (P C x)}}) ⟩ (≡⇒↝ implication $ cong (λ { ((C , _) , _) → C }) $ Σ-≡,≡→≡ (refl (C , x)) (proj₁ (+⇒≡ $ H-level-propositional ext 2))) ≡⟨ cong (≡⇒↝ implication ∘ cong (λ { ((C , _) , _) → C })) (Σ-≡,≡→≡-reflˡ (proj₁ (+⇒≡ $ H-level-propositional ext 2))) ⟩ (≡⇒↝ implication $ cong (λ { ((C , _) , _) → C }) $ cong (_,_ (C , x)) (trans (sym $ subst-refl (Is-set ∘ proj₁) C-set) (proj₁ (+⇒≡ $ H-level-propositional ext 2)))) ≡⟨ cong (≡⇒↝ implication) (cong-∘ (λ { ((C , _) , _) → C }) (_,_ (C , x)) _) ⟩ (≡⇒↝ implication $ cong (const C) (trans (sym $ subst-refl (Is-set ∘ proj₁) C-set) (proj₁ (+⇒≡ $ H-level-propositional ext 2)))) ≡⟨ cong (≡⇒↝ implication) (cong-const _) ⟩ ≡⇒↝ implication (refl C) ≡⟨ ≡⇒↝-refl ⟩ P.id ≡⟨ sym $ cong _≃_.to $ elim-refl (λ {X Y} _ → proj₁ X ≃ proj₁ Y) _ ⟩∎ _≃_.to (elim (λ {X Y} _ → proj₁ X ≃ proj₁ Y) (λ _ → Eq.id) (refl (C , x , p))) ∎) X≡Y D-set abstract -- The from component of isomorphism-is-equality′ is equal -- to a simple function. from-isomorphism-is-equality′ : ∀ Univ ass c X Y → let open Universe Univ; open Class Univ in (El-set : ∀ {B} → Is-set B → Is-set (El (proj₁ c) B)) → (X-set : Is-set (proj₁ X)) (Y-set : Is-set (proj₁ Y)) → _↔_.from (isomorphism-is-equality′ Univ ass c X Y El-set X-set Y-set) ≡ elim (λ {X Y} _ → Isomorphic c X Y) (λ { (_ , x , _) → Eq.id , resp-id ass (proj₁ c) x }) from-isomorphism-is-equality′ Univ ass c X Y El-set X-set Y-set = apply-ext ext λ eq → Σ-≡,≡→≡ (lemma eq) (El-set Y-set _ _) where open Assumptions ass open Universe Univ open Class Univ lemma : ∀ eq → proj₁ (_↔_.from (isomorphism-is-equality′ Univ ass c X Y El-set X-set Y-set) eq) ≡ proj₁ (elim (λ {X Y} _ → Isomorphic c X Y) (λ { (_ , x , _) → Eq.id , resp-id ass (proj₁ c) x }) eq) lemma eq = proj₁ (_↔_.from (isomorphism-is-equality′ Univ ass c X Y El-set X-set Y-set) eq) ≡⟨ Isomorphism-is-equality′.proj₁-from-isomorphic Univ ass _ _ _ _ _ _ _ _ El-set X-set Y-set eq ⟩ elim (λ {X Y} _ → proj₁ X ≃ proj₁ Y) (λ _ → Eq.id) eq ≡⟨ sym $ elim-∘ (λ {X Y} _ → Isomorphic c X Y) _ proj₁ _ ⟩∎ proj₁ (elim (λ {X Y} _ → Isomorphic c X Y) (λ { (_ , x , _) → Eq.id , resp-id ass (proj₁ c) x }) eq) ∎
{ "alphanum_fraction": 0.3659120084, "avg_line_length": 50.4058823529, "ext": "agda", "hexsha": "8cdf6412d1327248838c87144a81e0fbf2ea67ee", "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/Univalence-axiom/Isomorphism-is-equality/Structure-identity-principle.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/Univalence-axiom/Isomorphism-is-equality/Structure-identity-principle.agda", "max_line_length": 147, "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/Univalence-axiom/Isomorphism-is-equality/Structure-identity-principle.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": 5878, "size": 17138 }
module Thesis.Contexts where open import Thesis.Types -- Instantiate generic Context support open import Base.Syntax.Context Type public
{ "alphanum_fraction": 0.8273381295, "avg_line_length": 19.8571428571, "ext": "agda", "hexsha": "45cec0fa34777b904f333420d2c825d05e4810e0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z", "max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "inc-lc/ilc-agda", "max_forks_repo_path": "Thesis/Contexts.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z", "max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "inc-lc/ilc-agda", "max_issues_repo_path": "Thesis/Contexts.agda", "max_line_length": 43, "max_stars_count": 10, "max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "inc-lc/ilc-agda", "max_stars_repo_path": "Thesis/Contexts.agda", "max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z", "num_tokens": 25, "size": 139 }
-- {-# OPTIONS -v tc.meta:30 #-} {-# OPTIONS --sized-types #-} module GiveSize where postulate Size : Set postulate ∞ : Size {-# BUILTIN SIZE Size #-} -- {-# BUILTIN SIZEINF ∞ #-} id : Size → Size id i = {!i!}
{ "alphanum_fraction": 0.5849056604, "avg_line_length": 17.6666666667, "ext": "agda", "hexsha": "9a0fd484e6058e3f6213c55224f5111028ee577b", "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": "test/interaction/GiveSize.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/interaction/GiveSize.agda", "max_line_length": 32, "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": "test/interaction/GiveSize.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": 65, "size": 212 }
module par-swap.union-properties where open import par-swap open import par-swap.union-confluent open import par-swap.confluent open import sn-calculus open import sn-calculus-props open import Esterel.Lang open import Esterel.Lang.Binding open import Esterel.Lang.Properties open import Esterel.Context open import Esterel.Context.Properties open import Esterel.Environment as Env using (Env ; Θ ; _←_ ; sig ; []env ; VarList ; module SigMap ; module ShrMap ; module VarMap) open import Data.List using ([] ; [_] ; _∷_ ; List ; _++_) open import Data.Product open import Data.Empty open import Relation.Binary.PropositionalEquality using (_≡_ ; refl ; cong ; sym) open import binding-preserve ∥R∪sn≡ₑ-preserve-cb : ∀ {p BVp FVp q} -> CorrectBinding p BVp FVp -> p ∥R∪sn≡ₑ q -> Σ (VarList × VarList) λ { (BVq , FVq) -> CorrectBinding q BVq FVq } ∥R∪sn≡ₑ-preserve-cb CBp (∪stpsn psn⟶q) with sn⟶-maintains-binding CBp psn⟶q ... | _ , CBq , _ = _ , CBq ∥R∪sn≡ₑ-preserve-cb CBp (∪stp∥ p∥Rq) with ∥R-maintains-binding CBp p∥Rq ... | CBq = _ , CBq ∥R∪sn≡ₑ-preserve-cb CBp (∪sym p∪≡ₑq CBq) = _ , CBq ∥R∪sn≡ₑ-preserve-cb CBp ∪ref = _ , CBp ∥R∪sn≡ₑ-preserve-cb CBp (∪trn p∪≡ₑr r∪≡ₑq) with ∥R∪sn≡ₑ-preserve-cb CBp p∪≡ₑr ... | _ , CBr = ∥R∪sn≡ₑ-preserve-cb CBr r∪≡ₑq ∥R∪sn≡ₑ-consistent : ∀{p q BV FV} → CorrectBinding p BV FV → p ∥R∪sn≡ₑ q → Σ[ r ∈ Term ] (p ∥R*∪sn⟶* r) × (q ∥R*∪sn⟶* r) ∥R∪sn≡ₑ-consistent CBp (∪stpsn psn⟶q) = _ , ∪sn⟶* (rstep psn⟶q rrefl) ∪refl , ∪refl ∥R∪sn≡ₑ-consistent CBp (∪stp∥ ps∥Rq) = _ , ∪∥R* (∥Rn ps∥Rq ∥R0) ∪refl , ∪refl ∥R∪sn≡ₑ-consistent CBp (∪sym psn∪∥R≡ₑq CBq) with ∥R∪sn≡ₑ-consistent CBq psn∪∥R≡ₑq ... | _ , a , b = _ , b , a ∥R∪sn≡ₑ-consistent CBp ∪ref = _ , ∪refl , ∪refl ∥R∪sn≡ₑ-consistent{p}{q} CBp (∪trn{.p}{r}{.q} p≡r r≡q) with ∥R∪sn≡ₑ-preserve-cb CBp p≡r ... | ((BVr , FVr) , CBr) with ∥R∪sn≡ₑ-preserve-cb CBr r≡q ... | ((BVq , FVq) , CBq) with ∥R∪sn≡ₑ-consistent CBp p≡r ... | (y , p⟶y , r⟶y) with ∥R∪sn≡ₑ-consistent CBr r≡q ... | (z , r⟶z , q⟶z) with ∥R*∪sn⟶*-confluent CBr r⟶y r⟶z ... | (x , y⟶x , z⟶x) = x , ∥R*∪sn⟶*-concat p⟶y y⟶x , ∥R*∪sn⟶*-concat q⟶z z⟶x inescapability-of-complete-∥R : ∀ {p q} -> complete p -> p ∥R q -> complete q inescapability-of-complete-∥R = \ { completep (∥Rstep dc) -> thm completep dc } where thm-p : ∀ {p C p₁ p₂} -> paused p -> p ≐ C ⟦ p₁ ∥ p₂ ⟧c -> paused (C ⟦ p₂ ∥ p₁ ⟧c) thm-p ppause () thm-p (pseq paused₁) (dcseq₁ pC) = pseq (thm-p paused₁ pC) thm-p (pseq paused₁) (dcseq₂ pC) = pseq paused₁ thm-p (ploopˢ paused₁) (dcloopˢ₁ pC) = ploopˢ (thm-p paused₁ pC) thm-p (ploopˢ paused₁) (dcloopˢ₂ pC) = ploopˢ paused₁ thm-p (ppar paused₁ paused₂) dchole = ppar paused₂ paused₁ thm-p (ppar paused₁ paused₂) (dcpar₁ pC) = ppar (thm-p paused₁ pC) paused₂ thm-p (ppar paused₁ paused₂) (dcpar₂ pC) = ppar paused₁ (thm-p paused₂ pC) thm-p (psuspend paused₁) (dcsuspend pC) = psuspend (thm-p paused₁ pC) thm-p (ptrap paused₁) (dctrap pC) = ptrap (thm-p paused₁ pC) thm-d : ∀ {p C p₁ p₂} -> done p -> p ≐ C ⟦ p₁ ∥ p₂ ⟧c -> done (C ⟦ p₂ ∥ p₁ ⟧c) thm-d (dhalted hnothin) () thm-d (dhalted (hexit n)) () thm-d (dpaused p/paused) pC = dpaused (thm-p p/paused pC) thm : ∀ {p C p₁ p₂} -> complete p -> p ≐ C ⟦ p₁ ∥ p₂ ⟧c -> complete (C ⟦ p₂ ∥ p₁ ⟧c) thm (codone x) pC = codone (thm-d x pC) thm (coenv x x₁) (dcenv pC) = coenv x (thm-d x₁ pC) inescapability-of-complete-∥R* : ∀ {p q} -> complete p -> p ∥R* q -> complete q inescapability-of-complete-∥R* = thm where thm : ∀ {p q} -> complete p -> p ∥R* q -> complete q thm completep ∥R0 = completep thm completep (∥Rn p∥Rr r⟶q) = thm (inescapability-of-complete-∥R completep p∥Rr) r⟶q inescapability-of-complete-∪ : ∀ {p q} -> complete p -> p ∥R*∪sn⟶* q -> complete q inescapability-of-complete-∪ = thm where thm : ∀ {p q} -> complete p -> p ∥R*∪sn⟶* q -> complete q thm completep (∪∥R* p∥R*r r⟶q) = thm (inescapability-of-complete-∥R* completep p∥R*r) r⟶q thm completep (∪sn⟶* psn⟶*r r⟶q) = thm (inescapability-of-complete-sn completep psn⟶*r) r⟶q thm completep ∪refl = completep ρ-stays-ρ-∪ : ∀{θ p q A} → (ρ⟨ θ , A ⟩· p) ∥R*∪sn⟶* q → Σ[ θ' ∈ Env.Env ] Σ[ A' ∈ Ctrl ] Σ[ qin ∈ Term ] q ≡ (ρ⟨ θ' , A' ⟩· qin) ρ-stays-ρ-∪ = thm where thm∥R : ∀{θ p q A} → (ρ⟨ θ , A ⟩· p) ∥R q → Σ[ θ' ∈ Env.Env ] Σ[ A ∈ Ctrl ] Σ[ qin ∈ Term ] q ≡ (ρ⟨ θ' , A ⟩· qin) thm∥R (∥Rstep (dcenv d≐C⟦p∥q⟧c)) rewrite sym (unplugc d≐C⟦p∥q⟧c) = _ , _ , _ , refl thm∥R* : ∀{θ p q A} → (ρ⟨ θ , A ⟩· p) ∥R* q → Σ[ θ' ∈ Env.Env ] Σ[ A' ∈ Ctrl ] Σ[ qin ∈ Term ] q ≡ (ρ⟨ θ' , A' ⟩· qin) thm∥R* ∥R0 = _ , _ , _ , refl thm∥R* (∥Rn p∥Rq p⟶q) with thm∥R p∥Rq ... | (θ' , qin , A' , refl) = thm∥R* p⟶q thm : ∀{θ p q A} → (ρ⟨ θ , A ⟩· p) ∥R*∪sn⟶* q → Σ[ θ' ∈ Env.Env ] Σ[ A' ∈ Ctrl ] Σ[ qin ∈ Term ] q ≡ (ρ⟨ θ' , A' ⟩· qin) thm (∪∥R* p∥R*q p⟶q) with thm∥R* p∥R*q ... | (θ' , qin , A' , refl) = thm p⟶q thm (∪sn⟶* psn⟶*q p⟶q) with ρ-stays-ρ-sn⟶* psn⟶*q ... | (θ' , qin , A' , refl) = thm p⟶q thm ∪refl = _ , _ , _ , refl irreducibility-of-halted-∥R : ∀ {p q} -> halted p -> p ∥R q -> ⊥ irreducibility-of-halted-∥R hnothin (∥Rstep ()) irreducibility-of-halted-∥R (hexit n) (∥Rstep ()) inescapability-of-paused-∥R : ∀ {p q} -> paused p -> p ∥R q -> paused q inescapability-of-paused-∥R ppause (∥Rstep ()) inescapability-of-paused-∥R (pseq pausedp) (∥Rstep (dcseq₁ dc)) = pseq (inescapability-of-paused-∥R pausedp (∥Rstep dc)) inescapability-of-paused-∥R (pseq pausedp) (∥Rstep (dcseq₂ dc)) = pseq pausedp inescapability-of-paused-∥R (ploopˢ pausedp) (∥Rstep (dcloopˢ₁ dc)) = ploopˢ (inescapability-of-paused-∥R pausedp (∥Rstep dc)) inescapability-of-paused-∥R (ploopˢ pausedp) (∥Rstep (dcloopˢ₂ dc)) = ploopˢ pausedp inescapability-of-paused-∥R (ppar pausedp pausedq) (∥Rstep dchole) = ppar pausedq pausedp inescapability-of-paused-∥R (ppar pausedp pausedq) (∥Rstep (dcpar₁ dc)) = ppar (inescapability-of-paused-∥R pausedp (∥Rstep dc)) pausedq inescapability-of-paused-∥R (ppar pausedp pausedq) (∥Rstep (dcpar₂ dc)) = ppar pausedp (inescapability-of-paused-∥R pausedq (∥Rstep dc)) inescapability-of-paused-∥R (psuspend pausedp) (∥Rstep (dcsuspend dc)) = psuspend (inescapability-of-paused-∥R pausedp (∥Rstep dc)) inescapability-of-paused-∥R (ptrap pausedp) (∥Rstep (dctrap dc)) = ptrap (inescapability-of-paused-∥R pausedp (∥Rstep dc)) inescapability-of-paused-∥R* : ∀ {p q} -> paused p -> p ∥R* q -> paused q inescapability-of-paused-∥R* pausedp ∥R0 = pausedp inescapability-of-paused-∥R* pausedp (∥Rn p∥Rq p⟶q) = inescapability-of-paused-∥R* (inescapability-of-paused-∥R pausedp p∥Rq) p⟶q equality-of-complete-∪ : ∀{θ θ' p q A A'} → complete (ρ⟨ θ , A ⟩· p) → (ρ⟨ θ , A ⟩· p) ∥R*∪sn⟶* (ρ⟨ θ' , A' ⟩· q) → θ ≡ θ' × A ≡ A' equality-of-complete-∪ = thm where done-not-to-ρ-∪ : ∀ {p θ q A} -> done p -> p ∥R*∪sn⟶* (ρ⟨ θ , A ⟩· q) -> ⊥ done-not-to-ρ-∪ (dhalted p/halted) (∪∥R* ∥R0 p⟶q) = done-not-to-ρ-∪ (dhalted p/halted) p⟶q done-not-to-ρ-∪ (dhalted p/halted) (∪∥R* (∥Rn p∥Rq p∥R*q) p⟶q) = irreducibility-of-halted-∥R p/halted p∥Rq done-not-to-ρ-∪ (dpaused p/paused) (∪∥R* p∥R*q p⟶q) = done-not-to-ρ-∪ (dpaused (inescapability-of-paused-∥R* p/paused p∥R*q)) p⟶q done-not-to-ρ-∪ (dhalted p/halted) (∪sn⟶* rrefl r⟶q) = done-not-to-ρ-∪ (dhalted p/halted) r⟶q done-not-to-ρ-∪ (dhalted p/halted) (∪sn⟶* (rstep psn⟶q p⟶r) r⟶q) = irreducibility-of-halted-sn⟶ p/halted psn⟶q done-not-to-ρ-∪ (dpaused p/paused) (∪sn⟶* p⟶r r⟶q) = done-not-to-ρ-∪ (dpaused (inescapability-of-paused-sn⟶* p/paused p⟶r)) r⟶q done-not-to-ρ-∪ (dhalted ()) ∪refl done-not-to-ρ-∪ (dpaused ()) ∪refl ∥R*-lemma : ∀ {θ p q A} -> done p -> (ρ⟨ θ , A ⟩· p) ∥R* q -> Σ[ q' ∈ Term ] q ≡ (ρ⟨ θ , A ⟩· q') × done q' ∥R*-lemma done₁ ∥R0 = _ , refl , done₁ ∥R*-lemma (dhalted hnothin) (∥Rn (∥Rstep (dcenv ())) p⟶q) ∥R*-lemma (dhalted (hexit n)) (∥Rn (∥Rstep (dcenv ())) p⟶q) ∥R*-lemma (dpaused p/paused) (∥Rn (∥Rstep (dcenv d≐C⟦p∥q⟧c)) p⟶q) with inescapability-of-paused-∥R p/paused (∥Rstep d≐C⟦p∥q⟧c) ... | q/paused = ∥R*-lemma (dpaused q/paused) p⟶q thm : ∀{θ θ' p q A A'} → complete (ρ⟨ θ , A ⟩· p) → (ρ⟨ θ , A ⟩· p) ∥R*∪sn⟶* (ρ⟨ θ' , A' ⟩· q) → θ ≡ θ' × A ≡ A' thm (codone x) p⟶q = ⊥-elim (done-not-to-ρ-∪ x p⟶q) thm (coenv complete-θθ donep) (∪∥R* p∥R*q p⟶q) with ∥R*-lemma donep p∥R*q ... | _ , refl , doneq' = thm (coenv complete-θθ doneq') p⟶q thm (coenv complete-θθ donep) (∪sn⟶* psn⟶*r r⟶q) with inescapability-of-complete-sn (coenv complete-θθ donep) psn⟶*r thm (coenv complete-θθ donep) (∪sn⟶* psn⟶*r r⟶q) | codone x = ⊥-elim (done-not-to-ρ-∪ x r⟶q) thm (coenv complete-θθ donep) (∪sn⟶* psn⟶*r r⟶q) | coenv x x₁ with equality-of-complete-sn⟶* (coenv complete-θθ donep) psn⟶*r ... | refl , refl = thm (coenv x x₁) r⟶q thm (coenv complete-θθ donep) ∪refl = refl , refl
{ "alphanum_fraction": 0.5876793061, "avg_line_length": 35.405511811, "ext": "agda", "hexsha": "a9b30b14e30a657cc2f8cd6c175576f454e92d7b", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/par-swap/union-properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/par-swap/union-properties.agda", "max_line_length": 80, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/par-swap/union-properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 4519, "size": 8993 }
{-# OPTIONS --injective-type-constructors #-} module InjectiveTypeConstructors where data D (A : Set) : Set where data _==_ (A : Set) : Set → Set where refl : A == A injD : ∀ {A B} → D A == D B → A == B injD refl = refl
{ "alphanum_fraction": 0.6044444444, "avg_line_length": 20.4545454545, "ext": "agda", "hexsha": "98974791854e24eb0e4e423d7151a31782ece71b", "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/InjectiveTypeConstructors.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/InjectiveTypeConstructors.agda", "max_line_length": 45, "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/InjectiveTypeConstructors.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": 78, "size": 225 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Subsets of finite sets ------------------------------------------------------------------------ module Data.Fin.Subset where open import Algebra import Algebra.Properties.BooleanAlgebra as BoolAlgProp import Algebra.Properties.BooleanAlgebra.Expression as BAExpr import Data.Bool.Properties as BoolProp open import Data.Fin open import Data.List as List using (List) open import Data.Nat open import Data.Product open import Data.Vec using (Vec; _∷_; _[_]=_) import Relation.Binary.Vec.Pointwise as Pointwise open import Relation.Nullary infix 4 _∈_ _∉_ _⊆_ _⊈_ ------------------------------------------------------------------------ -- Definitions -- Sides. open import Data.Bool public using () renaming (Bool to Side; true to inside; false to outside) -- Partitions a finite set into two parts, the inside and the outside. Subset : ℕ → Set Subset = Vec Side ------------------------------------------------------------------------ -- Membership and subset predicates _∈_ : ∀ {n} → Fin n → Subset n → Set x ∈ p = p [ x ]= inside _∉_ : ∀ {n} → Fin n → Subset n → Set x ∉ p = ¬ (x ∈ p) _⊆_ : ∀ {n} → Subset n → Subset n → Set p₁ ⊆ p₂ = ∀ {x} → x ∈ p₁ → x ∈ p₂ _⊈_ : ∀ {n} → Subset n → Subset n → Set p₁ ⊈ p₂ = ¬ (p₁ ⊆ p₂) ------------------------------------------------------------------------ -- Set operations -- Pointwise lifting of the usual boolean algebra for booleans gives -- us a boolean algebra for subsets. -- -- The underlying equality of the returned boolean algebra is -- propositional equality. booleanAlgebra : ℕ → BooleanAlgebra _ _ booleanAlgebra n = BoolAlgProp.replace-equality (BAExpr.lift BoolProp.booleanAlgebra n) Pointwise.Pointwise-≡ private open module BA {n} = BooleanAlgebra (booleanAlgebra n) public using ( ⊥ -- The empty subset. ; ⊤ -- The subset containing all elements. ) renaming ( _∨_ to _∪_ -- Binary union. ; _∧_ to _∩_ -- Binary intersection. ; ¬_ to ∁ -- Complement. ) -- A singleton subset, containing just the given element. ⁅_⁆ : ∀ {n} → Fin n → Subset n ⁅ zero ⁆ = inside ∷ ⊥ ⁅ suc i ⁆ = outside ∷ ⁅ i ⁆ -- N-ary union. ⋃ : ∀ {n} → List (Subset n) → Subset n ⋃ = List.foldr _∪_ ⊥ -- N-ary intersection. ⋂ : ∀ {n} → List (Subset n) → Subset n ⋂ = List.foldr _∩_ ⊤ ------------------------------------------------------------------------ -- Properties Nonempty : ∀ {n} (p : Subset n) → Set Nonempty p = ∃ λ f → f ∈ p Empty : ∀ {n} (p : Subset n) → Set Empty p = ¬ Nonempty p -- Point-wise lifting of properties. Lift : ∀ {n} → (Fin n → Set) → (Subset n → Set) Lift P p = ∀ {x} → x ∈ p → P x
{ "alphanum_fraction": 0.5391621129, "avg_line_length": 25.6542056075, "ext": "agda", "hexsha": "73578d7b0fbb9a52d3c9c47e4f2930cbe560d300", "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/Fin/Subset.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/Fin/Subset.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Fin/Subset.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": 769, "size": 2745 }
module Subst where import Level postulate Ty : Set data Cxt : Set where ε : Cxt _,_ : (Γ : Cxt) (A : Ty) → Cxt _++_ : Cxt → Cxt → Cxt Γ ++ ε = Γ Γ ++ (Δ , A) = (Γ ++ Δ) , A data Tm : Cxt → Ty → Set where vz : ∀ {Γ A} → Tm (Γ , A) A other : ∀ {Γ A} → Tm Γ A data _≡_ {a}{A : Set a}(x : A) : A → Set a where refl : x ≡ x {-# BUILTIN EQUALITY _≡_ #-} {-# BUILTIN REFL refl #-} data Sub : Cxt → Cxt → Set where _∷_ : ∀ {Γ Δ A} → Tm Γ A → Sub Γ Δ → Sub Γ (Δ , A) lift : ∀ {Γ Δ} Ψ → Sub Γ Δ → Sub (Γ ++ Ψ) (Δ ++ Ψ) wk : ∀ {Γ Δ} Ψ → Sub Γ Δ → Sub (Γ ++ Ψ) Δ id : ∀ {Γ} → Sub Γ Γ ∅ : ∀ {Γ} → Sub Γ ε assoc : ∀ {Γ Δ} Ψ → (Γ ++ (Δ ++ Ψ)) ≡ ((Γ ++ Δ) ++ Ψ) assoc ε = refl assoc {Γ}{Δ} (Ψ , A) rewrite assoc {Γ} {Δ} Ψ = refl ε++ : ∀ Γ → (ε ++ Γ) ≡ Γ ε++ ε = refl ε++ (Γ , A) rewrite ε++ Γ = refl postulate apply : ∀ {Γ Δ A} → Sub Γ Δ → Tm Δ A → Tm Γ A sym : ∀ {A : Set}{x y : A} → x ≡ y → y ≡ x sym refl = refl cast : ∀ {Γ₁ Γ₂ Δ₁ Δ₂} → Γ₁ ≡ Γ₂ → Δ₁ ≡ Δ₂ → Sub Γ₁ Δ₁ → Sub Γ₂ Δ₂ cast refl refl ρ = ρ inj : ∀ {Γ Δ A B} → (Γ , A) ≡ (Δ , B) → Γ ≡ Δ inj refl = refl injT : ∀ {Γ Δ A B} → (Γ , A) ≡ (Δ , B) → A ≡ B injT refl = refl drop : ∀ {Γ Δ ΔΨ} Ψ → Sub Γ ΔΨ → ΔΨ ≡ (Δ ++ Ψ) → Sub Γ Δ drop Ψ id refl = wk Ψ id drop Ψ (wk Δ ρ) refl = wk Δ (drop Ψ ρ refl) drop Ψ (lift ε ρ) refl = drop Ψ ρ refl drop ε ρ refl = ρ drop (Ψ , A) (x ∷ ρ) refl = drop Ψ ρ refl drop {Δ = Δ} (Ψ , A) (lift {Γ = Γ}{Δ = Σ} (Θ , A′) ρ) eq = wk (ε , A′) (drop Ψ (lift Θ ρ) (inj eq)) drop (Ψ , A) ∅ () wkS : ∀ {Γ Δ} Ψ → Sub Γ Δ → Sub (Γ ++ Ψ) Δ wkS ε ρ = ρ wkS Ψ (x ∷ ρ) = (apply (wk Ψ id) x) ∷ wkS Ψ ρ wkS Ψ (lift Ψ₁ ρ) = wk Ψ (lift Ψ₁ ρ) wkS Ψ (wk Ψ₁ ρ) = cast (assoc Ψ) refl (wkS (Ψ₁ ++ Ψ) ρ) wkS Ψ id = wk Ψ id wkS Ψ ∅ = ∅ liftS : ∀ {Γ Δ} Ψ → Sub Γ Δ → Sub (Γ ++ Ψ) (Δ ++ Ψ) liftS Ψ (x ∷ ρ) = lift Ψ (x ∷ ρ) liftS Ψ (lift Ψ₁ ρ) = cast (assoc Ψ) (assoc Ψ) (liftS (Ψ₁ ++ Ψ) ρ) liftS Ψ (wk Ψ₁ ρ) = lift Ψ (wk Ψ₁ ρ) liftS Ψ id = id liftS Ψ ∅ = lift Ψ ∅ data _×_ A B : Set where _,_ : A → B → A × B split : ∀ {Γ Δ ΔΨ} Ψ → Sub Γ ΔΨ → ΔΨ ≡ (Δ ++ Ψ) → Sub Γ Δ × Sub Γ Ψ split {Γ} ε ρ refl = ρ , ∅ split (Ψ , A) (x ∷ ρ) refl with split Ψ ρ refl ... | σ , δ = σ , (x ∷ δ) split Ψ (lift ε ρ) eq = split Ψ ρ eq split (Ψ , A) (lift (Ψ₁ , A₁) ρ) eq with split Ψ (lift Ψ₁ ρ) (inj eq) | injT eq split (Ψ , A) (lift (Ψ₁ , .A) ρ) eq | σ , δ | refl = wk (ε , A) σ , lift (ε , A) δ split Ψ (wk Ψ₁ ρ) eq with split Ψ ρ eq ... | σ , δ = wk Ψ₁ σ , wk Ψ₁ δ split {Δ = Δ} Ψ id refl = wk Ψ id , cast refl (ε++ Ψ) (lift {Γ = Δ} Ψ ∅) split (Ψ , A) ∅ () _<>_ : ∀ {Γ Δ Ψ} → Sub Γ Ψ → Sub Γ Δ → Sub Γ (Δ ++ Ψ) (x ∷ ρ) <> σ = x ∷ (ρ <> σ) lift Ψ ρ <> σ = {!!} wk Ψ₁ ρ <> σ = {!!} -- _<>_ {Ψ = Ψ} id (_∷_ {Δ = Δ}{A = A} x σ) = cast refl (assoc {_}{ε , A} Ψ) -- (_<>_ {Ψ = (ε , A) ++ Ψ} {!!} σ) id <> lift Ψ σ = {!!} id <> wk Ψ σ = {!!} id <> id = {!!} _<>_ {Ψ = Ψ} id ∅ = cast (ε++ Ψ) refl id _<>_ {Ψ = ε} id σ = {!!} _<>_ {Ψ = Ψ , A} id σ = vz ∷ (_<>_ {Ψ = Ψ} (wk (ε , A) id) σ) ∅ <> σ = σ comp : ∀ {Γ Δ Δ′ Ψ} → Sub Γ Δ → Sub Δ′ Ψ → Δ ≡ Δ′ → Sub Γ Ψ comp ρ id refl = ρ comp ρ (wk Δ σ) refl = comp (drop Δ ρ refl) σ refl comp ρ (x ∷ σ) refl = apply ρ x ∷ comp ρ σ refl comp ρ (lift ε σ) refl = comp ρ σ refl comp ρ (lift Ψ σ) refl with split Ψ ρ refl ... | ρ₁ , ρ₂ = ρ₂ <> comp ρ₁ σ refl comp {Γ} ∅ σ refl = cast (ε++ Γ) refl (wk Γ σ) -- comp (u ∷ ρ) (lift (Ψ , A) σ) eq -- with injT eq -- ... | refl = u ∷ comp ρ (lift Ψ σ) (inj eq) -- comp ρ (lift (Ψ , A) σ) eq = -- apply (cast refl eq ρ) vz ∷ -- comp ρ (wk (ε , A) (lift Ψ σ)) eq comp ρ ∅ refl = ∅ _∘_ : ∀ {Γ Δ Ψ} → Sub Γ Δ → Sub Δ Ψ → Sub Γ Ψ ρ ∘ σ = comp ρ σ refl
{ "alphanum_fraction": 0.460137931, "avg_line_length": 27.8846153846, "ext": "agda", "hexsha": "40751acdd89443d89b4f291c4b98380548ac025a", "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": "src/prototyping/subst/Subst.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": "src/prototyping/subst/Subst.agda", "max_line_length": 79, "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": "src/prototyping/subst/Subst.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1942, "size": 3625 }
{-# OPTIONS --without-K --exact-split --safe #-} module 07-finite-sets where import 06-universes open 06-universes public -------------------------------------------------------------------------------- {- Section 7.1 The finite types -} {- Definition 7.1.1 -} {- We introduce the finite types as a family indexed by ℕ. -} Fin : ℕ → UU lzero Fin zero-ℕ = empty Fin (succ-ℕ k) = coprod (Fin k) unit inl-Fin : (k : ℕ) → Fin k → Fin (succ-ℕ k) inl-Fin k = inl neg-one-Fin : {k : ℕ} → Fin (succ-ℕ k) neg-one-Fin {k} = inr star {- Definition 7.1.4 -} zero-Fin : {k : ℕ} → Fin (succ-ℕ k) zero-Fin {zero-ℕ} = inr star zero-Fin {succ-ℕ k} = inl zero-Fin {- Definition 7.1.5 -} -- We define the successor function on finite sets. succ-Fin : {k : ℕ} → Fin k → Fin k succ-Fin {succ-ℕ k} (inr star) = zero-Fin succ-Fin {succ-ℕ (succ-ℕ k)} (inl (inr star)) = neg-one-Fin succ-Fin {succ-ℕ (succ-ℕ k)} (inl (inl x)) = inl (succ-Fin (inl x)) -- We define the predecessor function on finite sets. skip-neg-two-Fin : {k : ℕ} → Fin k → Fin (succ-ℕ k) skip-neg-two-Fin {succ-ℕ k} (inl x) = inl (inl x) skip-neg-two-Fin {succ-ℕ k} (inr x) = neg-one-Fin {succ-ℕ k} pred-Fin : {k : ℕ} → Fin k → Fin k pred-Fin {succ-ℕ zero-ℕ} x = zero-Fin pred-Fin {succ-ℕ (succ-ℕ k)} (inl x) = skip-neg-two-Fin (pred-Fin x) pred-Fin {succ-ℕ (succ-ℕ k)} (inr x) = inl neg-one-Fin {- Definition 7.1.6 -} {- The modulo function -} mod-succ-ℕ : (k : ℕ) → ℕ → Fin (succ-ℕ k) mod-succ-ℕ k zero-ℕ = zero-Fin mod-succ-ℕ k (succ-ℕ n) = succ-Fin (mod-succ-ℕ k n) mod-two-ℕ : ℕ → Fin two-ℕ mod-two-ℕ = mod-succ-ℕ one-ℕ mod-three-ℕ : ℕ → Fin three-ℕ mod-three-ℕ = mod-succ-ℕ two-ℕ -- We show that mod-succ-ℕ is a periodic function with period succ-ℕ n -- {- Definition 7.1.7 -} is-periodic-ℕ : (k : ℕ) {l : Level} {A : UU l} (f : ℕ → A) → UU l is-periodic-ℕ k f = (x : ℕ) → Id (f x) (f (add-ℕ k x)) {- Lemma 7.1.8 -} {- Our first goal is to show that mod-succ-ℕ is a periodic function. We will first prove some intermediate lemmas. -} successor-law-mod-succ-ℕ : (k x : ℕ) → leq-ℕ x k → Id (mod-succ-ℕ (succ-ℕ k) x) (inl (mod-succ-ℕ k x)) successor-law-mod-succ-ℕ k zero-ℕ star = refl successor-law-mod-succ-ℕ (succ-ℕ k) (succ-ℕ x) p = ( ( ap succ-Fin ( successor-law-mod-succ-ℕ (succ-ℕ k) x ( preserves-leq-succ-ℕ x k p))) ∙ ( ap succ-Fin (ap inl (successor-law-mod-succ-ℕ k x p)))) ∙ ( ap inl (ap succ-Fin (inv (successor-law-mod-succ-ℕ k x p)))) {- Corollary 7.1.9 -} neg-one-law-mod-succ-ℕ : (k : ℕ) → Id (mod-succ-ℕ k k) neg-one-Fin neg-one-law-mod-succ-ℕ zero-ℕ = refl neg-one-law-mod-succ-ℕ (succ-ℕ k) = ap succ-Fin ( ( successor-law-mod-succ-ℕ k k (reflexive-leq-ℕ k)) ∙ ( ap inl (neg-one-law-mod-succ-ℕ k))) base-case-is-periodic-mod-succ-ℕ : (k : ℕ) → Id (mod-succ-ℕ k (succ-ℕ k)) zero-Fin base-case-is-periodic-mod-succ-ℕ zero-ℕ = refl base-case-is-periodic-mod-succ-ℕ (succ-ℕ k) = ap succ-Fin (neg-one-law-mod-succ-ℕ (succ-ℕ k)) {- Proposition 7.1.10 -} is-periodic-mod-succ-ℕ : (k : ℕ) → is-periodic-ℕ (succ-ℕ k) (mod-succ-ℕ k) is-periodic-mod-succ-ℕ k zero-ℕ = inv (base-case-is-periodic-mod-succ-ℕ k) is-periodic-mod-succ-ℕ k (succ-ℕ x) = ap succ-Fin (is-periodic-mod-succ-ℕ k x) -------------------------------------------------------------------------------- {- Section 7.2 Decidability -} {- Definition 7.2.1 -} is-decidable : {l : Level} (A : UU l) → UU l is-decidable A = coprod A (¬ A) {- Example 7.2.2 -} is-decidable-unit : is-decidable unit is-decidable-unit = inl star is-decidable-empty : is-decidable empty is-decidable-empty = inr id {- Definition 7.2.3 -} {- We say that a type has decidable equality if we can decide whether x = y holds for any x, y : A. -} has-decidable-equality : {l : Level} (A : UU l) → UU l has-decidable-equality A = (x y : A) → is-decidable (Id x y) {- Lemma 7.2.5 -} is-decidable-iff : {l1 l2 : Level} {A : UU l1} {B : UU l2} → (A → B) → (B → A) → is-decidable A → is-decidable B is-decidable-iff f g = functor-coprod f (functor-neg g) {- Proposition 7.2.6 -} {- The type ℕ is an example of a type with decidable equality. -} is-decidable-Eq-ℕ : (m n : ℕ) → is-decidable (Eq-ℕ m n) is-decidable-Eq-ℕ zero-ℕ zero-ℕ = inl star is-decidable-Eq-ℕ zero-ℕ (succ-ℕ n) = inr id is-decidable-Eq-ℕ (succ-ℕ m) zero-ℕ = inr id is-decidable-Eq-ℕ (succ-ℕ m) (succ-ℕ n) = is-decidable-Eq-ℕ m n has-decidable-equality-ℕ : has-decidable-equality ℕ has-decidable-equality-ℕ x y = is-decidable-iff (eq-Eq-ℕ x y) Eq-ℕ-eq (is-decidable-Eq-ℕ x y) {- Definition 7.2.7 -} {- Observational equality on finite sets -} Eq-Fin : (k : ℕ) → Fin k → Fin k → UU lzero Eq-Fin (succ-ℕ k) (inl x) (inl y) = Eq-Fin k x y Eq-Fin (succ-ℕ k) (inl x) (inr y) = empty Eq-Fin (succ-ℕ k) (inr x) (inl y) = empty Eq-Fin (succ-ℕ k) (inr x) (inr y) = unit {- Proposition 7.2.8 -} refl-Eq-Fin : {k : ℕ} (x : Fin k) → Eq-Fin k x x refl-Eq-Fin {succ-ℕ k} (inl x) = refl-Eq-Fin x refl-Eq-Fin {succ-ℕ k} (inr x) = star Eq-Fin-eq : {k : ℕ} {x y : Fin k} → Id x y → Eq-Fin k x y Eq-Fin-eq {k} refl = refl-Eq-Fin {k} _ eq-Eq-Fin : {k : ℕ} {x y : Fin k} → Eq-Fin k x y → Id x y eq-Eq-Fin {succ-ℕ k} {inl x} {inl y} e = ap inl (eq-Eq-Fin e) eq-Eq-Fin {succ-ℕ k} {inr star} {inr star} star = refl {- Proposition 7.2.9 -} {- We show that Fin k has decidable equality, for each n : ℕ. -} is-decidable-Eq-Fin : (k : ℕ) (x y : Fin k) → is-decidable (Eq-Fin k x y) is-decidable-Eq-Fin (succ-ℕ k) (inl x) (inl y) = is-decidable-Eq-Fin k x y is-decidable-Eq-Fin (succ-ℕ k) (inl x) (inr y) = inr id is-decidable-Eq-Fin (succ-ℕ k) (inr x) (inl y) = inr id is-decidable-Eq-Fin (succ-ℕ k) (inr x) (inr y) = inl star is-decidable-eq-Fin : (k : ℕ) (x y : Fin k) → is-decidable (Id x y) is-decidable-eq-Fin k x y = functor-coprod eq-Eq-Fin (functor-neg Eq-Fin-eq) (is-decidable-Eq-Fin k x y) {- Proposition 7.2.10 -} {- The inclusion function Fin k → Fin (succ-ℕ k) is injective. -} is-injective-inl-Fin : {k : ℕ} {x y : Fin k} → Id (inl-Fin k x) (inl-Fin k y) → Id x y is-injective-inl-Fin p = eq-Eq-Fin (Eq-Fin-eq p) {- Lemma 7.2.11 -} neq-zero-succ-Fin : {k : ℕ} {x : Fin k} → ¬ (Id (succ-Fin (inl-Fin k x)) zero-Fin) neq-zero-succ-Fin {succ-ℕ k} {inl x} p = neq-zero-succ-Fin (is-injective-inl-Fin p) neq-zero-succ-Fin {succ-ℕ k} {inr star} p = Eq-Fin-eq {succ-ℕ (succ-ℕ k)} {inr star} {zero-Fin} p {- Proposition 7.2.12 -} {- The successor function Fin k → Fin k is injective. -} is-injective-succ-Fin : {k : ℕ} {x y : Fin k} → Id (succ-Fin x) (succ-Fin y) → Id x y is-injective-succ-Fin {succ-ℕ k} {inr star} {inr star} p = refl is-injective-succ-Fin {succ-ℕ k} {inl x} {inr star} p = ex-falso (neq-zero-succ-Fin {succ-ℕ k} {inl x} (ap inl p)) is-injective-succ-Fin {succ-ℕ k} {inr star} {inl y} p = ex-falso (neq-zero-succ-Fin {succ-ℕ k} {inl y} (ap inl (inv p))) is-injective-succ-Fin {succ-ℕ (succ-ℕ k)} {inl (inr star)} {inl (inr star)} p = refl is-injective-succ-Fin {succ-ℕ (succ-ℕ k)} {inl (inl x)} {inl (inr star)} p = ex-falso (Eq-Fin-eq p) is-injective-succ-Fin {succ-ℕ (succ-ℕ k)} {inl (inr star)} {inl (inl y)} p = ex-falso (Eq-Fin-eq p) is-injective-succ-Fin {succ-ℕ (succ-ℕ k)} {inl (inl x)} {inl (inl y)} p = ap inl (is-injective-succ-Fin (is-injective-inl-Fin p)) -------------------------------------------------------------------------------- {- Section 7.3 Definitions by case analysis -} {- We define an alternative definition of the predecessor function with manual with-abstraction. -} cases-pred-Fin-2 : {k : ℕ} (x : Fin (succ-ℕ k)) (d : is-decidable (Eq-Fin (succ-ℕ k) x zero-Fin)) → Fin (succ-ℕ k) cases-pred-Fin-2 {zero-ℕ} (inr star) d = zero-Fin cases-pred-Fin-2 {succ-ℕ k} (inl x) (inl e) = neg-one-Fin cases-pred-Fin-2 {succ-ℕ k} (inl x) (inr f) = inl (cases-pred-Fin-2 {k} x (inr f)) cases-pred-Fin-2 {succ-ℕ k} (inr star) (inr f) = inl neg-one-Fin pred-Fin-2 : {k : ℕ} → Fin k → Fin k pred-Fin-2 {succ-ℕ k} x = cases-pred-Fin-2 {k} x (is-decidable-Eq-Fin (succ-ℕ k) x zero-Fin) -------------------------------------------------------------------------------- {- Section 7.4 The congruence relations modulo k -} -- We introduce the divisibility relation. -- div-ℕ : ℕ → ℕ → UU lzero div-ℕ m n = Σ ℕ (λ k → Id (mul-ℕ k m) n) -- We show some basic properties of the divisibility relation -- {- In the following three constructions we show that if any two of the three numbers x, y, and x + y, is divisible by d, then so is the third. -} div-add-ℕ : (d x y : ℕ) → div-ℕ d x → div-ℕ d y → div-ℕ d (add-ℕ x y) div-add-ℕ d x y (pair n p) (pair m q) = pair ( add-ℕ n m) ( ( right-distributive-mul-add-ℕ n m d) ∙ ( ap-add-ℕ p q)) div-left-summand-ℕ : (d x y : ℕ) → div-ℕ d y → div-ℕ d (add-ℕ x y) → div-ℕ d x div-left-summand-ℕ zero-ℕ x y (pair m q) (pair n p) = pair zero-ℕ ( ( inv (right-zero-law-mul-ℕ n)) ∙ ( p ∙ (ap (add-ℕ x) ((inv q) ∙ (right-zero-law-mul-ℕ m))))) div-left-summand-ℕ (succ-ℕ d) x y (pair m q) (pair n p) = pair ( dist-ℕ m n) ( is-injective-add-ℕ (mul-ℕ m (succ-ℕ d)) (mul-ℕ (dist-ℕ m n) (succ-ℕ d)) x ( ( inv ( ( right-distributive-mul-add-ℕ m (dist-ℕ m n) (succ-ℕ d)) ∙ ( commutative-add-ℕ ( mul-ℕ m (succ-ℕ d)) ( mul-ℕ (dist-ℕ m n) (succ-ℕ d))))) ∙ ( ( ap ( mul-ℕ' (succ-ℕ d)) ( leq-dist-ℕ m n ( leq-leq-mul-ℕ' m n d ( concatenate-eq-leq-eq-ℕ q ( leq-add-ℕ' y x) ( inv p))))) ∙ ( p ∙ (ap (add-ℕ x) (inv q)))))) div-right-summand-ℕ : (d x y : ℕ) → div-ℕ d x → div-ℕ d (add-ℕ x y) → div-ℕ d y div-right-summand-ℕ d x y H1 H2 = div-left-summand-ℕ d y x H1 (tr (div-ℕ d) (commutative-add-ℕ x y) H2) -------------------------------------------------------------------------------- -- Some lemmas that will help us showing that cong is an equivalence relation order-two-elements-ℕ : (x y : ℕ) → coprod (leq-ℕ x y) (leq-ℕ y x) order-two-elements-ℕ zero-ℕ zero-ℕ = inl star order-two-elements-ℕ zero-ℕ (succ-ℕ y) = inl star order-two-elements-ℕ (succ-ℕ x) zero-ℕ = inr star order-two-elements-ℕ (succ-ℕ x) (succ-ℕ y) = order-two-elements-ℕ x y cases-order-three-elements-ℕ : (x y z : ℕ) → UU lzero cases-order-three-elements-ℕ x y z = coprod ( coprod ((leq-ℕ x y) × (leq-ℕ y z)) ((leq-ℕ x z) × (leq-ℕ z y))) ( coprod ( coprod ((leq-ℕ y z) × (leq-ℕ z x)) ((leq-ℕ y x) × (leq-ℕ x z))) ( coprod ((leq-ℕ z x) × (leq-ℕ x y)) ((leq-ℕ z y) × (leq-ℕ y x)))) order-three-elements-ℕ : (x y z : ℕ) → cases-order-three-elements-ℕ x y z order-three-elements-ℕ zero-ℕ zero-ℕ zero-ℕ = inl (inl (pair star star)) order-three-elements-ℕ zero-ℕ zero-ℕ (succ-ℕ z) = inl (inl (pair star star)) order-three-elements-ℕ zero-ℕ (succ-ℕ y) zero-ℕ = inl (inr (pair star star)) order-three-elements-ℕ zero-ℕ (succ-ℕ y) (succ-ℕ z) = inl (functor-coprod (pair star) (pair star) (order-two-elements-ℕ y z)) order-three-elements-ℕ (succ-ℕ x) zero-ℕ zero-ℕ = inr (inl (inl (pair star star))) order-three-elements-ℕ (succ-ℕ x) zero-ℕ (succ-ℕ z) = inr (inl (functor-coprod (pair star) (pair star) (order-two-elements-ℕ z x))) order-three-elements-ℕ (succ-ℕ x) (succ-ℕ y) zero-ℕ = inr (inr (functor-coprod (pair star) (pair star) (order-two-elements-ℕ x y))) order-three-elements-ℕ (succ-ℕ x) (succ-ℕ y) (succ-ℕ z) = order-three-elements-ℕ x y z triangle-equality-dist-ℕ : (x y z : ℕ) → (leq-ℕ x y) → (leq-ℕ y z) → Id (add-ℕ (dist-ℕ x y) (dist-ℕ y z)) (dist-ℕ x z) triangle-equality-dist-ℕ zero-ℕ zero-ℕ zero-ℕ H1 H2 = refl triangle-equality-dist-ℕ zero-ℕ zero-ℕ (succ-ℕ z) star star = ap succ-ℕ (left-unit-law-add-ℕ z) triangle-equality-dist-ℕ zero-ℕ (succ-ℕ y) (succ-ℕ z) star H2 = left-successor-law-add-ℕ y (dist-ℕ y z) ∙ ap succ-ℕ (leq-dist-ℕ y z H2) triangle-equality-dist-ℕ (succ-ℕ x) (succ-ℕ y) (succ-ℕ z) H1 H2 = triangle-equality-dist-ℕ x y z H1 H2 cases-dist-ℕ : (x y z : ℕ) → UU lzero cases-dist-ℕ x y z = coprod ( Id (add-ℕ (dist-ℕ x y) (dist-ℕ y z)) (dist-ℕ x z)) ( coprod ( Id (add-ℕ (dist-ℕ y z) (dist-ℕ x z)) (dist-ℕ x y)) ( Id (add-ℕ (dist-ℕ x z) (dist-ℕ x y)) (dist-ℕ y z))) is-total-dist-ℕ : (x y z : ℕ) → cases-dist-ℕ x y z is-total-dist-ℕ x y z with order-three-elements-ℕ x y z is-total-dist-ℕ x y z | inl (inl (pair H1 H2)) = inl (triangle-equality-dist-ℕ x y z H1 H2) is-total-dist-ℕ x y z | inl (inr (pair H1 H2)) = inr ( inl ( ( commutative-add-ℕ (dist-ℕ y z) (dist-ℕ x z)) ∙ ( ( ap (add-ℕ (dist-ℕ x z)) (symmetric-dist-ℕ y z)) ∙ ( triangle-equality-dist-ℕ x z y H1 H2)))) is-total-dist-ℕ x y z | inr (inl (inl (pair H1 H2))) = inr ( inl ( ( ap (add-ℕ (dist-ℕ y z)) (symmetric-dist-ℕ x z)) ∙ ( ( triangle-equality-dist-ℕ y z x H1 H2) ∙ ( symmetric-dist-ℕ y x)))) is-total-dist-ℕ x y z | inr (inl (inr (pair H1 H2))) = inr ( inr ( ( ap (add-ℕ (dist-ℕ x z)) (symmetric-dist-ℕ x y)) ∙ ( ( commutative-add-ℕ (dist-ℕ x z) (dist-ℕ y x)) ∙ ( triangle-equality-dist-ℕ y x z H1 H2)))) is-total-dist-ℕ x y z | inr (inr (inl (pair H1 H2))) = inr ( inr ( ( ap (add-ℕ' (dist-ℕ x y)) (symmetric-dist-ℕ x z)) ∙ ( ( triangle-equality-dist-ℕ z x y H1 H2) ∙ ( symmetric-dist-ℕ z y)))) is-total-dist-ℕ x y z | inr (inr (inr (pair H1 H2))) = inl ( ( ap-add-ℕ (symmetric-dist-ℕ x y) (symmetric-dist-ℕ y z)) ∙ ( ( commutative-add-ℕ (dist-ℕ y x) (dist-ℕ z y)) ∙ ( ( triangle-equality-dist-ℕ z y x H1 H2) ∙ ( symmetric-dist-ℕ z x)))) -------------------------------------------------------------------------------- {- We define the congruence relation on ℕ and show that it is an equivalence relation on ℕ. -} cong-ℕ : ℕ → ℕ → ℕ → UU lzero cong-ℕ k x y = div-ℕ k (dist-ℕ x y) eq-cong-eq-ℕ : (k : ℕ) {x1 x2 x3 x4 : ℕ} → Id x1 x2 → cong-ℕ k x2 x3 → Id x3 x4 → cong-ℕ k x1 x4 eq-cong-eq-ℕ k refl H refl = H reflexive-cong-ℕ : (k x : ℕ) → cong-ℕ k x x reflexive-cong-ℕ k x = pair zero-ℕ ((left-zero-law-mul-ℕ (succ-ℕ k)) ∙ (dist-eq-ℕ x x refl)) cong-identification-ℕ : (k : ℕ) {x y : ℕ} → Id x y → cong-ℕ k x y cong-identification-ℕ k {x} refl = reflexive-cong-ℕ k x symmetric-cong-ℕ : (k x y : ℕ) → cong-ℕ k x y → cong-ℕ k y x symmetric-cong-ℕ k x y (pair d p) = pair d (p ∙ (symmetric-dist-ℕ x y)) transitive-cong-ℕ : (k x y z : ℕ) → cong-ℕ k x y → cong-ℕ k y z → cong-ℕ k x z transitive-cong-ℕ k x y z d e with is-total-dist-ℕ x y z transitive-cong-ℕ k x y z d e | inl α = tr (div-ℕ k) α (div-add-ℕ k (dist-ℕ x y) (dist-ℕ y z) d e) transitive-cong-ℕ k x y z d e | inr (inl α) = div-right-summand-ℕ k (dist-ℕ y z) (dist-ℕ x z) e (tr (div-ℕ k) (inv α) d) transitive-cong-ℕ k x y z d e | inr (inr α) = div-left-summand-ℕ k (dist-ℕ x z) (dist-ℕ x y) d (tr (div-ℕ k) (inv α) e) concatenate-cong-eq-cong-ℕ : {k x1 x2 x3 x4 : ℕ} → cong-ℕ k x1 x2 → Id x2 x3 → cong-ℕ k x3 x4 → cong-ℕ k x1 x4 concatenate-cong-eq-cong-ℕ {k} {x} {y} {.y} {z} H refl K = transitive-cong-ℕ k x y z H K eq-cong-eq-cong-eq-ℕ : (k : ℕ) {x1 x2 x3 x4 x5 x6 : ℕ} → Id x1 x2 → cong-ℕ k x2 x3 → Id x3 x4 → cong-ℕ k x4 x5 → Id x5 x6 → cong-ℕ k x1 x6 eq-cong-eq-cong-eq-ℕ k {x} {.x} {y} {.y} {z} {.z} refl H refl K refl = transitive-cong-ℕ k x y z H K -------------------------------------------------------------------------------- -- We show that cong-ℕ zero-ℕ is the discrete equivalence relation -- is-discrete-cong-zero-ℕ : (x y : ℕ) → cong-ℕ zero-ℕ x y → Id x y is-discrete-cong-zero-ℕ x y (pair k p) = eq-dist-ℕ x y ((inv (right-zero-law-mul-ℕ k)) ∙ p) -- We show that cong-ℕ one-ℕ is the indiscrete equivalence relation -- div-one-ℕ : (x : ℕ) → div-ℕ one-ℕ x div-one-ℕ x = pair x (right-unit-law-mul-ℕ x) is-indiscrete-cong-one-ℕ : (x y : ℕ) → cong-ℕ one-ℕ x y is-indiscrete-cong-one-ℕ x y = div-one-ℕ (dist-ℕ x y) -- We show that zero-ℕ is congruent to n modulo n. cong-zero-ℕ : (k : ℕ) → cong-ℕ k k zero-ℕ cong-zero-ℕ k = pair one-ℕ ((left-unit-law-mul-ℕ k) ∙ (inv (right-zero-law-dist-ℕ k))) -- We show that congruence is translation invariant -- translation-invariant-cong-ℕ : (k x y z : ℕ) → cong-ℕ k x y → cong-ℕ k (add-ℕ z x) (add-ℕ z y) translation-invariant-cong-ℕ k x y z (pair d p) = pair d (p ∙ inv (translation-invariant-dist-ℕ z x y)) translation-invariant-cong-ℕ' : (k x y z : ℕ) → cong-ℕ k x y → cong-ℕ k (add-ℕ x z) (add-ℕ y z) translation-invariant-cong-ℕ' k x y z H = eq-cong-eq-ℕ k ( commutative-add-ℕ x z) ( translation-invariant-cong-ℕ k x y z H) ( commutative-add-ℕ z y) step-invariant-cong-ℕ : (k x y : ℕ) → cong-ℕ k x y → cong-ℕ k (succ-ℕ x) (succ-ℕ y) step-invariant-cong-ℕ k x y = translation-invariant-cong-ℕ' k x y one-ℕ -------------------------------------------------------------------------------- -- We show that mod-succ-ℕ sends congruent elements to equal elements -- zero-class-mod-succ-ℕ : (k x : ℕ) (d : div-ℕ (succ-ℕ k) x) → Id (mod-succ-ℕ k x) zero-Fin zero-class-mod-succ-ℕ k .zero-ℕ (pair zero-ℕ refl) = refl zero-class-mod-succ-ℕ k x (pair (succ-ℕ d) p) = ( inv (ap (mod-succ-ℕ k) p)) ∙ ( ( ap (mod-succ-ℕ k) (commutative-add-ℕ (mul-ℕ d (succ-ℕ k)) (succ-ℕ k))) ∙ ( ( inv (is-periodic-mod-succ-ℕ k (mul-ℕ d (succ-ℕ k)))) ∙ ( zero-class-mod-succ-ℕ k (mul-ℕ d (succ-ℕ k)) (pair d refl)))) eq-cong-ℕ : (k x y : ℕ) → cong-ℕ (succ-ℕ k) x y → Id (mod-succ-ℕ k x) (mod-succ-ℕ k y) eq-cong-ℕ k zero-ℕ zero-ℕ H = refl eq-cong-ℕ k zero-ℕ (succ-ℕ y) H = inv (zero-class-mod-succ-ℕ k (succ-ℕ y) H) eq-cong-ℕ k (succ-ℕ x) zero-ℕ H = zero-class-mod-succ-ℕ k (succ-ℕ x) H eq-cong-ℕ k (succ-ℕ x) (succ-ℕ y) H = ap succ-Fin (eq-cong-ℕ k x y H) -------------------------------------------------------------------------------- {- We define the inclusion of Fin k into ℕ. -} nat-Fin : {k : ℕ} → Fin k → ℕ nat-Fin {succ-ℕ k} (inl x) = nat-Fin x nat-Fin {succ-ℕ k} (inr x) = k zero-law-nat-Fin : {k : ℕ} → Id (nat-Fin (zero-Fin {k})) zero-ℕ zero-law-nat-Fin {zero-ℕ} = refl zero-law-nat-Fin {succ-ℕ k} = zero-law-nat-Fin {k} {- We show that nat-Fin x ≤ k. -} upper-bound-nat-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → leq-ℕ (nat-Fin x) k upper-bound-nat-Fin {zero-ℕ} (inr star) = star upper-bound-nat-Fin {succ-ℕ k} (inl x) = preserves-leq-succ-ℕ (nat-Fin x) k (upper-bound-nat-Fin x) upper-bound-nat-Fin {succ-ℕ k} (inr star) = reflexive-leq-ℕ (succ-ℕ k) {- Now we show that Fin (succ-ℕ k) is a retract of ℕ -} issec-nat-Fin : (k : ℕ) (x : Fin (succ-ℕ k)) → Id (mod-succ-ℕ k (nat-Fin x)) x issec-nat-Fin zero-ℕ (inr star) = refl issec-nat-Fin (succ-ℕ k) (inl x) = ( successor-law-mod-succ-ℕ k (nat-Fin x) (upper-bound-nat-Fin x)) ∙ ( ap inl (issec-nat-Fin k x)) issec-nat-Fin (succ-ℕ k) (inr star) = neg-one-law-mod-succ-ℕ (succ-ℕ k) -- We show that nat-Fin is an injective function -- neq-leq-ℕ : {m n : ℕ} → leq-ℕ m n → ¬ (Id m (succ-ℕ n)) neq-leq-ℕ {zero-ℕ} {n} p q = Eq-ℕ-eq q neq-leq-ℕ {succ-ℕ m} {succ-ℕ n} p q = neq-leq-ℕ p (is-injective-succ-ℕ m (succ-ℕ n) q) is-injective-nat-Fin : {k : ℕ} {x y : Fin (succ-ℕ k)} → Id (nat-Fin x) (nat-Fin y) → Id x y is-injective-nat-Fin {zero-ℕ} {inr star} {inr star} p = refl is-injective-nat-Fin {succ-ℕ k} {inl x} {inl y} p = ap inl (is-injective-nat-Fin p) is-injective-nat-Fin {succ-ℕ k} {inl x} {inr star} p = ex-falso (neq-leq-ℕ (upper-bound-nat-Fin x) p) is-injective-nat-Fin {succ-ℕ k} {inr star} {inl y} p = ex-falso (neq-leq-ℕ (upper-bound-nat-Fin y) (inv p)) is-injective-nat-Fin {succ-ℕ k} {inr star} {inr star} p = refl -- We show that nat-Fin commutes with the successor for x ≠ neg-one-Fin -- nat-succ-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) (p : ¬ (Eq-Fin (succ-ℕ k) x neg-one-Fin)) → Id (nat-Fin (succ-Fin x)) (succ-ℕ (nat-Fin x)) nat-succ-Fin {k} (inr star) p = ex-falso (p star) nat-succ-Fin {succ-ℕ k} (inl (inr star)) p = refl nat-succ-Fin {succ-ℕ k} (inl (inl x)) p = nat-succ-Fin (inl x) id -- We show that (nat-Fin (mod-succ-ℕ n x)) is congruent to x modulo n+1. -- cong-nat-mod-succ-ℕ : (k x : ℕ) → cong-ℕ (succ-ℕ k) (nat-Fin (mod-succ-ℕ k x)) x cong-nat-mod-succ-ℕ k x with is-decidable-eq-Fin (succ-ℕ k) (mod-succ-ℕ k x) zero-Fin cong-nat-mod-succ-ℕ zero-ℕ zero-ℕ | d = pair zero-ℕ refl cong-nat-mod-succ-ℕ zero-ℕ (succ-ℕ x) | d = div-one-ℕ (dist-ℕ (nat-Fin (mod-succ-ℕ zero-ℕ (succ-ℕ x))) (succ-ℕ x)) cong-nat-mod-succ-ℕ (succ-ℕ k) zero-ℕ | d = eq-cong-eq-ℕ (succ-ℕ (succ-ℕ k)) ( zero-law-nat-Fin {succ-ℕ k}) ( reflexive-cong-ℕ (succ-ℕ (succ-ℕ k)) zero-ℕ) ( refl) cong-nat-mod-succ-ℕ (succ-ℕ k) (succ-ℕ x) | inl p = eq-cong-eq-cong-eq-ℕ ( succ-ℕ (succ-ℕ k)) ( ap nat-Fin {x = mod-succ-ℕ (succ-ℕ k) (succ-ℕ x)} p ∙ zero-law-nat-Fin {succ-ℕ k}) ( symmetric-cong-ℕ ( succ-ℕ (succ-ℕ k)) ( zero-ℕ) ( succ-ℕ (succ-ℕ k)) ( cong-zero-ℕ (succ-ℕ (succ-ℕ k)))) ( ap ( succ-ℕ ∘ nat-Fin) { x = neg-one-Fin} { y = mod-succ-ℕ (succ-ℕ k) x} ( is-injective-succ-Fin (inv p))) ( step-invariant-cong-ℕ ( succ-ℕ (succ-ℕ k)) ( nat-Fin (mod-succ-ℕ (succ-ℕ k) x)) ( x) ( cong-nat-mod-succ-ℕ (succ-ℕ k) x)) ( refl) cong-nat-mod-succ-ℕ (succ-ℕ k) (succ-ℕ x) | inr f = eq-cong-eq-ℕ ( succ-ℕ (succ-ℕ k)) ( nat-succ-Fin ( mod-succ-ℕ (succ-ℕ k) x) ( (f ∘ ap succ-Fin) ∘ ( eq-Eq-Fin { succ-ℕ (succ-ℕ k)} { x = mod-succ-ℕ (succ-ℕ k) x} { y = neg-one-Fin}))) ( step-invariant-cong-ℕ ( succ-ℕ (succ-ℕ k)) ( nat-Fin (mod-succ-ℕ (succ-ℕ k) x)) ( x) ( cong-nat-mod-succ-ℕ (succ-ℕ k) x)) ( refl) -------------------------------------------------------------------------------- {- We show that if mod-succ-ℕ n = is mod-succ-ℕ n x, then x and y must be congruent modulo succ-ℕ n. -} cong-eq-ℕ : (k x y : ℕ) → Id (mod-succ-ℕ k x) (mod-succ-ℕ k y) → cong-ℕ (succ-ℕ k) x y cong-eq-ℕ k x y p = concatenate-cong-eq-cong-ℕ {succ-ℕ k} {x} ( symmetric-cong-ℕ (succ-ℕ k) (nat-Fin (mod-succ-ℕ k x)) x ( cong-nat-mod-succ-ℕ k x)) ( ap nat-Fin p) ( cong-nat-mod-succ-ℕ k y) -------------------------------------------------------------------------------- {- We show that if x and y are congruent modulo (succ-ℕ n), then we will have an identification mod-succ-ℕ n x = mod-succ-ℕ n y. -} upper-bound-dist-ℕ : (b x y : ℕ) → leq-ℕ x b → leq-ℕ y b → leq-ℕ (dist-ℕ x y) b upper-bound-dist-ℕ zero-ℕ zero-ℕ zero-ℕ H K = star upper-bound-dist-ℕ (succ-ℕ b) zero-ℕ zero-ℕ H K = star upper-bound-dist-ℕ (succ-ℕ b) zero-ℕ (succ-ℕ y) H K = K upper-bound-dist-ℕ (succ-ℕ b) (succ-ℕ x) zero-ℕ H K = H upper-bound-dist-ℕ (succ-ℕ b) (succ-ℕ x) (succ-ℕ y) H K = preserves-leq-succ-ℕ (dist-ℕ x y) b (upper-bound-dist-ℕ b x y H K) contradiction-leq-ℕ : (x y : ℕ) → leq-ℕ x y → leq-ℕ (succ-ℕ y) x → empty contradiction-leq-ℕ (succ-ℕ x) (succ-ℕ y) H K = contradiction-leq-ℕ x y H K eq-zero-div-ℕ : (d x : ℕ) → leq-ℕ x d → div-ℕ (succ-ℕ d) x → Id x zero-ℕ eq-zero-div-ℕ d zero-ℕ H D = refl eq-zero-div-ℕ d (succ-ℕ x) H (pair (succ-ℕ k) p) = ex-falso ( contradiction-leq-ℕ d x ( concatenate-eq-leq-eq-ℕ { x1 = succ-ℕ d} { x2 = succ-ℕ d} { x3 = succ-ℕ (add-ℕ (mul-ℕ k (succ-ℕ d)) d)} { x4 = succ-ℕ x} ( refl) ( leq-add-ℕ' d (mul-ℕ k (succ-ℕ d))) ( p)) H) eq-cong-nat-Fin : (k : ℕ) (x y : Fin k) → cong-ℕ k (nat-Fin x) (nat-Fin y) → Id x y eq-cong-nat-Fin (succ-ℕ k) x y H = is-injective-nat-Fin ( eq-dist-ℕ ( nat-Fin x) ( nat-Fin y) ( inv ( eq-zero-div-ℕ k ( dist-ℕ (nat-Fin x) (nat-Fin y)) ( upper-bound-dist-ℕ k ( nat-Fin x) ( nat-Fin y) ( upper-bound-nat-Fin x) ( upper-bound-nat-Fin y)) ( H)))) eq-mod-succ-ℕ : (k x y : ℕ) → cong-ℕ (succ-ℕ k) x y → Id (mod-succ-ℕ k x) (mod-succ-ℕ k y) eq-mod-succ-ℕ k x y H = eq-cong-nat-Fin ( succ-ℕ k) ( mod-succ-ℕ k x) ( mod-succ-ℕ k y) ( transitive-cong-ℕ ( succ-ℕ k) ( nat-Fin (mod-succ-ℕ k x)) ( x) ( nat-Fin (mod-succ-ℕ k y)) ( cong-nat-mod-succ-ℕ k x) ( transitive-cong-ℕ (succ-ℕ k) x y (nat-Fin (mod-succ-ℕ k y)) H ( symmetric-cong-ℕ (succ-ℕ k) (nat-Fin (mod-succ-ℕ k y)) y ( cong-nat-mod-succ-ℕ k y)))) {- This completes the proof that (mod-succ-ℕ n x = mod-succ-ℕ n y) ↔ (cong-ℕ (succ-ℕ n) x y). -} -------------------------------------------------------------------------------- {- Section 7.7 Modular arithmetic -} -- We show that congruence is invariant under scalar multiplication -- scalar-invariant-cong-ℕ : (k x y z : ℕ) → cong-ℕ k x y → cong-ℕ k (mul-ℕ z x) (mul-ℕ z y) scalar-invariant-cong-ℕ k x y z (pair d p) = pair ( mul-ℕ z d) ( ( associative-mul-ℕ z d k) ∙ ( ( ap (mul-ℕ z) p) ∙ ( inv (linear-dist-ℕ x y z)))) scalar-invariant-cong-ℕ' : (k x y z : ℕ) → cong-ℕ k x y → cong-ℕ k (mul-ℕ x z) (mul-ℕ y z) scalar-invariant-cong-ℕ' k x y z H = eq-cong-eq-ℕ k ( commutative-mul-ℕ x z) ( scalar-invariant-cong-ℕ k x y z H) ( commutative-mul-ℕ z y) -- We show that addition respects the congruence relation -- congruence-add-ℕ : (k : ℕ) {x y x' y' : ℕ} → cong-ℕ k x x' → cong-ℕ k y y' → cong-ℕ k (add-ℕ x y) (add-ℕ x' y') congruence-add-ℕ k {x} {y} {x'} {y'} H K = transitive-cong-ℕ k (add-ℕ x y) (add-ℕ x y') (add-ℕ x' y') ( translation-invariant-cong-ℕ k y y' x K) ( translation-invariant-cong-ℕ' k x x' y' H) -- We show that multiplication respects the congruence relation -- congruence-mul-ℕ : (k : ℕ) {x y x' y' : ℕ} → cong-ℕ k x x' → cong-ℕ k y y' → cong-ℕ k (mul-ℕ x y) (mul-ℕ x' y') congruence-mul-ℕ k {x} {y} {x'} {y'} H K = transitive-cong-ℕ k (mul-ℕ x y) (mul-ℕ x y') (mul-ℕ x' y') ( scalar-invariant-cong-ℕ k y y' x K) ( scalar-invariant-cong-ℕ' k x x' y' H) -------------------------------------------------------------------------------- -- Now we start defining the finite cyclic groups ℤ/n. -- Addition on finite sets -- add-Fin : {k : ℕ} → Fin k → Fin k → Fin k add-Fin {succ-ℕ k} x y = mod-succ-ℕ k (add-ℕ (nat-Fin x) (nat-Fin y)) add-Fin' : {k : ℕ} → Fin k → Fin k → Fin k add-Fin' x y = add-Fin y x ap-add-Fin : {k : ℕ} {x y x' y' : Fin k} → Id x x' → Id y y' → Id (add-Fin x y) (add-Fin x' y') ap-add-Fin refl refl = refl cong-add-Fin : {k : ℕ} (x y : Fin k) → cong-ℕ k (nat-Fin (add-Fin x y)) (add-ℕ (nat-Fin x) (nat-Fin y)) cong-add-Fin {succ-ℕ k} x y = cong-nat-mod-succ-ℕ k (add-ℕ (nat-Fin x) (nat-Fin y)) -------------------------------------------------------------------------------- -- We show that addition is associative -- associative-add-Fin : {k : ℕ} (x y z : Fin k) → Id (add-Fin (add-Fin x y) z) (add-Fin x (add-Fin y z)) associative-add-Fin {succ-ℕ k} x y z = eq-cong-ℕ k ( add-ℕ (nat-Fin (add-Fin x y)) (nat-Fin z)) ( add-ℕ (nat-Fin x) (nat-Fin (add-Fin y z))) ( concatenate-cong-eq-cong-ℕ { x1 = add-ℕ (nat-Fin (add-Fin x y)) (nat-Fin z)} { x2 = add-ℕ (add-ℕ (nat-Fin x) (nat-Fin y)) (nat-Fin z)} { x3 = add-ℕ (nat-Fin x) (add-ℕ (nat-Fin y) (nat-Fin z))} { x4 = add-ℕ (nat-Fin x) (nat-Fin (add-Fin y z))} ( congruence-add-ℕ ( succ-ℕ k) { x = nat-Fin (add-Fin x y)} { y = nat-Fin z} { x' = add-ℕ (nat-Fin x) (nat-Fin y)} { y' = nat-Fin z} ( cong-add-Fin x y) ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin z))) ( associative-add-ℕ (nat-Fin x) (nat-Fin y) (nat-Fin z)) ( congruence-add-ℕ ( succ-ℕ k) { x = nat-Fin x} { y = add-ℕ (nat-Fin y) (nat-Fin z)} { x' = nat-Fin x} { y' = nat-Fin (add-Fin y z)} ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin x)) ( symmetric-cong-ℕ ( succ-ℕ k) ( nat-Fin (add-Fin y z)) ( add-ℕ (nat-Fin y) (nat-Fin z)) ( cong-add-Fin y z)))) -------------------------------------------------------------------------------- -- addition is commutative -- commutative-add-Fin : {k : ℕ} (x y : Fin k) → Id (add-Fin x y) (add-Fin y x) commutative-add-Fin {succ-ℕ k} x y = ap (mod-succ-ℕ k) (commutative-add-ℕ (nat-Fin x) (nat-Fin y)) -------------------------------------------------------------------------------- -- We prove the unit laws for add-Fin -- nat-zero-Fin : {k : ℕ} → cong-ℕ (succ-ℕ k) (nat-Fin (zero-Fin {k})) zero-ℕ nat-zero-Fin {k} = cong-nat-mod-succ-ℕ k zero-ℕ right-unit-law-add-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (add-Fin x zero-Fin) x right-unit-law-add-Fin {k} x = ( eq-cong-ℕ k ( add-ℕ (nat-Fin x) (nat-Fin {succ-ℕ k} zero-Fin)) ( add-ℕ (nat-Fin x) zero-ℕ) ( congruence-add-ℕ ( succ-ℕ k) { x = nat-Fin {succ-ℕ k} x} { y = nat-Fin {succ-ℕ k} zero-Fin} { x' = nat-Fin x} { y' = zero-ℕ} ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin {succ-ℕ k} x)) ( nat-zero-Fin {k}))) ∙ ( issec-nat-Fin k x) left-unit-law-add-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (add-Fin zero-Fin x) x left-unit-law-add-Fin {k} x = ( commutative-add-Fin zero-Fin x) ∙ ( right-unit-law-add-Fin x) -------------------------------------------------------------------------------- -- We define the negative of x : Fin (succ-ℕ k) -- neg-Fin : {k : ℕ} → Fin k → Fin k neg-Fin {succ-ℕ k} x = mod-succ-ℕ k (dist-ℕ (nat-Fin x) (succ-ℕ k)) cong-neg-Fin : {k : ℕ} (x : Fin k) → cong-ℕ k (nat-Fin (neg-Fin x)) (dist-ℕ (nat-Fin x) k) cong-neg-Fin {succ-ℕ k} x = cong-nat-mod-succ-ℕ k (dist-ℕ (nat-Fin x) (succ-ℕ k)) left-inverse-law-add-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (add-Fin (neg-Fin x) x) zero-Fin left-inverse-law-add-Fin {k} x = eq-cong-ℕ k (add-ℕ (nat-Fin (neg-Fin x)) (nat-Fin x)) zero-ℕ ( concatenate-cong-eq-cong-ℕ { succ-ℕ k} { x1 = add-ℕ (nat-Fin (neg-Fin x)) (nat-Fin x)} { x2 = add-ℕ (dist-ℕ (nat-Fin x) (succ-ℕ k)) (nat-Fin x)} { x3 = succ-ℕ k} { x4 = zero-ℕ} ( congruence-add-ℕ ( succ-ℕ k) { x = nat-Fin (neg-Fin x)} { y = nat-Fin x} ( cong-neg-Fin x) ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin x))) ( ( ap ( add-ℕ (dist-ℕ (nat-Fin x) (succ-ℕ k))) ( inv (left-zero-law-dist-ℕ (nat-Fin x)))) ∙ ( ( commutative-add-ℕ ( dist-ℕ (nat-Fin x) (succ-ℕ k)) ( dist-ℕ zero-ℕ (nat-Fin x))) ∙ ( triangle-equality-dist-ℕ zero-ℕ (nat-Fin x) (succ-ℕ k) star ( preserves-leq-succ-ℕ (nat-Fin x) k (upper-bound-nat-Fin x))))) ( symmetric-cong-ℕ ( succ-ℕ k) ( zero-ℕ) ( succ-ℕ k) ( cong-zero-ℕ (succ-ℕ k)))) right-inverse-law-add-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (add-Fin x (neg-Fin x)) zero-Fin right-inverse-law-add-Fin x = ( commutative-add-Fin x (neg-Fin x)) ∙ (left-inverse-law-add-Fin x) -------------------------------------------------------------------------------- {- Exercises -} -- Exercise 7.1 {- We give a first solution of this exercise using the definition of pred-Fin that doesn't use with-abstraction. -} pred-zero-Fin : {k : ℕ} → Id (pred-Fin {succ-ℕ k} zero-Fin) neg-one-Fin pred-zero-Fin {zero-ℕ} = refl pred-zero-Fin {succ-ℕ k} = ap skip-neg-two-Fin (pred-zero-Fin {k}) succ-skip-neg-two-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (succ-Fin (skip-neg-two-Fin x)) (inl (succ-Fin x)) succ-skip-neg-two-Fin {zero-ℕ} (inr star) = refl succ-skip-neg-two-Fin {succ-ℕ k} (inl x) = refl succ-skip-neg-two-Fin {succ-ℕ k} (inr star) = refl succ-pred-Fin : {k : ℕ} (x : Fin k) → Id (succ-Fin (pred-Fin x)) x succ-pred-Fin {succ-ℕ zero-ℕ} (inr star) = refl succ-pred-Fin {succ-ℕ (succ-ℕ k)} (inl x) = succ-skip-neg-two-Fin (pred-Fin x) ∙ ap inl (succ-pred-Fin x) succ-pred-Fin {succ-ℕ (succ-ℕ k)} (inr star) = refl pred-succ-Fin : {k : ℕ} (x : Fin k) → Id (pred-Fin (succ-Fin x)) x pred-succ-Fin {succ-ℕ zero-ℕ} (inr star) = refl pred-succ-Fin {succ-ℕ (succ-ℕ k)} (inl (inl x)) = ap skip-neg-two-Fin (pred-succ-Fin (inl x)) pred-succ-Fin {succ-ℕ (succ-ℕ k)} (inl (inr star)) = refl pred-succ-Fin {succ-ℕ (succ-ℕ k)} (inr star) = pred-zero-Fin {- We give a solution to the exercise for the alternative definition of the predecessor function, using with-abstraction. -} pred-zero-Fin-2 : {k : ℕ} → Id (pred-Fin-2 {succ-ℕ k} zero-Fin) neg-one-Fin pred-zero-Fin-2 {k} with is-decidable-Eq-Fin (succ-ℕ k) zero-Fin zero-Fin pred-zero-Fin-2 {zero-ℕ} | d = refl pred-zero-Fin-2 {succ-ℕ k} | inl e = refl pred-zero-Fin-2 {succ-ℕ k} | inr f = ex-falso (f (refl-Eq-Fin {succ-ℕ k} zero-Fin)) cases-succ-pred-Fin-2 : {k : ℕ} (x : Fin (succ-ℕ k)) (d : is-decidable (Eq-Fin (succ-ℕ k) x zero-Fin)) → Id (succ-Fin (cases-pred-Fin-2 x d)) x cases-succ-pred-Fin-2 {zero-ℕ} (inr star) d = refl cases-succ-pred-Fin-2 {succ-ℕ k} (inl x) (inl e) = inv (eq-Eq-Fin e) cases-succ-pred-Fin-2 {succ-ℕ zero-ℕ} (inl (inr x)) (inr f) = ex-falso (f star) cases-succ-pred-Fin-2 {succ-ℕ (succ-ℕ k)} (inl (inl x)) (inr f) = ap inl (cases-succ-pred-Fin-2 (inl x) (inr f)) cases-succ-pred-Fin-2 {succ-ℕ (succ-ℕ k)} (inl (inr star)) (inr f) = refl cases-succ-pred-Fin-2 {succ-ℕ k} (inr star) (inr f) = refl succ-pred-Fin-2 : {k : ℕ} (x : Fin k) → Id (succ-Fin (pred-Fin-2 x)) x succ-pred-Fin-2 {succ-ℕ k} x = cases-succ-pred-Fin-2 x (is-decidable-Eq-Fin (succ-ℕ k) x zero-Fin) pred-inl-Fin-2 : {k : ℕ} (x : Fin (succ-ℕ k)) (f : ¬ (Eq-Fin (succ-ℕ k) x zero-Fin)) → Id (pred-Fin-2 (inl x)) (inl (pred-Fin-2 x)) pred-inl-Fin-2 {k} x f with is-decidable-Eq-Fin (succ-ℕ k) x zero-Fin ... | inl e = ex-falso (f e) ... | inr f' = refl nEq-zero-succ-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → ¬ (Eq-Fin (succ-ℕ (succ-ℕ k)) (succ-Fin (inl x)) zero-Fin) nEq-zero-succ-Fin {succ-ℕ k} (inl (inl x)) e = nEq-zero-succ-Fin (inl x) e nEq-zero-succ-Fin {succ-ℕ k} (inl (inr star)) () nEq-zero-succ-Fin {succ-ℕ k} (inr star) () pred-succ-Fin-2 : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (pred-Fin-2 (succ-Fin x)) x pred-succ-Fin-2 {zero-ℕ} (inr star) = refl pred-succ-Fin-2 {succ-ℕ zero-ℕ} (inl (inr star)) = refl pred-succ-Fin-2 {succ-ℕ zero-ℕ} (inr star) = refl pred-succ-Fin-2 {succ-ℕ (succ-ℕ k)} (inl (inl (inl x))) = ( pred-inl-Fin-2 (inl (succ-Fin (inl x))) (nEq-zero-succ-Fin (inl x))) ∙ ( ( ap inl (pred-inl-Fin-2 (succ-Fin (inl x)) (nEq-zero-succ-Fin (inl x)))) ∙ ( ap (inl ∘ inl) (pred-succ-Fin-2 (inl x)))) pred-succ-Fin-2 {succ-ℕ (succ-ℕ k)} (inl (inl (inr star))) = refl pred-succ-Fin-2 {succ-ℕ (succ-ℕ k)} (inl (inr star)) = refl pred-succ-Fin-2 {succ-ℕ (succ-ℕ k)} (inr star) = pred-zero-Fin-2 -------------------------------------------------------------------------------- {- We define the multiplication on the types Fin k. -} mul-Fin : {k : ℕ} → Fin k → Fin k → Fin k mul-Fin {succ-ℕ k} x y = mod-succ-ℕ k (mul-ℕ (nat-Fin x) (nat-Fin y)) ap-mul-Fin : {k : ℕ} {x y x' y' : Fin k} → Id x x' → Id y y' → Id (mul-Fin x y) (mul-Fin x' y') ap-mul-Fin refl refl = refl cong-mul-Fin : {k : ℕ} (x y : Fin k) → cong-ℕ k (nat-Fin (mul-Fin x y)) (mul-ℕ (nat-Fin x) (nat-Fin y)) cong-mul-Fin {succ-ℕ k} x y = cong-nat-mod-succ-ℕ k (mul-ℕ (nat-Fin x) (nat-Fin y)) associative-mul-Fin : {k : ℕ} (x y z : Fin k) → Id (mul-Fin (mul-Fin x y) z) (mul-Fin x (mul-Fin y z)) associative-mul-Fin {succ-ℕ k} x y z = eq-cong-ℕ k ( mul-ℕ (nat-Fin (mul-Fin x y)) (nat-Fin z)) ( mul-ℕ (nat-Fin x) (nat-Fin (mul-Fin y z))) ( concatenate-cong-eq-cong-ℕ { x1 = mul-ℕ (nat-Fin (mul-Fin x y)) (nat-Fin z)} { x2 = mul-ℕ (mul-ℕ (nat-Fin x) (nat-Fin y)) (nat-Fin z)} { x3 = mul-ℕ (nat-Fin x) (mul-ℕ (nat-Fin y) (nat-Fin z))} { x4 = mul-ℕ (nat-Fin x) (nat-Fin (mul-Fin y z))} ( congruence-mul-ℕ ( succ-ℕ k) { x = nat-Fin (mul-Fin x y)} { y = nat-Fin z} ( cong-mul-Fin x y) ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin z))) ( associative-mul-ℕ (nat-Fin x) (nat-Fin y) (nat-Fin z)) ( symmetric-cong-ℕ ( succ-ℕ k) ( mul-ℕ (nat-Fin x) (nat-Fin (mul-Fin y z))) ( mul-ℕ (nat-Fin x) (mul-ℕ (nat-Fin y) (nat-Fin z))) ( congruence-mul-ℕ ( succ-ℕ k) { x = nat-Fin x} { y = nat-Fin (mul-Fin y z)} ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin x)) ( cong-mul-Fin y z)))) commutative-mul-Fin : {k : ℕ} (x y : Fin k) → Id (mul-Fin x y) (mul-Fin y x) commutative-mul-Fin {succ-ℕ k} x y = eq-cong-ℕ k ( mul-ℕ (nat-Fin x) (nat-Fin y)) ( mul-ℕ (nat-Fin y) (nat-Fin x)) ( cong-identification-ℕ ( succ-ℕ k) ( commutative-mul-ℕ (nat-Fin x) (nat-Fin y))) one-Fin : {k : ℕ} → Fin (succ-ℕ k) one-Fin {k} = mod-succ-ℕ k one-ℕ nat-one-Fin : {k : ℕ} → Id (nat-Fin (one-Fin {succ-ℕ k})) one-ℕ nat-one-Fin {zero-ℕ} = refl nat-one-Fin {succ-ℕ k} = nat-one-Fin {k} left-unit-law-mul-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (mul-Fin one-Fin x) x left-unit-law-mul-Fin {zero-ℕ} (inr star) = refl left-unit-law-mul-Fin {succ-ℕ k} x = ( eq-cong-ℕ (succ-ℕ k) ( mul-ℕ (nat-Fin (one-Fin {succ-ℕ k})) (nat-Fin x)) ( nat-Fin x) ( cong-identification-ℕ ( succ-ℕ (succ-ℕ k)) ( ( ap ( mul-ℕ' (nat-Fin x)) ( nat-one-Fin {k})) ∙ ( left-unit-law-mul-ℕ (nat-Fin x))))) ∙ ( issec-nat-Fin (succ-ℕ k) x) right-unit-law-mul-Fin : {k : ℕ} (x : Fin (succ-ℕ k)) → Id (mul-Fin x one-Fin) x right-unit-law-mul-Fin x = ( commutative-mul-Fin x one-Fin) ∙ ( left-unit-law-mul-Fin x) -------------------------------------------------------------------------------- left-distributive-mul-add-Fin : {k : ℕ} (x y z : Fin k) → Id (mul-Fin x (add-Fin y z)) (add-Fin (mul-Fin x y) (mul-Fin x z)) left-distributive-mul-add-Fin {succ-ℕ k} x y z = eq-cong-ℕ k ( mul-ℕ (nat-Fin x) (nat-Fin (add-Fin y z))) ( add-ℕ (nat-Fin (mul-Fin x y)) (nat-Fin (mul-Fin x z))) ( concatenate-cong-eq-cong-ℕ { k = succ-ℕ k} { x1 = mul-ℕ ( nat-Fin x) (nat-Fin (add-Fin y z))} { x2 = mul-ℕ ( nat-Fin x) (add-ℕ (nat-Fin y) (nat-Fin z))} { x3 = add-ℕ ( mul-ℕ (nat-Fin x) (nat-Fin y)) ( mul-ℕ (nat-Fin x) (nat-Fin z))} { x4 = add-ℕ (nat-Fin (mul-Fin x y)) (nat-Fin (mul-Fin x z))} ( congruence-mul-ℕ ( succ-ℕ k) { x = nat-Fin x} { y = nat-Fin (add-Fin y z)} { x' = nat-Fin x} { y' = add-ℕ (nat-Fin y) (nat-Fin z)} ( reflexive-cong-ℕ (succ-ℕ k) (nat-Fin x)) ( cong-add-Fin y z)) ( left-distributive-mul-add-ℕ (nat-Fin x) (nat-Fin y) (nat-Fin z)) ( symmetric-cong-ℕ (succ-ℕ k) ( add-ℕ ( nat-Fin (mul-Fin x y)) ( nat-Fin (mul-Fin x z))) ( add-ℕ ( mul-ℕ (nat-Fin x) (nat-Fin y)) ( mul-ℕ (nat-Fin x) (nat-Fin z))) ( congruence-add-ℕ ( succ-ℕ k) { x = nat-Fin (mul-Fin x y)} { y = nat-Fin (mul-Fin x z)} { x' = mul-ℕ (nat-Fin x) (nat-Fin y)} { y' = mul-ℕ (nat-Fin x) (nat-Fin z)} ( cong-mul-Fin x y) ( cong-mul-Fin x z)))) right-distributive-mul-add-Fin : {k : ℕ} (x y z : Fin k) → Id (mul-Fin (add-Fin x y) z) (add-Fin (mul-Fin x z) (mul-Fin y z)) right-distributive-mul-add-Fin {k} x y z = ( commutative-mul-Fin (add-Fin x y) z) ∙ ( ( left-distributive-mul-add-Fin z x y) ∙ ( ap-add-Fin (commutative-mul-Fin z x) (commutative-mul-Fin z y))) -------------------------------------------------------------------------------- {- -- We introduce the absolute value of an integer. -- abs-ℤ : ℤ → ℕ abs-ℤ (inl x) = succ-ℕ x abs-ℤ (inr (inl star)) = zero-ℕ abs-ℤ (inr (inr x)) = succ-ℕ x int-abs-ℤ : ℤ → ℤ int-abs-ℤ = int-ℕ ∘ abs-ℤ eq-abs-ℤ : (x : ℤ) → Id zero-ℕ (abs-ℤ x) → Id zero-ℤ x eq-abs-ℤ (inl x) p = ex-falso (Peano-8 x p) eq-abs-ℤ (inr (inl star)) p = refl eq-abs-ℤ (inr (inr x)) p = ex-falso (Peano-8 x p) abs-eq-ℤ : (x : ℤ) → Id zero-ℤ x → Id zero-ℕ (abs-ℤ x) abs-eq-ℤ .zero-ℤ refl = refl negatives-add-ℤ : (x y : ℕ) → Id (add-ℤ (in-neg x) (in-neg y)) (in-neg (succ-ℕ (add-ℕ x y))) negatives-add-ℤ zero-ℕ y = ap (inl ∘ succ-ℕ) (inv (left-unit-law-add-ℕ y)) negatives-add-ℤ (succ-ℕ x) y = ( ap pred-ℤ (negatives-add-ℤ x y)) ∙ ( ap (inl ∘ succ-ℕ) (inv (left-successor-law-add-ℕ x y))) subadditive-abs-ℤ : (x y : ℤ) → leq-ℕ (abs-ℤ (add-ℤ x y)) (add-ℕ (abs-ℤ x) (abs-ℤ y)) subadditive-abs-ℤ (inl x) (inl y) = leq-eq-ℕ ( abs-ℤ (add-ℤ (inl x) (inl y))) ( add-ℕ (succ-ℕ x) (succ-ℕ y)) ( ( ap abs-ℤ (negatives-add-ℤ x y)) ∙ ( ap succ-ℕ (inv (left-successor-law-add-ℕ x y)))) subadditive-abs-ℤ (inl x) (inr (inl star)) = leq-eq-ℕ ( abs-ℤ (add-ℤ (inl x) zero-ℤ)) ( add-ℕ (succ-ℕ x) zero-ℕ) ( ap abs-ℤ (right-unit-law-add-ℤ (inl x))) subadditive-abs-ℤ (inl zero-ℕ) (inr (inr zero-ℕ)) = star subadditive-abs-ℤ (inl zero-ℕ) (inr (inr (succ-ℕ y))) = concatenate-leq-eq-ℕ ( succ-ℕ y) ( preserves-leq-succ-ℕ (succ-ℕ y) (succ-ℕ (succ-ℕ y)) (succ-leq-ℕ y)) ( inv ( ( left-successor-law-add-ℕ zero-ℕ (succ-ℕ (succ-ℕ y))) ∙ ( ap succ-ℕ (left-unit-law-add-ℕ (succ-ℕ (succ-ℕ y)))))) subadditive-abs-ℤ (inl (succ-ℕ x)) (inr (inr zero-ℕ)) = {!!} subadditive-abs-ℤ (inl (succ-ℕ x)) (inr (inr (succ-ℕ y))) = {!!} subadditive-abs-ℤ (inr x) (inl y) = {!!} subadditive-abs-ℤ (inr x) (inr y) = {!!} -------------------------------------------------------------------------------- dist-ℤ : ℤ → ℤ → ℕ dist-ℤ (inl x) (inl y) = dist-ℕ x y dist-ℤ (inl x) (inr (inl star)) = succ-ℕ x dist-ℤ (inl x) (inr (inr y)) = succ-ℕ (succ-ℕ (add-ℕ x y)) dist-ℤ (inr (inl star)) (inl y) = succ-ℕ y dist-ℤ (inr (inr x)) (inl y) = succ-ℕ (succ-ℕ (add-ℕ x y)) dist-ℤ (inr (inl star)) (inr (inl star)) = zero-ℕ dist-ℤ (inr (inl star)) (inr (inr y)) = succ-ℕ y dist-ℤ (inr (inr x)) (inr (inl star)) = succ-ℕ x dist-ℤ (inr (inr x)) (inr (inr y)) = dist-ℕ x y dist-ℤ' : ℤ → ℤ → ℕ dist-ℤ' x y = dist-ℤ y x ap-dist-ℤ : {x y x' y' : ℤ} → Id x x' → Id y y' → Id (dist-ℤ x y) (dist-ℤ x' y') ap-dist-ℤ refl refl = refl eq-dist-ℤ : (x y : ℤ) → Id zero-ℕ (dist-ℤ x y) → Id x y eq-dist-ℤ (inl x) (inl y) p = ap inl (eq-dist-ℕ x y p) eq-dist-ℤ (inl x) (inr (inl star)) p = ex-falso (Peano-8 x p) eq-dist-ℤ (inr (inl star)) (inl y) p = ex-falso (Peano-8 y p) eq-dist-ℤ (inr (inl star)) (inr (inl star)) p = refl eq-dist-ℤ (inr (inl star)) (inr (inr y)) p = ex-falso (Peano-8 y p) eq-dist-ℤ (inr (inr x)) (inr (inl star)) p = ex-falso (Peano-8 x p) eq-dist-ℤ (inr (inr x)) (inr (inr y)) p = ap (inr ∘ inr) (eq-dist-ℕ x y p) dist-eq-ℤ' : (x : ℤ) → Id zero-ℕ (dist-ℤ x x) dist-eq-ℤ' (inl x) = dist-eq-ℕ' x dist-eq-ℤ' (inr (inl star)) = refl dist-eq-ℤ' (inr (inr x)) = dist-eq-ℕ' x dist-eq-ℤ : (x y : ℤ) → Id x y → Id zero-ℕ (dist-ℤ x y) dist-eq-ℤ x .x refl = dist-eq-ℤ' x {- The distance function on ℤ is symmetric. -} symmetric-dist-ℤ : (x y : ℤ) → Id (dist-ℤ x y) (dist-ℤ y x) symmetric-dist-ℤ (inl x) (inl y) = symmetric-dist-ℕ x y symmetric-dist-ℤ (inl x) (inr (inl star)) = refl symmetric-dist-ℤ (inl x) (inr (inr y)) = ap (succ-ℕ ∘ succ-ℕ) (commutative-add-ℕ x y) symmetric-dist-ℤ (inr (inl star)) (inl y) = refl symmetric-dist-ℤ (inr (inr x)) (inl y) = ap (succ-ℕ ∘ succ-ℕ) (commutative-add-ℕ x y) symmetric-dist-ℤ (inr (inl star)) (inr (inl star)) = refl symmetric-dist-ℤ (inr (inl star)) (inr (inr y)) = refl symmetric-dist-ℤ (inr (inr x)) (inr (inl star)) = refl symmetric-dist-ℤ (inr (inr x)) (inr (inr y)) = symmetric-dist-ℕ x y -- We compute the distance from zero -- left-zero-law-dist-ℤ : (x : ℤ) → Id (dist-ℤ zero-ℤ x) (abs-ℤ x) left-zero-law-dist-ℤ (inl x) = refl left-zero-law-dist-ℤ (inr (inl star)) = refl left-zero-law-dist-ℤ (inr (inr x)) = refl right-zero-law-dist-ℤ : (x : ℤ) → Id (dist-ℤ x zero-ℤ) (abs-ℤ x) right-zero-law-dist-ℤ (inl x) = refl right-zero-law-dist-ℤ (inr (inl star)) = refl right-zero-law-dist-ℤ (inr (inr x)) = refl -- We prove the triangle inequality -- triangle-inequality-dist-ℤ : (x y z : ℤ) → leq-ℕ (dist-ℤ x y) (add-ℕ (dist-ℤ x z) (dist-ℤ z y)) triangle-inequality-dist-ℤ (inl x) (inl y) (inl z) = triangle-inequality-dist-ℕ x y z triangle-inequality-dist-ℤ (inl x) (inl y) (inr (inl star)) = triangle-inequality-dist-ℕ (succ-ℕ x) (succ-ℕ y) zero-ℕ triangle-inequality-dist-ℤ (inl x) (inl y) (inr (inr z)) = {!!} triangle-inequality-dist-ℤ (inl x) (inr y) (inl z) = {!!} triangle-inequality-dist-ℤ (inl x) (inr y) (inr z) = {!!} triangle-inequality-dist-ℤ (inr x) (inl y) (inl z) = {!!} triangle-inequality-dist-ℤ (inr x) (inl y) (inr z) = {!!} triangle-inequality-dist-ℤ (inr x) (inr y) (inl z) = {!!} triangle-inequality-dist-ℤ (inr x) (inr y) (inr z) = {!!} {- triangle-inequality-dist-ℕ : (m n k : ℕ) → leq-ℕ (dist-ℕ m n) (add-ℕ (dist-ℕ m k) (dist-ℕ k n)) triangle-inequality-dist-ℕ zero-ℕ zero-ℕ zero-ℕ = star triangle-inequality-dist-ℕ zero-ℕ zero-ℕ (succ-ℕ k) = star triangle-inequality-dist-ℕ zero-ℕ (succ-ℕ n) zero-ℕ = tr ( leq-ℕ (succ-ℕ n)) ( inv (left-unit-law-add-ℕ (succ-ℕ n))) ( reflexive-leq-ℕ (succ-ℕ n)) triangle-inequality-dist-ℕ zero-ℕ (succ-ℕ n) (succ-ℕ k) = concatenate-eq-leq-eq-ℕ ( inv (ap succ-ℕ (left-zero-law-dist-ℕ n))) ( triangle-inequality-dist-ℕ zero-ℕ n k) ( ( ap (succ-ℕ ∘ (add-ℕ' (dist-ℕ k n))) (left-zero-law-dist-ℕ k)) ∙ ( inv (left-successor-law-add-ℕ k (dist-ℕ k n)))) triangle-inequality-dist-ℕ (succ-ℕ m) zero-ℕ zero-ℕ = reflexive-leq-ℕ (succ-ℕ m) triangle-inequality-dist-ℕ (succ-ℕ m) zero-ℕ (succ-ℕ k) = concatenate-eq-leq-eq-ℕ ( inv (ap succ-ℕ (right-zero-law-dist-ℕ m))) ( triangle-inequality-dist-ℕ m zero-ℕ k) ( ap (succ-ℕ ∘ (add-ℕ (dist-ℕ m k))) (right-zero-law-dist-ℕ k)) triangle-inequality-dist-ℕ (succ-ℕ m) (succ-ℕ n) zero-ℕ = concatenate-leq-eq-ℕ ( dist-ℕ m n) ( transitive-leq-ℕ ( dist-ℕ m n) ( succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n))) ( succ-ℕ (succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n)))) ( transitive-leq-ℕ ( dist-ℕ m n) ( add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n)) ( succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n))) ( triangle-inequality-dist-ℕ m n zero-ℕ) ( succ-leq-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n)))) ( succ-leq-ℕ (succ-ℕ (add-ℕ (dist-ℕ m zero-ℕ) (dist-ℕ zero-ℕ n))))) ( ( ap (succ-ℕ ∘ succ-ℕ) ( ap-add-ℕ (right-zero-law-dist-ℕ m) (left-zero-law-dist-ℕ n))) ∙ ( inv (left-successor-law-add-ℕ m (succ-ℕ n)))) triangle-inequality-dist-ℕ (succ-ℕ m) (succ-ℕ n) (succ-ℕ k) = triangle-inequality-dist-ℕ m n k -- We show that dist-ℕ x y is a solution to a simple equation. leq-dist-ℕ : (x y : ℕ) → leq-ℕ x y → Id (add-ℕ x (dist-ℕ x y)) y leq-dist-ℕ zero-ℕ zero-ℕ H = refl leq-dist-ℕ zero-ℕ (succ-ℕ y) star = left-unit-law-add-ℕ (succ-ℕ y) leq-dist-ℕ (succ-ℕ x) (succ-ℕ y) H = ( left-successor-law-add-ℕ x (dist-ℕ x y)) ∙ ( ap succ-ℕ (leq-dist-ℕ x y H)) rewrite-left-add-dist-ℕ : (x y z : ℕ) → Id (add-ℕ x y) z → Id x (dist-ℕ y z) rewrite-left-add-dist-ℕ zero-ℕ zero-ℕ .zero-ℕ refl = refl rewrite-left-add-dist-ℕ zero-ℕ (succ-ℕ y) .(succ-ℕ (add-ℕ zero-ℕ y)) refl = ( dist-eq-ℕ' y) ∙ ( inv (ap (dist-ℕ (succ-ℕ y)) (left-unit-law-add-ℕ (succ-ℕ y)))) rewrite-left-add-dist-ℕ (succ-ℕ x) zero-ℕ .(succ-ℕ x) refl = refl rewrite-left-add-dist-ℕ (succ-ℕ x) (succ-ℕ y) .(succ-ℕ (add-ℕ (succ-ℕ x) y)) refl = rewrite-left-add-dist-ℕ (succ-ℕ x) y (add-ℕ (succ-ℕ x) y) refl rewrite-left-dist-add-ℕ : (x y z : ℕ) → leq-ℕ y z → Id x (dist-ℕ y z) → Id (add-ℕ x y) z rewrite-left-dist-add-ℕ .(dist-ℕ y z) y z H refl = ( commutative-add-ℕ (dist-ℕ y z) y) ∙ ( leq-dist-ℕ y z H) rewrite-right-add-dist-ℕ : (x y z : ℕ) → Id (add-ℕ x y) z → Id y (dist-ℕ x z) rewrite-right-add-dist-ℕ x y z p = rewrite-left-add-dist-ℕ y x z (commutative-add-ℕ y x ∙ p) rewrite-right-dist-add-ℕ : (x y z : ℕ) → leq-ℕ x z → Id y (dist-ℕ x z) → Id (add-ℕ x y) z rewrite-right-dist-add-ℕ x .(dist-ℕ x z) z H refl = leq-dist-ℕ x z H -- We show that dist-ℕ is translation invariant translation-invariant-dist-ℕ : (k m n : ℕ) → Id (dist-ℕ (add-ℕ k m) (add-ℕ k n)) (dist-ℕ m n) translation-invariant-dist-ℕ zero-ℕ m n = ap-dist-ℕ (left-unit-law-add-ℕ m) (left-unit-law-add-ℕ n) translation-invariant-dist-ℕ (succ-ℕ k) m n = ( ap-dist-ℕ (left-successor-law-add-ℕ k m) (left-successor-law-add-ℕ k n)) ∙ ( translation-invariant-dist-ℕ k m n) -- We show that dist-ℕ is linear with respect to scalar multiplication linear-dist-ℕ : (m n k : ℕ) → Id (dist-ℕ (mul-ℕ k m) (mul-ℕ k n)) (mul-ℕ k (dist-ℕ m n)) linear-dist-ℕ zero-ℕ zero-ℕ zero-ℕ = refl linear-dist-ℕ zero-ℕ zero-ℕ (succ-ℕ k) = linear-dist-ℕ zero-ℕ zero-ℕ k linear-dist-ℕ zero-ℕ (succ-ℕ n) zero-ℕ = refl linear-dist-ℕ zero-ℕ (succ-ℕ n) (succ-ℕ k) = ap (dist-ℕ' (mul-ℕ (succ-ℕ k) (succ-ℕ n))) (right-zero-law-mul-ℕ (succ-ℕ k)) linear-dist-ℕ (succ-ℕ m) zero-ℕ zero-ℕ = refl linear-dist-ℕ (succ-ℕ m) zero-ℕ (succ-ℕ k) = ap (dist-ℕ (mul-ℕ (succ-ℕ k) (succ-ℕ m))) (right-zero-law-mul-ℕ (succ-ℕ k)) linear-dist-ℕ (succ-ℕ m) (succ-ℕ n) zero-ℕ = refl linear-dist-ℕ (succ-ℕ m) (succ-ℕ n) (succ-ℕ k) = ( ap-dist-ℕ ( right-successor-law-mul-ℕ (succ-ℕ k) m) ( right-successor-law-mul-ℕ (succ-ℕ k) n)) ∙ ( ( translation-invariant-dist-ℕ ( succ-ℕ k) ( mul-ℕ (succ-ℕ k) m) ( mul-ℕ (succ-ℕ k) n)) ∙ ( linear-dist-ℕ m n (succ-ℕ k))) -} -}
{ "alphanum_fraction": 0.5522143248, "avg_line_length": 35.4, "ext": "agda", "hexsha": "c8a59cf4002d55c4bc06378a0732776245ff6ef3", "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": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_forks_repo_licenses": [ "CC-BY-4.0" ], "max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_forks_repo_path": "Agda/07-finite-sets.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC-BY-4.0" ], "max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_issues_repo_path": "Agda/07-finite-sets.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9", "max_stars_repo_licenses": [ "CC-BY-4.0" ], "max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro", "max_stars_repo_path": "Agda/07-finite-sets.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 21715, "size": 49383 }
------------------------------------------------------------------------------ -- Testing polymorphic lists using data types ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Polymorphism.List where open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.Bool.Type open import FOTC.Data.List.Type open import FOTC.Data.Nat.List.Type open import FOTC.Data.Nat.Type open import FOTC.Data.Nat.UnaryNumbers ------------------------------------------------------------------------------ -- "Heterogeneous" total lists xs : D xs = 0' ∷ true ∷ 1' ∷ false ∷ [] xs-List : List xs xs-List = lcons 0' (lcons true (lcons 1' (lcons false lnil))) -- Total lists of total natural numbers ys : D ys = 0' ∷ 1' ∷ 2' ∷ [] ys-ListN : ListN ys ys-ListN = lncons nzero (lncons (nsucc nzero) (lncons (nsucc (nsucc nzero)) lnnil)) -- Total lists of total Booleans data ListB : D → Set where lbnil : ListB [] lbcons : ∀ {b bs} → Bool b → ListB bs → ListB (b ∷ bs) zs : D zs = true ∷ false ∷ true ∷ [] zs-ListB : ListB zs zs-ListB = lbcons btrue (lbcons bfalse (lbcons btrue lbnil)) ------------------------------------------------------------------------------ -- Polymorphic lists. data Plist (P : D → Set) : D → Set where lnil : Plist P [] lcons : ∀ {x xs} → P x → Plist P xs → Plist P (x ∷ xs) -- "Heterogeneous" total lists List₁ : D → Set List₁ = Plist (λ d → d ≡ d) xs-List₁ : List₁ xs xs-List₁ = lcons refl (lcons refl (lcons refl (lcons refl lnil))) -- Total lists of total natural numbers ListN₁ : D → Set ListN₁ = Plist N ys-ListN₁ : ListN₁ ys ys-ListN₁ = lcons nzero (lcons (nsucc nzero) (lcons (nsucc (nsucc nzero)) lnil)) -- Total lists of total Booleans ListB₁ : D → Set ListB₁ = Plist Bool zs-ListB₁ : ListB₁ zs zs-ListB₁ = lcons btrue (lcons bfalse (lcons btrue lnil))
{ "alphanum_fraction": 0.5345821326, "avg_line_length": 28.5205479452, "ext": "agda", "hexsha": "299a852c9841ee9d6a016a12bf43323e193c683e", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Polymorphism/List.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Polymorphism/List.agda", "max_line_length": 80, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Polymorphism/List.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": 613, "size": 2082 }
-- Andreas, 2020-05-27 AIM XXXII, issue 4679 -- reported by Ayberk Tosun. {-# OPTIONS --safe --cubical #-} -- {-# OPTIONS -v tc.def.fun:10 #-} -- {-# OPTIONS -v tc.cover.iapply:10 #-} open import Agda.Primitive.Cubical renaming (primTransp to transp) open import Agda.Builtin.Cubical.Path using (_≡_) data ⊥ : Set where data Unit : Set where tt : Unit transport : {A B : Set} → A ≡ B → A → B transport p a = transp (λ i → p i) i0 a subst : ∀{A : Set} {x y : A} (B : A → Set) (p : x ≡ y) → B x → B y subst B p pa = transport (λ i → B (p i)) pa data Foo : Set where bar : Unit → Foo baz : Unit → Foo squash : (x y : Foo) → x ≡ y bar≢baz : (x y : Unit) → bar x ≡ baz y → ⊥ bar≢baz tt tt p = subst {! λ { (bar _) → Unit ; (baz _) → ⊥ ; _ → ⊥ } !} p tt -- -- This function does not check: -- where -- P : Foo → Set -- P (bar _) = Unit -- P (baz _) = ⊥ -- P _ = ⊥ -- -- P p x != ⊥ of type Set -- -- when checking the definition of P -- Giving the extended lambda should fail -- since it fails boundary conditions (checkIApplyConfluence).
{ "alphanum_fraction": 0.5623268698, "avg_line_length": 26.4146341463, "ext": "agda", "hexsha": "ec078b32285e617a7baf626b7bbf6fbbaa481821", "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": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/interaction/Issue4679.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/Issue4679.agda", "max_line_length": 66, "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/Issue4679.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": 390, "size": 1083 }
------------------------------------------------------------------------------ -- Proving properties without using pattern matching on refl ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.NoPatternMatchingOnRefl where open import FOTC.Base open import FOTC.Base.List open import FOTC.Data.Bool open import FOTC.Data.Conat open import FOTC.Data.Conat.Equality.Type renaming ( _≈_ to _≈N_ ; ≈-coind to ≈N-coind ) open import FOTC.Data.List open import FOTC.Data.Nat open import FOTC.Data.Nat.Inequalities open import FOTC.Data.Stream.Type open import FOTC.Program.McCarthy91.McCarthy91 open import FOTC.Relation.Binary.Bisimilarity.PropertiesI open import FOTC.Relation.Binary.Bisimilarity.Type ------------------------------------------------------------------------------ -- From FOTC.Base.PropertiesI -- Congruence properties ·-leftCong : ∀ {a b c} → a ≡ b → a · c ≡ b · c ·-leftCong {a} {c = c} h = subst (λ t → a · c ≡ t · c) h refl ·-rightCong : ∀ {a b c} → b ≡ c → a · b ≡ a · c ·-rightCong {a} {b} h = subst (λ t → a · b ≡ a · t) h refl ·-cong : ∀ {a b c d} → a ≡ b → c ≡ d → a · c ≡ b · d ·-cong {a} {c = c} h₁ h₂ = subst₂ (λ t₁ t₂ → a · c ≡ t₁ · t₂) h₁ h₂ refl succCong : ∀ {m n} → m ≡ n → succ₁ m ≡ succ₁ n succCong {m} h = subst (λ t → succ₁ m ≡ succ₁ t) h refl predCong : ∀ {m n} → m ≡ n → pred₁ m ≡ pred₁ n predCong {m} h = subst (λ t → pred₁ m ≡ pred₁ t) h refl ifCong₁ : ∀ {b b' t t'} → b ≡ b' → (if b then t else t') ≡ (if b' then t else t') ifCong₁ {b} {t = t} {t'} h = subst (λ x → (if b then t else t') ≡ (if x then t else t')) h refl ifCong₂ : ∀ {b t₁ t₂ t} → t₁ ≡ t₂ → (if b then t₁ else t) ≡ (if b then t₂ else t) ifCong₂ {b} {t₁} {t = t} h = subst (λ x → (if b then t₁ else t) ≡ (if b then x else t)) h refl ifCong₃ : ∀ {b t t₁ t₂} → t₁ ≡ t₂ → (if b then t else t₁) ≡ (if b then t else t₂) ifCong₃ {b} {t} {t₁} h = subst (λ x → (if b then t else t₁) ≡ (if b then t else x)) h refl ------------------------------------------------------------------------------ -- From FOTC.Base.List.PropertiesI -- Congruence properties ∷-leftCong : ∀ {x y xs} → x ≡ y → x ∷ xs ≡ y ∷ xs ∷-leftCong {x} {xs = xs} h = subst (λ t → x ∷ xs ≡ t ∷ xs) h refl ∷-rightCong : ∀ {x xs ys} → xs ≡ ys → x ∷ xs ≡ x ∷ ys ∷-rightCong {x}{xs} h = subst (λ t → x ∷ xs ≡ x ∷ t) h refl ∷-Cong : ∀ {x y xs ys} → x ≡ y → xs ≡ ys → x ∷ xs ≡ y ∷ ys ∷-Cong {x} {xs = xs} h₁ h₂ = subst₂ (λ t₁ t₂ → x ∷ xs ≡ t₁ ∷ t₂) h₁ h₂ refl headCong : ∀ {xs ys} → xs ≡ ys → head₁ xs ≡ head₁ ys headCong {xs} h = subst (λ t → head₁ xs ≡ head₁ t) h refl tailCong : ∀ {xs ys} → xs ≡ ys → tail₁ xs ≡ tail₁ ys tailCong {xs} h = subst (λ t → tail₁ xs ≡ tail₁ t) h refl ------------------------------------------------------------------------------ -- From FOTC.Data.Bool.PropertiesI -- Congruence properties &&-leftCong : ∀ {a b c} → a ≡ b → a && c ≡ b && c &&-leftCong {a} {c = c} h = subst (λ t → a && c ≡ t && c) h refl &&-rightCong : ∀ {a b c} → b ≡ c → a && b ≡ a && c &&-rightCong {a} {b} h = subst (λ t → a && b ≡ a && t) h refl &&-cong : ∀ {a b c d } → a ≡ c → b ≡ d → a && b ≡ c && d &&-cong {a} {b} h₁ h₂ = subst₂ (λ t₁ t₂ → a && b ≡ t₁ && t₂) h₁ h₂ refl notCong : ∀ {a b} → a ≡ b → not a ≡ not b notCong {a} h = subst (λ t → not a ≡ not t) h refl ------------------------------------------------------------------------------ -- FOTC.Data.Conat.Equality.PropertiesI ≈N-refl : ∀ {n} → Conat n → n ≈N n ≈N-refl {n} Cn = ≈N-coind R h₁ h₂ where R : D → D → Set R a b = Conat a ∧ Conat b ∧ a ≡ b h₁ : ∀ {a b} → R a b → a ≡ zero ∧ b ≡ zero ∨ (∃[ a' ] ∃[ b' ] a ≡ succ₁ a' ∧ b ≡ succ₁ b' ∧ R a' b') h₁ (Ca , Cb , h) with Conat-out Ca ... | inj₁ prf = inj₁ (prf , trans (sym h) prf) ... | inj₂ (a' , prf , Ca') = inj₂ (a' , a' , prf , trans (sym h) prf , (Ca' , Ca' , refl)) h₂ : R n n h₂ = Cn , Cn , refl ≡→≈ : ∀ {m n} → Conat m → Conat n → m ≡ n → m ≈N n ≡→≈ {m} Cm _ h = subst (_≈N_ m) h (≈N-refl Cm) ------------------------------------------------------------------------------ -- FOTC.Data.List.PropertiesI -- Congruence properties ++-leftCong : ∀ {xs ys zs} → xs ≡ ys → xs ++ zs ≡ ys ++ zs ++-leftCong {xs} {zs = zs} h = subst (λ t → xs ++ zs ≡ t ++ zs) h refl ++-rightCong : ∀ {xs ys zs} → ys ≡ zs → xs ++ ys ≡ xs ++ zs ++-rightCong {xs} {ys} h = subst (λ t → xs ++ ys ≡ xs ++ t) h refl mapCong₂ : ∀ {f xs ys} → xs ≡ ys → map f xs ≡ map f ys mapCong₂ {f} {xs} h = subst (λ t → map f xs ≡ map f t) h refl revCong₁ : ∀ {xs ys zs} → xs ≡ ys → rev xs zs ≡ rev ys zs revCong₁ {xs} {zs = zs} h = subst (λ t → rev xs zs ≡ rev t zs) h refl revCong₂ : ∀ {xs ys zs} → ys ≡ zs → rev xs ys ≡ rev xs zs revCong₂ {xs} {ys} h = subst (λ t → rev xs ys ≡ rev xs t) h refl reverseCong : ∀ {xs ys} → xs ≡ ys → reverse xs ≡ reverse ys reverseCong {xs} h = subst (λ t → reverse xs ≡ reverse t) h refl lengthCong : ∀ {xs ys} → xs ≡ ys → length xs ≡ length ys lengthCong {xs} h = subst (λ t → length xs ≡ length t) h refl ------------------------------------------------------------------------------ -- From FOTC.Data.Nat.Inequalities.PropertiesI -- Congruence properties leLeftCong : ∀ {m n o} → m ≡ n → le m o ≡ le n o leLeftCong {m} {o = o} h = subst (λ t → le m o ≡ le t o) h refl ltLeftCong : ∀ {m n o} → m ≡ n → lt m o ≡ lt n o ltLeftCong {m} {o = o} h = subst (λ t → lt m o ≡ lt t o) h refl ltRightCong : ∀ {m n o} → n ≡ o → lt m n ≡ lt m o ltRightCong {m} {n} h = subst (λ t → lt m n ≡ lt m t) h refl ltCong : ∀ {m₁ n₁ m₂ n₂} → m₁ ≡ m₂ → n₁ ≡ n₂ → lt m₁ n₁ ≡ lt m₂ n₂ ltCong {m₁} {n₁} h₁ h₂ = subst₂ (λ t₁ t₂ → lt m₁ n₁ ≡ lt t₁ t₂) h₁ h₂ refl ------------------------------------------------------------------------------ -- From FOTC.Data.Nat.PropertiesI -- Congruence properties +-leftCong : ∀ {m n o} → m ≡ n → m + o ≡ n + o +-leftCong {m} {o = o} h = subst (λ t → m + o ≡ t + o) h refl +-rightCong : ∀ {m n o} → n ≡ o → m + n ≡ m + o +-rightCong {m} {n} h = subst (λ t → m + n ≡ m + t) h refl ∸-leftCong : ∀ {m n o} → m ≡ n → m ∸ o ≡ n ∸ o ∸-leftCong {m} {o = o} h = subst (λ t → m ∸ o ≡ t ∸ o) h refl ∸-rightCong : ∀ {m n o} → n ≡ o → m ∸ n ≡ m ∸ o ∸-rightCong {m} {n} h = subst (λ t → m ∸ n ≡ m ∸ t) h refl *-leftCong : ∀ {m n o} → m ≡ n → m * o ≡ n * o *-leftCong {m} {o = o} h = subst (λ t → m * o ≡ t * o) h refl *-rightCong : ∀ {m n o} → n ≡ o → m * n ≡ m * o *-rightCong {m} {n} h = subst (λ t → m * n ≡ m * t) h refl ------------------------------------------------------------------------------ -- From FOT.FOTC.Data.Stream.Equality.PropertiesI where stream-≡→≈ : ∀ {xs ys} → Stream xs → Stream ys → xs ≡ ys → xs ≈ ys stream-≡→≈ {xs} Sxs _ h = subst (_≈_ xs) h (≈-refl Sxs) ------------------------------------------------------------------------------ -- From FOTC.Program.McCarthy91.AuxiliaryPropertiesATP f₉₁-x≡y : ∀ {m n o} → f₉₁ m ≡ n → o ≡ m → f₉₁ o ≡ n f₉₁-x≡y {n = n} h₁ h₂ = subst (λ t → f₉₁ t ≡ n) (sym h₂) h₁
{ "alphanum_fraction": 0.467987167, "avg_line_length": 35.1421568627, "ext": "agda", "hexsha": "76c4473280441646add2fb7106920a6407714c66", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/NoPatternMatchingOnRefl.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/NoPatternMatchingOnRefl.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/NoPatternMatchingOnRefl.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": 2833, "size": 7169 }
module Issue329 where mutual infixl 0 D Undeclared data D : Set where
{ "alphanum_fraction": 0.7368421053, "avg_line_length": 10.8571428571, "ext": "agda", "hexsha": "f51030b77e641981a50f20a2a81dc1f1861bfee2", "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": "test/fail/Issue329.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/Issue329.agda", "max_line_length": 23, "max_stars_count": 3, "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/Fail/Issue329.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": 26, "size": 76 }
{-# OPTIONS --universe-polymorphism #-} open import Categories.Category module Categories.Object.SubobjectClassifier {o ℓ e} (C : Category o ℓ e) where open Category C open import Level open import Categories.Object.Terminal open import Categories.Morphisms open import Categories.Pullback record SubobjectClassifier : Set (o ⊔ ℓ ⊔ e) where field Ω : Obj χ : ∀ {U X} → (j : U ⇒ X) → (X ⇒ Ω) terminal : Terminal C open Terminal terminal field ⊤⇒Ω : ⊤ ⇒ Ω .j-pullback : ∀ {U X} → (j : U ⇒ X) → Mono C j → Pullback C ⊤⇒Ω (χ j) .χ-unique : ∀ {U X} → (j : U ⇒ X) → (χ′ : X ⇒ Ω) → Mono C j → Pullback C ⊤⇒Ω χ′ → χ′ ≡ χ j
{ "alphanum_fraction": 0.6100917431, "avg_line_length": 23.3571428571, "ext": "agda", "hexsha": "b61eaf788cc99db072c3c097bb008ca43857477b", "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/SubobjectClassifier.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/SubobjectClassifier.agda", "max_line_length": 94, "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/SubobjectClassifier.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": 241, "size": 654 }
import Lvl open import Type open import Structure.Setoid module Type.Singleton {ℓ ℓₑ : Lvl.Level} {X : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(X) ⦄ where open import Functional open import Function.Domains open import Logic.Predicate -- A type with only a single object Singleton : X → Type{ℓₑ Lvl.⊔ ℓ} Singleton(x) = ∃(Fiber(id) (x))
{ "alphanum_fraction": 0.7078313253, "avg_line_length": 23.7142857143, "ext": "agda", "hexsha": "c2977e6639fbd099a92b2fb000bc1f0a01c833d0", "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": "Type/Singleton.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": "Type/Singleton.agda", "max_line_length": 85, "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": "Type/Singleton.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": 115, "size": 332 }
open import SingleSorted.AlgebraicTheory open import Agda.Primitive using (lzero; lsuc; _⊔_) open import Relation.Binary.PropositionalEquality using (_≡_; refl) open import SingleSorted.Substitution open import Data.Nat using (ℕ; zero; suc; _+_; _*_) module SingleSorted.Group where data GroupOp : Set where e : GroupOp inv : GroupOp mul : GroupOp _ : Context _ = ctx-empty _ : Context _ = ctx-concat ctx-slot ctx-empty _ : var ctx-slot _ = var-var _ : var (ctx-concat ctx-slot ctx-slot) _ = var-inl var-var _ : var (ctx-concat ctx-slot ctx-slot) _ = var-inr var-var ctx-1 : Context ctx-1 = ctx-slot ctx-2 : Context ctx-2 = ctx-concat ctx-1 ctx-1 ctx : ∀ (n : ℕ) → Context ctx zero = ctx-empty ctx (suc n) = ctx-concat (ctx n) ctx-slot -- the signature of the theory of groups -- has one constant, one unary operation, one binary operation Σ : Signature Σ = record { oper = GroupOp ; oper-arity = λ{ e → ctx-empty ; inv → ctx 1 ; mul → ctx 2} } open Signature Σ -- some example terms _ : Term ctx-1 _ = tm-var var-var _ : Term ctx-2 _ = tm-var (var-inr var-var) _ : Term ctx-2 _ = tm-var (var-inr var-var) -- helper functions for creating terms e' : ∀ {Γ : Context} → Term Γ e' {Γ} = tm-oper e λ() -- inv' : ∀ {Γ : Context} → Term Γ → Term Γ -- inv' x = tm-oper inv λ{ _ → x} -- mul' : ∀ {Γ : Context} → Term Γ → Term Γ → Term Γ -- mul' x y = tm-oper mul λ{ (var-inl _) → x ; (var-inr _) → y} concat-empty : var (ctx-concat ctx-empty ctx-slot) → (var ctx-slot) concat-empty (var-inr x) = x x*y : Term ctx-2 x*y = tm-oper mul λ{ (var-inl x) → tm-var (var-inl (concat-empty x)) ; (var-inr y) → tm-var (var-inr y)} -- concat-empty-idʳ : ctx-concat ctx-empty ctx-slot ≡ ctx-slot -- concat-empty-idʳ = {!!} singleton-context : (var ctx-slot) → var (ctx-concat ctx-empty ctx-slot) singleton-context (var-var) = var-inr var-var σ : ∀ {Γ : Context} {t : Term Γ} → Γ ⇒s (ctx 1) σ {Γ} {t} = λ{ (var-inr var-var) → t} δ : ∀ {Γ : Context} {t : Term Γ} {s : Term Γ} → Γ ⇒s (ctx 2) δ {Γ} {t} {s} = λ{ (var-inl x) → t ; (var-inr y) → s} _∗_ : ∀ {Γ} → Term Γ → Term Γ → Term Γ t ∗ s = tm-oper mul λ{ xs → δ {t = t} {s = s} xs} _ⁱ : ∀ {Γ : Context} → Term Γ → Term Γ t ⁱ = tm-oper inv λ{ x → σ {t = t} x} -- _∗_ : ∀ {Γ} → Term Γ → Term Γ → Term Γ -- t ∗ s = tm-oper mul λ{ (var-inl x) → t ; (var-inr args) → s} -- _ⁱ : ∀ {Γ : Context} → Term Γ → Term Γ -- t ⁱ = tm-oper inv λ{ x → t } infixl 5 _∗_ infix 6 _ⁱ _ : Term (ctx 2) _ = tm-var (var-inl (var-inr var-var)) ∗ tm-var (var-inr var-var) _ : Term (ctx 1) _ = e' ∗ a where a : Term (ctx 1) a = tm-var (var-inr var-var) -- group equations data GroupEq : Set where mul-assoc e-left e-right inv-left inv-right : GroupEq mul-assoc-ax : Equation e-left-ax : Equation e-right-ax : Equation inv-left-ax : Equation inv-right-ax : Equation mul-assoc-ax = record { eq-ctx = ctx 3 ; eq-lhs = x ∗ y ∗ z ; eq-rhs = x ∗ (y ∗ z) } where x : Term (ctx 3) y : Term (ctx 3) z : Term (ctx 3) x = tm-var (var-inl (var-inl (var-inr var-var))) y = tm-var (var-inl (var-inr var-var)) z = tm-var (var-inr var-var) e-left-ax = record { eq-ctx = ctx 1 ; eq-lhs = e' ∗ x ; eq-rhs = x } where x : Term (ctx 1) x = tm-var (var-inr var-var) e-right-ax = record { eq-ctx = ctx 1 ; eq-lhs = x ∗ e' ; eq-rhs = x } where x : Term (ctx 1) x = tm-var (var-inr var-var) inv-left-ax = record { eq-ctx = ctx 1 ; eq-lhs = x ⁱ ∗ x ; eq-rhs = e' } where x : Term (ctx 1) x = tm-var (var-inr var-var) inv-right-ax = record { eq-ctx = ctx 1 ; eq-lhs = x ∗ x ⁱ ; eq-rhs = e' } where x : Term (ctx 1) x = tm-var (var-inr var-var) 𝒢 : Theory lzero Σ 𝒢 = record { ax = GroupEq ; ax-eq = λ{ mul-assoc → mul-assoc-ax ; e-left → e-left-ax ; e-right → e-right-ax ; inv-left → inv-left-ax ; inv-right → inv-right-ax } }
{ "alphanum_fraction": 0.5519686965, "avg_line_length": 25.0858895706, "ext": "agda", "hexsha": "25421e0ec2f663a8552d028896a13011398825fc", "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/SingleSorted/Group.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/SingleSorted/Group.agda", "max_line_length": 104, "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/SingleSorted/Group.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": 1482, "size": 4089 }
module Languages.FILL.AgdaInterface where open import nat open import Utils.HaskellTypes open import Utils.Exception open import Languages.FILL.Intermediate open import Languages.FILL.Syntax translate : ITerm → Either Exception Term translate = translate' 0 0 where -- n : the next fresh bound variable name -- m : the next fresh bound pattern variable name translate' : Name → Name → ITerm → Either Exception Term translate' n m Triv = right Triv translate' n m Void = right Void translate' n m (Var x) = right (FVar x) translate' n m (TTensor t₁ t₂) = (translate' n m t₁) >>=E (λ e₁ → (translate' n m t₂) >>=E (λ e₂ → right (Tensor e₁ e₂))) translate' n m (TPar t₁ t₂) = (translate' n m t₁) >>=E (λ e₁ → (translate' n m t₂) >>=E (λ e₂ → right (Par e₁ e₂))) translate' n m (Lam x a t) = (translate' (suc n) m t) >>=E (λ e → right (Lam x a (close-t n x BV x e))) translate' n m (Let t₁ a PTriv t₂) = (translate' n m t₁) >>=E (λ e₁ → (translate' n m t₂) >>=E (λ e₂ → right (Let e₁ a PTriv e₂))) translate' n m (Let t₁ a (PTensor (PVar x) (PVar y)) t₂) = (translate' n (suc m) t₁) >>=E (λ e₁ → (translate' n (suc m) t₂) >>=E (λ e₂ → right (Let e₁ a (PTensor x y) (close-t m x LPV x (close-t m y RPV y e₂))))) translate' n m (Let t₁ a (PPar (PVar x) (PVar y)) t₂) = (translate' n (suc m) t₁) >>=E (λ e₁ → (translate' n (suc m) t₂) >>=E (λ e₂ → right (Let e₁ a (PPar x y) (close-t m x LPV x (close-t m y RPV y e₂))))) translate' n m (Let _ _ _ _) = error IllformedLetPattern translate' n m (App t₁ t₂) = (translate' n m t₁) >>=E (λ e₁ → (translate' n m t₂) >>=E (λ e₂ → right (App e₁ e₂))) untranslate : Term → ITerm untranslate Triv = Triv untranslate Void = Void untranslate (FVar x) = Var x untranslate (BVar _ x _) = Var x untranslate (Let t₁ a PTriv t₂) = Let (untranslate t₁) a PTriv (untranslate t₂) untranslate (Let t₁ a (PTensor xs ys) t₂) = Let (untranslate t₁) a (PTensor (PVar xs) (PVar ys)) (untranslate t₂) untranslate (Let t₁ a (PPar xs ys) t₂) = Let (untranslate t₁) a (PPar (PVar xs) (PVar ys)) (untranslate t₂) untranslate (Lam x a t) = Lam x a (untranslate t) untranslate (App t₁ t₂) = App (untranslate t₁) (untranslate t₂) untranslate (Tensor t₁ t₂) = TTensor (untranslate t₁) (untranslate t₂) untranslate (Par t₁ t₂) = TPar (untranslate t₁) (untranslate t₂) transUntransId : ITerm → Either Exception ITerm transUntransId t = (translate t) >>=E (λ e → right (untranslate e)) {-# COMPILED_EXPORT transUntransId transUntransId #-}
{ "alphanum_fraction": 0.6221040638, "avg_line_length": 40.5076923077, "ext": "agda", "hexsha": "b8fb8448df4e08547473b0796add4455398f21a7", "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": "c83f5d8201362b26a749138f6dbff2dd509f85b1", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "heades/Agda-LLS", "max_forks_repo_path": "Source/ALL/Languages/FILL/AgdaInterface.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1", "max_issues_repo_issues_event_max_datetime": "2017-04-05T17:30:16.000Z", "max_issues_repo_issues_event_min_datetime": "2017-03-27T14:52:46.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "heades/Agda-LLS", "max_issues_repo_path": "Source/ALL/Languages/FILL/AgdaInterface.agda", "max_line_length": 113, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "heades/Agda-LLS", "max_stars_repo_path": "Source/ALL/Languages/FILL/AgdaInterface.agda", "max_stars_repo_stars_event_max_datetime": "2019-08-02T23:41:23.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-09T20:53:53.000Z", "num_tokens": 924, "size": 2633 }
module NotStrictlyPositiveInMutual where mutual data Cheat : Set where cheat : Oops -> Cheat data Oops : Set where oops : (Cheat -> Cheat) -> Oops
{ "alphanum_fraction": 0.6687116564, "avg_line_length": 14.8181818182, "ext": "agda", "hexsha": "24897a73cb1b533c979947ad01a0451d94c5a271", "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/NotStrictlyPositiveInMutual.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/NotStrictlyPositiveInMutual.agda", "max_line_length": 40, "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/NotStrictlyPositiveInMutual.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 48, "size": 163 }
{-# OPTIONS --safe #-} module Definition.Conversion.Whnf where open import Definition.Untyped open import Definition.Typed open import Definition.Conversion open import Tools.Product mutual -- Extraction of neutrality from algorithmic equality of neutrals. ne~↑! : ∀ {t u A Γ l} → Γ ⊢ t ~ u ↑! A ^ l → Neutral t × Neutral u ne~↑! (var-refl x₁ x≡y) = var _ , var _ ne~↑! (app-cong x x₁) = let _ , q , w = ne~↓! x in ∘ₙ q , ∘ₙ w ne~↑! (natrec-cong x x₁ x₂ x₃) = let _ , q , w = ne~↓! x₃ in natrecₙ q , natrecₙ w ne~↑! (Emptyrec-cong x x₁) = Emptyrecₙ , Emptyrecₙ ne~↑! (Id-cong X x x₁) = let _ , nt , nu = ne~↓! X in Idₙ nt , Idₙ nu ne~↑! (Id-ℕ X x) = let _ , nt , nu = ne~↓! X in Idℕₙ nt , Idℕₙ nu ne~↑! (Id-ℕ0 X) = let _ , nt , nu = ne~↓! X in Idℕ0ₙ nt , Idℕ0ₙ nu ne~↑! (Id-ℕS x X) = let _ , nt , nu = ne~↓! X in IdℕSₙ nt , IdℕSₙ nu ne~↑! (Id-U X x) = let _ , nt , nu = ne~↓! X in IdUₙ nt , IdUₙ nu ne~↑! (Id-Uℕ X) = let _ , nt , nu = ne~↓! X in IdUℕₙ nt , IdUℕₙ nu ne~↑! (Id-UΠ x X) = let _ , nt , nu = ne~↓! X in IdUΠₙ nt , IdUΠₙ nu ne~↑! (cast-cong X x x₁ x₂ x₃) = let _ , nt , nu = ne~↓! X in castₙ nt , castₙ nu ne~↑! (cast-ℕ X x x₁ x₂) = let _ , nt , nu = ne~↓! X in castℕₙ nt , castℕₙ nu ne~↑! (cast-ℕℕ X x x₁) = let _ , nt , nu = ne~↓! X in castℕℕₙ nt , castℕℕₙ nu ne~↑! (cast-Π x X x₁ x₂ x₃) = let _ , nt , nu = ne~↓! X in castΠₙ nt , castΠₙ nu ne~↑! (cast-Πℕ x x₁ x₂ x₃) = castΠℕₙ , castΠℕₙ ne~↑! (cast-ℕΠ x x₁ x₂ x₃) = castℕΠₙ , castℕΠₙ ne~↑! (cast-ΠΠ%! x x₁ x₂ x₃ x₄) = castΠΠ%!ₙ , castΠΠ%!ₙ ne~↑! (cast-ΠΠ!% x x₁ x₂ x₃ x₄) = castΠΠ!%ₙ , castΠΠ!%ₙ ne~↓! : ∀ {t u A Γ l} → Γ ⊢ t ~ u ↓! A ^ l → Whnf A × Neutral t × Neutral u ne~↓! ([~] A D whnfB k~l) = whnfB , ne~↑! k~l -- Extraction of WHNF from algorithmic equality of terms in WHNF. whnfConv↓Term : ∀ {t u A Γ l} → Γ ⊢ t [conv↓] u ∷ A ^ l → Whnf A × Whnf t × Whnf u whnfConv↓Term (ℕ-ins x) = let _ , neT , neU = ne~↓! x in ℕₙ , ne neT , ne neU -- whnfConv↓Term (Empty-ins x) = let _ , neT , neU = ne~↓% x -- in Emptyₙ , ne neT , ne neU whnfConv↓Term (ne x) = let wA , nt , nu = ne~↓! x in wA , ne nt , ne nu whnfConv↓Term (ne-ins t u x x₁) = let _ , neT , neU = ne~↓! x₁ in ne x , ne neT , ne neU whnfConv↓Term (ℕ-refl x) = Uₙ , ℕₙ , ℕₙ whnfConv↓Term (Empty-refl x x₁) = Uₙ , Emptyₙ , Emptyₙ whnfConv↓Term (Π-cong _ _ _ _ _ _ x x₁ x₂) = Uₙ , Πₙ , Πₙ whnfConv↓Term (∃-cong _ x x₁ x₂) = Uₙ , ∃ₙ , ∃ₙ whnfConv↓Term (U-refl _ _) = Uₙ , Uₙ , Uₙ whnfConv↓Term (zero-refl x) = ℕₙ , zeroₙ , zeroₙ whnfConv↓Term (suc-cong x) = ℕₙ , sucₙ , sucₙ whnfConv↓Term (η-eq _ _ x x₁ x₂ y y₁ x₃) = Πₙ , functionWhnf y , functionWhnf y₁ -- Extraction of WHNF from algorithmic equality of types in WHNF. whnfConv↓ : ∀ {A B rA Γ} → Γ ⊢ A [conv↓] B ^ rA → Whnf A × Whnf B whnfConv↓ (U-refl _ _) = Uₙ , Uₙ whnfConv↓ (univ x₂) = let _ , A , B = whnfConv↓Term x₂ in A , B
{ "alphanum_fraction": 0.5357960118, "avg_line_length": 43.0845070423, "ext": "agda", "hexsha": "adfdbf10459fc15df3310716f2fdd63451580bbb", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "Definition/Conversion/Whnf.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "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": "CoqHott/logrel-mltt", "max_issues_repo_path": "Definition/Conversion/Whnf.agda", "max_line_length": 83, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "Definition/Conversion/Whnf.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 1493, "size": 3059 }
{-# OPTIONS --allow-unsolved-metas #-} module Putil where open import Level hiding ( suc ; zero ) open import Algebra open import Algebra.Structures open import Data.Fin hiding ( _<_ ; _≤_ ; _-_ ; _+_ ; _≟_) open import Data.Fin.Properties hiding ( <-trans ; ≤-trans ; ≤-irrelevant ; _≟_ ) renaming ( <-cmp to <-fcmp ) open import Data.Fin.Permutation open import Function hiding (id ; flip) open import Function.Inverse as Inverse using (_↔_; Inverse; _InverseOf_) open import Function.LeftInverse using ( _LeftInverseOf_ ) open import Function.Equality using (Π) open import Data.Nat -- using (ℕ; suc; zero; s≤s ; z≤n ) open import Data.Nat.Properties -- using (<-trans) open import Relation.Binary.PropositionalEquality hiding ( [_] ) open import Data.List using (List; []; _∷_ ; length ; _++_ ; head ; tail ) renaming (reverse to rev ) open import nat open import Symmetric open import Relation.Nullary open import Data.Empty open import Relation.Binary.Core open import Relation.Binary.Definitions open import fin -- An inductive construction of permutation pprep : {n : ℕ } → Permutation n n → Permutation (suc n) (suc n) pprep {n} perm = permutation p→ p← record { left-inverse-of = piso→ ; right-inverse-of = piso← } where p→ : Fin (suc n) → Fin (suc n) p→ zero = zero p→ (suc x) = suc ( perm ⟨$⟩ʳ x) p← : Fin (suc n) → Fin (suc n) p← zero = zero p← (suc x) = suc ( perm ⟨$⟩ˡ x) piso← : (x : Fin (suc n)) → p→ ( p← x ) ≡ x piso← zero = refl piso← (suc x) = cong (λ k → suc k ) (inverseʳ perm) piso→ : (x : Fin (suc n)) → p← ( p→ x ) ≡ x piso→ zero = refl piso→ (suc x) = cong (λ k → suc k ) (inverseˡ perm) pswap : {n : ℕ } → Permutation n n → Permutation (suc (suc n)) (suc (suc n )) pswap {n} perm = permutation p→ p← record { left-inverse-of = piso→ ; right-inverse-of = piso← } where p→ : Fin (suc (suc n)) → Fin (suc (suc n)) p→ zero = suc zero p→ (suc zero) = zero p→ (suc (suc x)) = suc ( suc ( perm ⟨$⟩ʳ x) ) p← : Fin (suc (suc n)) → Fin (suc (suc n)) p← zero = suc zero p← (suc zero) = zero p← (suc (suc x)) = suc ( suc ( perm ⟨$⟩ˡ x) ) piso← : (x : Fin (suc (suc n)) ) → p→ ( p← x ) ≡ x piso← zero = refl piso← (suc zero) = refl piso← (suc (suc x)) = cong (λ k → suc (suc k) ) (inverseʳ perm) piso→ : (x : Fin (suc (suc n)) ) → p← ( p→ x ) ≡ x piso→ zero = refl piso→ (suc zero) = refl piso→ (suc (suc x)) = cong (λ k → suc (suc k) ) (inverseˡ perm) psawpn : {n : ℕ} → 1 < n → Permutation n n psawpn {suc zero} (s≤s ()) psawpn {suc n} (s≤s (s≤s x)) = pswap pid pfill : { n m : ℕ } → m ≤ n → Permutation m m → Permutation n n pfill {n} {m} m≤n perm = pfill1 (n - m) (n-m<n n m ) (subst (λ k → Permutation k k ) (n-n-m=m m≤n ) perm) where pfill1 : (i : ℕ ) → i ≤ n → Permutation (n - i) (n - i) → Permutation n n pfill1 0 _ perm = perm pfill1 (suc i) i<n perm = pfill1 i (≤to< i<n) (subst (λ k → Permutation k k ) (si-sn=i-n i<n ) ( pprep perm ) ) -- -- psawpim (inseert swap at position m ) -- psawpim : {n m : ℕ} → suc (suc m) ≤ n → Permutation n n psawpim {n} {m} m≤n = pfill m≤n ( psawpn (s≤s (s≤s z≤n)) ) n≤ : (i : ℕ ) → {j : ℕ } → i ≤ i + j n≤ (zero) {j} = z≤n n≤ (suc i) {j} = s≤s ( n≤ i ) lem0 : {n : ℕ } → n ≤ n lem0 {zero} = z≤n lem0 {suc n} = s≤s lem0 lem00 : {n m : ℕ } → n ≡ m → n ≤ m lem00 refl = lem0 plist1 : {n : ℕ} → Permutation (suc n) (suc n) → (i : ℕ ) → i < suc n → List ℕ plist1 {n} perm zero _ = toℕ ( perm ⟨$⟩ˡ (fromℕ< {zero} (s≤s z≤n))) ∷ [] plist1 {n} perm (suc i) (s≤s lt) = toℕ ( perm ⟨$⟩ˡ (fromℕ< (s≤s lt))) ∷ plist1 perm i (<-trans lt a<sa) plist : {n : ℕ} → Permutation n n → List ℕ plist {0} perm = [] plist {suc n} perm = rev (plist1 perm n a<sa) -- -- from n-1 length create n length inserting new element at position m -- -- 0 ∷ 1 ∷ 2 ∷ 3 ∷ [] -- 0 ∷ 1 ∷ 2 ∷ 3 ∷ [] -- 1 ∷ 0 ∷ 2 ∷ 3 ∷ [] plist ( pins {3} (n≤ 1) ) 1 ∷ 0 ∷ 2 ∷ 3 ∷ [] -- 1 ∷ 2 ∷ 0 ∷ 3 ∷ [] plist ( pins {3} (n≤ 2) ) 2 ∷ 0 ∷ 1 ∷ 3 ∷ [] -- 1 ∷ 2 ∷ 3 ∷ 0 ∷ [] plist ( pins {3} (n≤ 3) ) 3 ∷ 0 ∷ 1 ∷ 2 ∷ [] -- -- defined by pprep and pswap -- -- pins : {n m : ℕ} → m ≤ n → Permutation (suc n) (suc n) -- pins {_} {zero} _ = pid -- pins {suc _} {suc zero} _ = pswap pid -- pins {suc (suc n)} {suc m} (s≤s m<n) = pins1 (suc m) (suc (suc n)) lem0 where -- pins1 : (i j : ℕ ) → j ≤ suc (suc n) → Permutation (suc (suc (suc n ))) (suc (suc (suc n))) -- pins1 _ zero _ = pid -- pins1 zero _ _ = pid -- pins1 (suc i) (suc j) (s≤s si≤n) = psawpim {suc (suc (suc n))} {j} (s≤s (s≤s si≤n)) ∘ₚ pins1 i j (≤-trans si≤n a≤sa ) open import Relation.Binary.HeterogeneousEquality as HE using (_≅_ ) open ≡-Reasoning pins : {n m : ℕ} → m ≤ n → Permutation (suc n) (suc n) pins {_} {zero} _ = pid pins {suc n} {suc m} (s≤s m≤n) = permutation p← p→ record { left-inverse-of = piso← ; right-inverse-of = piso→ } where next : Fin (suc (suc n)) → Fin (suc (suc n)) next zero = suc zero next (suc x) = fromℕ< (≤-trans (fin<n {_} {x} ) a≤sa ) p→ : Fin (suc (suc n)) → Fin (suc (suc n)) p→ x with <-cmp (toℕ x) (suc m) ... | tri< a ¬b ¬c = fromℕ< (≤-trans (s≤s a) (s≤s (s≤s m≤n) )) ... | tri≈ ¬a b ¬c = zero ... | tri> ¬a ¬b c = x p← : Fin (suc (suc n)) → Fin (suc (suc n)) p← zero = fromℕ< (s≤s (s≤s m≤n)) p← (suc x) with <-cmp (toℕ x) (suc m) ... | tri< a ¬b ¬c = fromℕ< (≤-trans (fin<n {_} {x}) a≤sa ) ... | tri≈ ¬a b ¬c = suc x ... | tri> ¬a ¬b c = suc x mm : toℕ (fromℕ< {suc m} {suc (suc n)} (s≤s (s≤s m≤n))) ≡ suc m mm = toℕ-fromℕ< (s≤s (s≤s m≤n)) mma : (x : Fin (suc n) ) → suc (toℕ x) ≤ suc m → toℕ ( fromℕ< (≤-trans (fin<n {_} {x}) a≤sa ) ) ≤ m mma x (s≤s x<sm) = subst (λ k → k ≤ m) (sym (toℕ-fromℕ< (≤-trans fin<n a≤sa ) )) x<sm p3 : (x : Fin (suc n) ) → toℕ (fromℕ< (≤-trans (fin<n {_} {suc x} ) (s≤s a≤sa))) ≡ suc (toℕ x) p3 x = begin toℕ (fromℕ< (≤-trans (fin<n {_} {suc x} ) (s≤s a≤sa))) ≡⟨ toℕ-fromℕ< ( s≤s ( ≤-trans fin<n a≤sa ) ) ⟩ suc (toℕ x) ∎ piso→ : (x : Fin (suc (suc n)) ) → p← ( p→ x ) ≡ x piso→ zero with <-cmp (toℕ (fromℕ< (≤-trans (s≤s z≤n) (s≤s (s≤s m≤n) )))) (suc m) ... | tri< a ¬b ¬c = refl piso→ (suc x) with <-cmp (toℕ (suc x)) (suc m) ... | tri≈ ¬a refl ¬c = p13 where p13 : fromℕ< (s≤s (s≤s m≤n)) ≡ suc x p13 = cong (λ k → suc k ) (fromℕ<-toℕ _ (s≤s m≤n) ) ... | tri> ¬a ¬b c = p16 (suc x) refl where p16 : (y : Fin (suc (suc n))) → y ≡ suc x → p← y ≡ suc x p16 zero eq = ⊥-elim ( nat-≡< (cong (λ k → suc (toℕ k) ) eq) (s≤s (s≤s (z≤n)))) p16 (suc y) eq with <-cmp (toℕ y) (suc m) -- suc (suc m) < toℕ (suc x) ... | tri< a ¬b ¬c = ⊥-elim ( nat-≡< refl ( ≤-trans c (subst (λ k → k < suc m) p17 a )) ) where -- x = suc m case, c : suc (suc m) ≤ suc (toℕ x), a : suc (toℕ y) ≤ suc m, suc y ≡ suc x p17 : toℕ y ≡ toℕ x p17 with <-cmp (toℕ y) (toℕ x) | cong toℕ eq ... | tri< a ¬b ¬c | seq = ⊥-elim ( nat-≡< seq (s≤s a) ) ... | tri≈ ¬a b ¬c | seq = b ... | tri> ¬a ¬b c | seq = ⊥-elim ( nat-≡< (sym seq) (s≤s c)) ... | tri≈ ¬a b ¬c = eq ... | tri> ¬a ¬b c₁ = eq ... | tri< a ¬b ¬c = p10 (fromℕ< (≤-trans (s≤s a) (s≤s (s≤s m≤n) ))) refl where p10 : (y : Fin (suc (suc n)) ) → y ≡ fromℕ< (≤-trans (s≤s a) (s≤s (s≤s m≤n) )) → p← y ≡ suc x p10 zero () p10 (suc y) eq = p15 where p12 : toℕ y ≡ suc (toℕ x) p12 = begin toℕ y ≡⟨ cong (λ k → Data.Nat.pred (toℕ k)) eq ⟩ toℕ (fromℕ< (≤-trans a (s≤s m≤n))) ≡⟨ toℕ-fromℕ< {suc (toℕ x)} {suc n} (≤-trans a (s≤s m≤n)) ⟩ suc (toℕ x) ∎ p15 : p← (suc y) ≡ suc x p15 with <-cmp (toℕ y) (suc m) -- eq : suc y ≡ suc (suc (fromℕ< (≤-pred (≤-trans a (s≤s m≤n))))) , a : suc x < suc m ... | tri< a₁ ¬b ¬c = p11 where p11 : fromℕ< (≤-trans (fin<n {_} {y}) a≤sa ) ≡ suc x p11 = begin fromℕ< (≤-trans (fin<n {_} {y}) a≤sa ) ≡⟨ lemma10 {suc (suc n)} {_} {_} p12 {≤-trans (fin<n {_} {y}) a≤sa} {s≤s (fin<n {suc n} {x} )} ⟩ suc (fromℕ< (fin<n {suc n} {x} )) ≡⟨ cong suc (fromℕ<-toℕ x _ ) ⟩ suc x ∎ ... | tri≈ ¬a b ¬c = ⊥-elim ( nat-≡< b (subst (λ k → k < suc m) (sym p12) a )) -- suc x < suc m -> y = suc x → toℕ y < suc m ... | tri> ¬a ¬b c = ⊥-elim ( nat-<> c (subst (λ k → k < suc m) (sym p12) a )) piso← : (x : Fin (suc (suc n)) ) → p→ ( p← x ) ≡ x piso← zero with <-cmp (toℕ (fromℕ< (s≤s (s≤s m≤n)))) (suc m) | mm ... | tri< a ¬b ¬c | t = ⊥-elim ( ¬b t ) ... | tri≈ ¬a b ¬c | t = refl ... | tri> ¬a ¬b c | t = ⊥-elim ( ¬b t ) piso← (suc x) with <-cmp (toℕ x) (suc m) ... | tri> ¬a ¬b c with <-cmp (toℕ (suc x)) (suc m) ... | tri< a ¬b₁ ¬c = ⊥-elim ( nat-<> a (<-trans c a<sa ) ) ... | tri≈ ¬a₁ b ¬c = ⊥-elim ( nat-≡< (sym b) (<-trans c a<sa )) ... | tri> ¬a₁ ¬b₁ c₁ = refl piso← (suc x) | tri≈ ¬a b ¬c with <-cmp (toℕ (suc x)) (suc m) ... | tri< a ¬b ¬c₁ = ⊥-elim ( nat-≡< b (<-trans a<sa a) ) ... | tri≈ ¬a₁ refl ¬c₁ = ⊥-elim ( nat-≡< b a<sa ) ... | tri> ¬a₁ ¬b c = refl piso← (suc x) | tri< a ¬b ¬c with <-cmp (toℕ ( fromℕ< (≤-trans (fin<n {_} {x}) a≤sa ) )) (suc m) ... | tri≈ ¬a b ¬c₁ = ⊥-elim ( ¬a (s≤s (mma x a))) ... | tri> ¬a ¬b₁ c = ⊥-elim ( ¬a (s≤s (mma x a))) ... | tri< a₁ ¬b₁ ¬c₁ = p0 where p2 : suc (suc (toℕ x)) ≤ suc (suc n) p2 = s≤s (fin<n {suc n} {x}) p6 : suc (toℕ (fromℕ< (≤-trans (fin<n {_} {suc x}) (s≤s a≤sa)))) ≤ suc (suc n) p6 = s≤s (≤-trans a₁ (s≤s m≤n)) p0 : fromℕ< (≤-trans (s≤s a₁) (s≤s (s≤s m≤n) )) ≡ suc x p0 = begin fromℕ< (≤-trans (s≤s a₁) (s≤s (s≤s m≤n) )) ≡⟨⟩ fromℕ< (s≤s (≤-trans a₁ (s≤s m≤n))) ≡⟨ lemma10 {suc (suc n)} (p3 x) {p6} {p2} ⟩ fromℕ< ( s≤s (fin<n {suc n} {x}) ) ≡⟨⟩ suc (fromℕ< (fin<n {suc n} {x} )) ≡⟨ cong suc (fromℕ<-toℕ x _ ) ⟩ suc x ∎ t7 = plist (pins {3} (n≤ 3)) ∷ plist (flip ( pins {3} (n≤ 3) )) ∷ plist ( pins {3} (n≤ 3) ∘ₚ flip ( pins {3} (n≤ 3))) ∷ [] -- t8 = {!!} open import logic open _∧_ perm1 : {perm : Permutation 1 1 } {q : Fin 1} → (perm ⟨$⟩ʳ q ≡ # 0) ∧ ((perm ⟨$⟩ˡ q ≡ # 0)) perm1 {p} {q} = ⟪ perm01 _ _ , perm00 _ _ ⟫ where perm01 : (x y : Fin 1) → (p ⟨$⟩ʳ x) ≡ y perm01 x y with p ⟨$⟩ʳ x perm01 zero zero | zero = refl perm00 : (x y : Fin 1) → (p ⟨$⟩ˡ x) ≡ y perm00 x y with p ⟨$⟩ˡ x perm00 zero zero | zero = refl ---- -- find insertion point of pins ---- p=0 : {n : ℕ } → (perm : Permutation (suc n) (suc n) ) → ((perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ⟨$⟩ˡ (# 0)) ≡ # 0 p=0 {zero} perm with ((perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ⟨$⟩ˡ (# 0)) ... | zero = refl p=0 {suc n} perm with perm ⟨$⟩ʳ (# 0) | inspect (_⟨$⟩ʳ_ perm ) (# 0)| toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)) | inspect toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)) ... | zero | record { eq = e} | m<n | _ = p001 where p001 : perm ⟨$⟩ˡ ( pins m<n ⟨$⟩ʳ zero) ≡ zero p001 = subst (λ k → perm ⟨$⟩ˡ k ≡ zero ) e (inverseˡ perm) ... | suc t | record { eq = e } | m<n | record { eq = e1 } = p002 where -- m<n : suc (toℕ t) ≤ suc n p002 : perm ⟨$⟩ˡ ( pins m<n ⟨$⟩ʳ zero) ≡ zero p002 = p005 zero (toℕ t) refl m<n refl where -- suc (toℕ t) ≤ suc n p003 : (s : Fin (suc (suc n))) → s ≡ (perm ⟨$⟩ʳ (# 0)) → perm ⟨$⟩ˡ s ≡ # 0 p003 s eq = subst (λ k → perm ⟨$⟩ˡ k ≡ zero ) (sym eq) (inverseˡ perm) p005 : (x : Fin (suc (suc n))) → (m : ℕ ) → x ≡ zero → (m≤n : suc m ≤ suc n ) → m ≡ toℕ t → perm ⟨$⟩ˡ ( pins m≤n ⟨$⟩ʳ zero) ≡ zero p005 zero m eq (s≤s m≤n) meq = p004 where p004 : perm ⟨$⟩ˡ (fromℕ< (s≤s (s≤s m≤n))) ≡ zero p004 = p003 (fromℕ< (s≤s (s≤s m≤n))) ( begin fromℕ< (s≤s (s≤s m≤n)) ≡⟨ lemma10 {suc (suc n)} (cong suc meq) {s≤s (s≤s m≤n)} {subst (λ k → suc k < suc (suc n)) meq (s≤s (s≤s m≤n)) } ⟩ fromℕ< (subst (λ k → suc k < suc (suc n)) meq (s≤s (s≤s m≤n)) ) ≡⟨ fromℕ<-toℕ {suc (suc n)} (suc t) (subst (λ k → suc k < suc (suc n)) meq (s≤s (s≤s m≤n)) ) ⟩ suc t ≡⟨ sym e ⟩ (perm ⟨$⟩ʳ (# 0)) ∎ ) ---- -- other elements are preserved in pins ---- px=x : {n : ℕ } → (x : Fin (suc n)) → pins ( toℕ≤pred[n] x ) ⟨$⟩ʳ (# 0) ≡ x px=x {n} zero = refl px=x {suc n} (suc x) = p001 where p002 : fromℕ< (s≤s (toℕ≤pred[n] x)) ≡ x p002 = fromℕ<-toℕ x (s≤s (toℕ≤pred[n] x)) p001 : (pins (toℕ≤pred[n] (suc x)) ⟨$⟩ʳ (# 0)) ≡ suc x p001 with <-cmp 0 ((toℕ x)) ... | tri< a ¬b ¬c = cong suc p002 ... | tri≈ ¬a b ¬c = cong suc p002 -- pp : {n : ℕ } → (perm : Permutation (suc n) (suc n) ) → Fin (suc n) -- pp perm → (( perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ⟨$⟩ˡ (# 0)) plist2 : {n : ℕ} → Permutation (suc n) (suc n) → (i : ℕ ) → i < suc n → List ℕ plist2 {n} perm zero _ = toℕ ( perm ⟨$⟩ʳ (fromℕ< {zero} (s≤s z≤n))) ∷ [] plist2 {n} perm (suc i) (s≤s lt) = toℕ ( perm ⟨$⟩ʳ (fromℕ< (s≤s lt))) ∷ plist2 perm i (<-trans lt a<sa) plist0 : {n : ℕ} → Permutation n n → List ℕ plist0 {0} perm = [] plist0 {suc n} perm = plist2 perm n a<sa open _=p=_ -- -- plist cong -- ←pleq : {n : ℕ} → (x y : Permutation n n ) → x =p= y → plist0 x ≡ plist0 y ←pleq {zero} x y eq = refl ←pleq {suc n} x y eq = ←pleq1 n a<sa where ←pleq1 : (i : ℕ ) → (i<sn : i < suc n ) → plist2 x i i<sn ≡ plist2 y i i<sn ←pleq1 zero _ = cong ( λ k → toℕ k ∷ [] ) ( peq eq (fromℕ< {zero} (s≤s z≤n))) ←pleq1 (suc i) (s≤s lt) = cong₂ ( λ j k → toℕ j ∷ k ) ( peq eq (fromℕ< (s≤s lt))) ( ←pleq1 i (<-trans lt a<sa) ) headeq : {A : Set } → {x y : A } → {xt yt : List A } → (x ∷ xt) ≡ (y ∷ yt) → x ≡ y headeq refl = refl taileq : {A : Set } → {x y : A } → {xt yt : List A } → (x ∷ xt) ≡ (y ∷ yt) → xt ≡ yt taileq refl = refl -- -- plist injection / equalizer -- -- if plist0 of two perm looks the same, the permutations are the same -- pleq : {n : ℕ} → (x y : Permutation n n ) → plist0 x ≡ plist0 y → x =p= y pleq {0} x y refl = record { peq = λ q → pleq0 q } where pleq0 : (q : Fin 0 ) → (x ⟨$⟩ʳ q) ≡ (y ⟨$⟩ʳ q) pleq0 () pleq {suc n} x y eq = record { peq = λ q → pleq1 n a<sa eq q fin<n } where pleq1 : (i : ℕ ) → (i<sn : i < suc n ) → plist2 x i i<sn ≡ plist2 y i i<sn → (q : Fin (suc n)) → toℕ q < suc i → x ⟨$⟩ʳ q ≡ y ⟨$⟩ʳ q pleq1 zero i<sn eq q q<i with <-cmp (toℕ q) zero ... | tri< () ¬b ¬c ... | tri> ¬a ¬b c = ⊥-elim (nat-≤> c q<i ) ... | tri≈ ¬a b ¬c = begin x ⟨$⟩ʳ q ≡⟨ cong ( λ k → x ⟨$⟩ʳ k ) (toℕ-injective b )⟩ x ⟨$⟩ʳ zero ≡⟨ toℕ-injective (headeq eq) ⟩ y ⟨$⟩ʳ zero ≡⟨ cong ( λ k → y ⟨$⟩ʳ k ) (sym (toℕ-injective b )) ⟩ y ⟨$⟩ʳ q ∎ pleq1 (suc i) (s≤s i<sn) eq q q<i with <-cmp (toℕ q) (suc i) ... | tri< a ¬b ¬c = pleq1 i (<-trans i<sn a<sa ) (taileq eq) q a ... | tri> ¬a ¬b c = ⊥-elim (nat-≤> c q<i ) ... | tri≈ ¬a b ¬c = begin x ⟨$⟩ʳ q ≡⟨ cong (λ k → x ⟨$⟩ʳ k) (pleq3 b) ⟩ x ⟨$⟩ʳ (suc (fromℕ< i<sn)) ≡⟨ toℕ-injective pleq2 ⟩ y ⟨$⟩ʳ (suc (fromℕ< i<sn)) ≡⟨ cong (λ k → y ⟨$⟩ʳ k) (sym (pleq3 b)) ⟩ y ⟨$⟩ʳ q ∎ where pleq3 : toℕ q ≡ suc i → q ≡ suc (fromℕ< i<sn) pleq3 tq=si = toℕ-injective ( begin toℕ q ≡⟨ b ⟩ suc i ≡⟨ sym (toℕ-fromℕ< (s≤s i<sn)) ⟩ toℕ (fromℕ< (s≤s i<sn)) ≡⟨⟩ toℕ (suc (fromℕ< i<sn)) ∎ ) pleq2 : toℕ ( x ⟨$⟩ʳ (suc (fromℕ< i<sn)) ) ≡ toℕ ( y ⟨$⟩ʳ (suc (fromℕ< i<sn)) ) pleq2 = headeq eq is-=p= : {n : ℕ} → (x y : Permutation n n ) → Dec (x =p= y ) is-=p= {zero} x y = yes record { peq = λ () } is-=p= {suc n} x y with ℕL-eq? (plist0 x ) ( plist0 y ) ... | yes t = yes (pleq x y t) ... | no t = no ( contra-position (←pleq x y) t ) pprep-cong : {n : ℕ} → {x y : Permutation n n } → x =p= y → pprep x =p= pprep y pprep-cong {n} {x} {y} x=y = record { peq = pprep-cong1 } where pprep-cong1 : (q : Fin (suc n)) → (pprep x ⟨$⟩ʳ q) ≡ (pprep y ⟨$⟩ʳ q) pprep-cong1 zero = refl pprep-cong1 (suc q) = begin pprep x ⟨$⟩ʳ suc q ≡⟨⟩ suc ( x ⟨$⟩ʳ q ) ≡⟨ cong ( λ k → suc k ) ( peq x=y q ) ⟩ suc ( y ⟨$⟩ʳ q ) ≡⟨⟩ pprep y ⟨$⟩ʳ suc q ∎ pprep-dist : {n : ℕ} → {x y : Permutation n n } → pprep (x ∘ₚ y) =p= (pprep x ∘ₚ pprep y) pprep-dist {n} {x} {y} = record { peq = pprep-dist1 } where pprep-dist1 : (q : Fin (suc n)) → (pprep (x ∘ₚ y) ⟨$⟩ʳ q) ≡ ((pprep x ∘ₚ pprep y) ⟨$⟩ʳ q) pprep-dist1 zero = refl pprep-dist1 (suc q) = cong ( λ k → suc k ) refl pswap-cong : {n : ℕ} → {x y : Permutation n n } → x =p= y → pswap x =p= pswap y pswap-cong {n} {x} {y} x=y = record { peq = pswap-cong1 } where pswap-cong1 : (q : Fin (suc (suc n))) → (pswap x ⟨$⟩ʳ q) ≡ (pswap y ⟨$⟩ʳ q) pswap-cong1 zero = refl pswap-cong1 (suc zero) = refl pswap-cong1 (suc (suc q)) = begin pswap x ⟨$⟩ʳ suc (suc q) ≡⟨⟩ suc (suc (x ⟨$⟩ʳ q)) ≡⟨ cong ( λ k → suc (suc k) ) ( peq x=y q ) ⟩ suc (suc (y ⟨$⟩ʳ q)) ≡⟨⟩ pswap y ⟨$⟩ʳ suc (suc q) ∎ pswap-dist : {n : ℕ} → {x y : Permutation n n } → pprep (pprep (x ∘ₚ y)) =p= (pswap x ∘ₚ pswap y) pswap-dist {n} {x} {y} = record { peq = pswap-dist1 } where pswap-dist1 : (q : Fin (suc (suc n))) → ((pprep (pprep (x ∘ₚ y))) ⟨$⟩ʳ q) ≡ ((pswap x ∘ₚ pswap y) ⟨$⟩ʳ q) pswap-dist1 zero = refl pswap-dist1 (suc zero) = refl pswap-dist1 (suc (suc q)) = cong ( λ k → suc (suc k) ) refl shlem→ : {n : ℕ} → (perm : Permutation (suc n) (suc n) ) → (p0=0 : perm ⟨$⟩ˡ (# 0) ≡ # 0 ) → (x : Fin (suc n) ) → perm ⟨$⟩ˡ x ≡ zero → x ≡ zero shlem→ perm p0=0 x px=0 = begin x ≡⟨ sym ( inverseʳ perm ) ⟩ perm ⟨$⟩ʳ ( perm ⟨$⟩ˡ x) ≡⟨ cong (λ k → perm ⟨$⟩ʳ k ) px=0 ⟩ perm ⟨$⟩ʳ zero ≡⟨ cong (λ k → perm ⟨$⟩ʳ k ) (sym p0=0) ⟩ perm ⟨$⟩ʳ ( perm ⟨$⟩ˡ zero) ≡⟨ inverseʳ perm ⟩ zero ∎ shlem← : {n : ℕ} → (perm : Permutation (suc n) (suc n) ) → (p0=0 : perm ⟨$⟩ˡ (# 0) ≡ # 0 ) → (x : Fin (suc n)) → perm ⟨$⟩ʳ x ≡ zero → x ≡ zero shlem← perm p0=0 x px=0 = begin x ≡⟨ sym (inverseˡ perm ) ⟩ perm ⟨$⟩ˡ ( perm ⟨$⟩ʳ x ) ≡⟨ cong (λ k → perm ⟨$⟩ˡ k ) px=0 ⟩ perm ⟨$⟩ˡ zero ≡⟨ p0=0 ⟩ zero ∎ sh2 : {n : ℕ} → (perm : Permutation (suc n) (suc n) ) → (p0=0 : perm ⟨$⟩ˡ (# 0) ≡ # 0 ) → {x : Fin n} → ¬ perm ⟨$⟩ˡ (suc x) ≡ zero sh2 perm p0=0 {x} eq with shlem→ perm p0=0 (suc x) eq sh2 perm p0=0 {x} eq | () sh1 : {n : ℕ} → (perm : Permutation (suc n) (suc n) ) → (p0=0 : perm ⟨$⟩ˡ (# 0) ≡ # 0 ) → {x : Fin n} → ¬ perm ⟨$⟩ʳ (suc x) ≡ zero sh1 perm p0=0 {x} eq with shlem← perm p0=0 (suc x) eq sh1 perm p0=0 {x} eq | () -- 0 ∷ 1 ∷ 2 ∷ 3 ∷ [] → 0 ∷ 1 ∷ 2 ∷ [] shrink : {n : ℕ} → (perm : Permutation (suc n) (suc n) ) → perm ⟨$⟩ˡ (# 0) ≡ # 0 → Permutation n n shrink {n} perm p0=0 = permutation p→ p← record { left-inverse-of = piso→ ; right-inverse-of = piso← } where p→ : Fin n → Fin n p→ x with perm ⟨$⟩ʳ (suc x) | inspect (_⟨$⟩ʳ_ perm ) (suc x) p→ x | zero | record { eq = e } = ⊥-elim ( sh1 perm p0=0 {x} e ) p→ x | suc t | _ = t p← : Fin n → Fin n p← x with perm ⟨$⟩ˡ (suc x) | inspect (_⟨$⟩ˡ_ perm ) (suc x) p← x | zero | record { eq = e } = ⊥-elim ( sh2 perm p0=0 {x} e ) p← x | suc t | _ = t piso← : (x : Fin n ) → p→ ( p← x ) ≡ x piso← x with perm ⟨$⟩ˡ (suc x) | inspect (_⟨$⟩ˡ_ perm ) (suc x) piso← x | zero | record { eq = e } = ⊥-elim ( sh2 perm p0=0 {x} e ) piso← x | suc t | _ with perm ⟨$⟩ʳ (suc t) | inspect (_⟨$⟩ʳ_ perm ) (suc t) piso← x | suc t | _ | zero | record { eq = e } = ⊥-elim ( sh1 perm p0=0 e ) piso← x | suc t | record { eq = e0 } | suc t1 | record { eq = e1 } = begin t1 ≡⟨ plem0 plem1 ⟩ x ∎ where open ≡-Reasoning plem0 : suc t1 ≡ suc x → t1 ≡ x plem0 refl = refl plem1 : suc t1 ≡ suc x plem1 = begin suc t1 ≡⟨ sym e1 ⟩ Inverse.to perm Π.⟨$⟩ suc t ≡⟨ cong (λ k → Inverse.to perm Π.⟨$⟩ k ) (sym e0) ⟩ Inverse.to perm Π.⟨$⟩ ( Inverse.from perm Π.⟨$⟩ suc x ) ≡⟨ inverseʳ perm ⟩ suc x ∎ piso→ : (x : Fin n ) → p← ( p→ x ) ≡ x piso→ x with perm ⟨$⟩ʳ (suc x) | inspect (_⟨$⟩ʳ_ perm ) (suc x) piso→ x | zero | record { eq = e } = ⊥-elim ( sh1 perm p0=0 {x} e ) piso→ x | suc t | _ with perm ⟨$⟩ˡ (suc t) | inspect (_⟨$⟩ˡ_ perm ) (suc t) piso→ x | suc t | _ | zero | record { eq = e } = ⊥-elim ( sh2 perm p0=0 e ) piso→ x | suc t | record { eq = e0 } | suc t1 | record { eq = e1 } = begin t1 ≡⟨ plem2 plem3 ⟩ x ∎ where plem2 : suc t1 ≡ suc x → t1 ≡ x plem2 refl = refl plem3 : suc t1 ≡ suc x plem3 = begin suc t1 ≡⟨ sym e1 ⟩ Inverse.from perm Π.⟨$⟩ suc t ≡⟨ cong (λ k → Inverse.from perm Π.⟨$⟩ k ) (sym e0 ) ⟩ Inverse.from perm Π.⟨$⟩ ( Inverse.to perm Π.⟨$⟩ suc x ) ≡⟨ inverseˡ perm ⟩ suc x ∎ shrink-iso : { n : ℕ } → {perm : Permutation n n} → shrink (pprep perm) refl =p= perm shrink-iso {n} {perm} = record { peq = λ q → refl } shrink-iso2 : { n : ℕ } → {perm : Permutation (suc n) (suc n)} → (p=0 : perm ⟨$⟩ˡ (# 0) ≡ # 0) → pprep (shrink perm p=0) =p= perm shrink-iso2 {n} {perm} p=0 = record { peq = s001 } where s001 : (q : Fin (suc n)) → (pprep (shrink perm p=0) ⟨$⟩ʳ q) ≡ perm ⟨$⟩ʳ q s001 zero = begin zero ≡⟨ sym ( inverseʳ perm ) ⟩ perm ⟨$⟩ʳ ( perm ⟨$⟩ˡ zero ) ≡⟨ cong (λ k → perm ⟨$⟩ʳ k ) p=0 ⟩ perm ⟨$⟩ʳ zero ∎ s001 (suc q) with perm ⟨$⟩ʳ (suc q) | inspect (_⟨$⟩ʳ_ perm ) (suc q) ... | zero | record {eq = e} = ⊥-elim (sh1 perm p=0 {q} e) ... | suc t | e = refl shrink-cong : { n : ℕ } → {x y : Permutation (suc n) (suc n)} → x =p= y → (x=0 : x ⟨$⟩ˡ (# 0) ≡ # 0 ) → (y=0 : y ⟨$⟩ˡ (# 0) ≡ # 0 ) → shrink x x=0 =p= shrink y y=0 shrink-cong {n} {x} {y} x=y x=0 y=0 = record { peq = p002 } where p002 : (q : Fin n) → (shrink x x=0 ⟨$⟩ʳ q) ≡ (shrink y y=0 ⟨$⟩ʳ q) p002 q with x ⟨$⟩ʳ (suc q) | inspect (_⟨$⟩ʳ_ x ) (suc q) | y ⟨$⟩ʳ (suc q) | inspect (_⟨$⟩ʳ_ y ) (suc q) p002 q | zero | record { eq = ex } | zero | ey = ⊥-elim ( sh1 x x=0 ex ) p002 q | zero | record { eq = ex } | suc py | ey = ⊥-elim ( sh1 x x=0 ex ) p002 q | suc px | ex | zero | record { eq = ey } = ⊥-elim ( sh1 y y=0 ey ) p002 q | suc px | record { eq = ex } | suc py | record { eq = ey } = p003 ( begin suc px ≡⟨ sym ex ⟩ x ⟨$⟩ʳ (suc q) ≡⟨ peq x=y (suc q) ⟩ y ⟨$⟩ʳ (suc q) ≡⟨ ey ⟩ suc py ∎ ) where p003 : suc px ≡ suc py → px ≡ py p003 refl = refl open import FLutil FL→perm : {n : ℕ } → FL n → Permutation n n FL→perm f0 = pid FL→perm (x :: fl) = pprep (FL→perm fl) ∘ₚ pins ( toℕ≤pred[n] x ) t40 = (# 2) :: ( (# 1) :: (( # 0 ) :: f0 )) t4 = FL→perm ((# 2) :: t40 ) -- t1 = plist (shrink (pid {3} ∘ₚ (pins (n≤ 1))) refl) t2 = plist ((pid {5} ) ∘ₚ transpose (# 2) (# 4)) ∷ plist (pid {5} ∘ₚ reverse ) ∷ [] t3 = plist (FL→perm t40) -- ∷ plist (pprep (FL→perm t40)) -- ∷ plist ( pprep (FL→perm t40) ∘ₚ pins ( n≤ 0 {3} )) -- ∷ plist ( pprep (FL→perm t40 )∘ₚ pins ( n≤ 1 {2} )) -- ∷ plist ( pprep (FL→perm t40 )∘ₚ pins ( n≤ 2 {1} )) -- ∷ plist ( pprep (FL→perm t40 )∘ₚ pins ( n≤ 3 {0} )) ∷ plist ( FL→perm ((# 0) :: t40)) -- (0 ∷ 1 ∷ 2 ∷ []) ∷ ∷ plist ( FL→perm ((# 1) :: t40)) -- (0 ∷ 2 ∷ 1 ∷ []) ∷ ∷ plist ( FL→perm ((# 2) :: t40)) -- (1 ∷ 0 ∷ 2 ∷ []) ∷ ∷ plist ( FL→perm ((# 3) :: t40)) -- (2 ∷ 0 ∷ 1 ∷ []) ∷ -- ∷ plist ( FL→perm ((# 3) :: ((# 2) :: ( (# 0) :: (( # 0 ) :: f0 )) ))) -- (1 ∷ 2 ∷ 0 ∷ []) ∷ -- ∷ plist ( FL→perm ((# 3) :: ((# 2) :: ( (# 1) :: (( # 0 ) :: f0 )) ))) -- (2 ∷ 1 ∷ 0 ∷ []) ∷ -- ∷ plist ( (flip (FL→perm ((# 3) :: ((# 1) :: ( (# 0) :: (( # 0 ) :: f0 )) ))))) -- ∷ plist ( (flip (FL→perm ((# 3) :: ((# 1) :: ( (# 0) :: (( # 0 ) :: f0 )) ))) ∘ₚ (FL→perm ((# 3) :: (((# 1) :: ( (# 0) :: (( # 0 ) :: f0 )) )))) )) ∷ [] -- FL→plist-iso : {n : ℕ} → (f : FL n ) → plist→FL (FL→plist f ) ≡ f -- FL→plist-inject : {n : ℕ} → (f g : FL n ) → FL→plist f ≡ FL→plist g → f ≡ g perm→FL : {n : ℕ } → Permutation n n → FL n perm→FL {zero} perm = f0 perm→FL {suc n} perm = (perm ⟨$⟩ʳ (# 0)) :: perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm) ) ---FL→perm : {n : ℕ } → FL n → Permutation n n ---FL→perm x = plist→perm ( FL→plis x) -- perm→FL : {n : ℕ } → Permutation n n → FL n -- perm→FL p = plist→FL (plist p) -- pcong-pF : {n : ℕ } → {x y : Permutation n n} → x =p= y → perm→FL x ≡ perm→FL y -- pcong-pF {n} {x} {y} x=y = FL→plist-inject (subst ... (pleq← eq)) (perm→FL x) (perm→FL y) -- FL→iso : {n : ℕ } → (fl : FL n ) → perm→FL ( FL→perm fl ) ≡ fl -- FL→iso = -- pcong-Fp : {n : ℕ } → {x y : FL n} → x ≡ y → FL→perm x =p= FL→perm y -- FL←iso : {n : ℕ } → (perm : Permutation n n ) → FL→perm ( perm→FL perm ) =p= perm _p<_ : {n : ℕ } ( x y : Permutation n n ) → Set x p< y = perm→FL x f< perm→FL y pcong-pF : {n : ℕ } → {x y : Permutation n n} → x =p= y → perm→FL x ≡ perm→FL y pcong-pF {zero} eq = refl pcong-pF {suc n} {x} {y} eq = cong₂ (λ j k → j :: k ) ( peq eq (# 0)) (pcong-pF (shrink-cong (presp eq p001 ) (p=0 x) (p=0 y))) where p002 : x ⟨$⟩ʳ (# 0) ≡ y ⟨$⟩ʳ (# 0) p002 = peq eq (# 0) p001 : flip (pins (toℕ≤pred[n] (x ⟨$⟩ʳ (# 0)))) =p= flip (pins (toℕ≤pred[n] (y ⟨$⟩ʳ (# 0)))) p001 = subst ( λ k → flip (pins (toℕ≤pred[n] (x ⟨$⟩ʳ (# 0)))) =p= flip (pins (toℕ≤pred[n] k ))) p002 prefl -- t5 = plist t4 ∷ plist ( t4 ∘ₚ flip (pins ( n≤ 3 ) )) t5 = plist (t4) ∷ plist (flip t4) ∷ ( toℕ (t4 ⟨$⟩ˡ fromℕ< a<sa) ∷ [] ) ∷ ( toℕ (t4 ⟨$⟩ʳ (# 0)) ∷ [] ) -- ∷ plist ( t4 ∘ₚ flip (pins ( n≤ 1 ) )) ∷ plist (remove (# 0) t4 ) ∷ plist ( FL→perm t40 ) ∷ [] t6 = perm→FL t4 FL→iso : {n : ℕ } → (fl : FL n ) → perm→FL ( FL→perm fl ) ≡ fl FL→iso f0 = refl FL→iso {suc n} (x :: fl) = cong₂ ( λ j k → j :: k ) f001 f002 where perm = pprep (FL→perm fl) ∘ₚ pins ( toℕ≤pred[n] x ) f001 : perm ⟨$⟩ʳ (# 0) ≡ x f001 = begin (pprep (FL→perm fl) ∘ₚ pins ( toℕ≤pred[n] x )) ⟨$⟩ʳ (# 0) ≡⟨⟩ pins ( toℕ≤pred[n] x ) ⟨$⟩ʳ (# 0) ≡⟨ px=x x ⟩ x ∎ x=0 : (perm ∘ₚ flip (pins (toℕ≤pred[n] x))) ⟨$⟩ˡ (# 0) ≡ # 0 x=0 = subst ( λ k → (perm ∘ₚ flip (pins (toℕ≤pred[n] k))) ⟨$⟩ˡ (# 0) ≡ # 0 ) f001 (p=0 perm) x=0' : (pprep (FL→perm fl) ∘ₚ pid) ⟨$⟩ˡ (# 0) ≡ # 0 x=0' = refl f003 : (q : Fin (suc n)) → ((perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ⟨$⟩ʳ q) ≡ ((perm ∘ₚ flip (pins (toℕ≤pred[n] x))) ⟨$⟩ʳ q) f003 q = cong (λ k → (perm ∘ₚ flip (pins (toℕ≤pred[n] k))) ⟨$⟩ʳ q ) f001 f002 : perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm) ) ≡ fl f002 = begin perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm) ) ≡⟨ pcong-pF (shrink-cong {n} {perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))} {perm ∘ₚ flip (pins (toℕ≤pred[n] x))} record {peq = f003 } (p=0 perm) x=0) ⟩ perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] x))) x=0 ) ≡⟨⟩ perm→FL (shrink ((pprep (FL→perm fl) ∘ₚ pins ( toℕ≤pred[n] x )) ∘ₚ flip (pins (toℕ≤pred[n] x))) x=0 ) ≡⟨ pcong-pF (shrink-cong (passoc (pprep (FL→perm fl)) (pins ( toℕ≤pred[n] x )) (flip (pins (toℕ≤pred[n] x))) ) x=0 x=0) ⟩ perm→FL (shrink (pprep (FL→perm fl) ∘ₚ (pins ( toℕ≤pred[n] x ) ∘ₚ flip (pins (toℕ≤pred[n] x)))) x=0 ) ≡⟨ pcong-pF (shrink-cong {n} {pprep (FL→perm fl) ∘ₚ (pins ( toℕ≤pred[n] x ) ∘ₚ flip (pins (toℕ≤pred[n] x)))} {pprep (FL→perm fl) ∘ₚ pid} ( presp {suc n} {pprep (FL→perm fl) } {_} {(pins ( toℕ≤pred[n] x ) ∘ₚ flip (pins (toℕ≤pred[n] x)))} {pid} prefl record { peq = λ q → inverseˡ (pins ( toℕ≤pred[n] x )) } ) x=0 x=0') ⟩ perm→FL (shrink (pprep (FL→perm fl) ∘ₚ pid) x=0' ) ≡⟨ pcong-pF (shrink-cong {n} {pprep (FL→perm fl) ∘ₚ pid} {pprep (FL→perm fl)} record {peq = λ q → refl } x=0' x=0') ⟩ -- prefl won't work perm→FL (shrink (pprep (FL→perm fl)) x=0' ) ≡⟨ pcong-pF shrink-iso ⟩ perm→FL ( FL→perm fl ) ≡⟨ FL→iso fl ⟩ fl ∎ pcong-Fp : {n : ℕ } → {x y : FL n} → x ≡ y → FL→perm x =p= FL→perm y pcong-Fp {n} {x} {x} refl = prefl FL←iso : {n : ℕ } → (perm : Permutation n n ) → FL→perm ( perm→FL perm ) =p= perm FL←iso {0} perm = record { peq = λ () } FL←iso {suc n} perm = record { peq = λ q → ( begin FL→perm ( perm→FL perm ) ⟨$⟩ʳ q ≡⟨⟩ (pprep (FL→perm (perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm) ))) ∘ₚ pins ( toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)) ) ) ⟨$⟩ʳ q ≡⟨ peq (presp {suc n} {_} {_} {pins ( toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)))} (pprep-cong {n} {FL→perm (perm→FL (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm) ))} (FL←iso _ ) ) prefl ) q ⟩ (pprep (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm)) ∘ₚ pins ( toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)) )) ⟨$⟩ʳ q ≡⟨ peq (presp {suc n} {pprep (shrink (perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) (p=0 perm))} {perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))} {pins ( toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)) )} (shrink-iso2 (p=0 perm)) prefl) q ⟩ ((perm ∘ₚ flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0))))) ∘ₚ pins ( toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)) )) ⟨$⟩ʳ q ≡⟨ peq (presp {suc n} {perm} {_} {flip (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)))) ∘ₚ pins ( toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)))} {pid} prefl record { peq = λ q → inverseʳ (pins (toℕ≤pred[n] (perm ⟨$⟩ʳ (# 0)))) }) q ⟩ ( perm ∘ₚ pid ) ⟨$⟩ʳ q ≡⟨⟩ perm ⟨$⟩ʳ q ∎ ) } FL-inject : {n : ℕ } → {g h : Permutation n n } → perm→FL g ≡ perm→FL h → g =p= h FL-inject {n} {g} {h} g=h = record { peq = λ q → ( begin g ⟨$⟩ʳ q ≡⟨ peq (psym (FL←iso g )) q ⟩ ( FL→perm (perm→FL g) ) ⟨$⟩ʳ q ≡⟨ cong ( λ k → FL→perm k ⟨$⟩ʳ q ) g=h ⟩ ( FL→perm (perm→FL h) ) ⟨$⟩ʳ q ≡⟨ peq (FL←iso h) q ⟩ h ⟨$⟩ʳ q ∎ ) } FLpid : {n : ℕ} → (x : Permutation n n) → perm→FL x ≡ FL0 → FL→perm FL0 =p= pid → x =p= pid FLpid x eq p0id = ptrans pf2 (ptrans pf0 p0id ) where pf2 : x =p= FL→perm (perm→FL x) pf2 = psym (FL←iso x) pf0 : FL→perm (perm→FL x) =p= FL→perm FL0 pf0 = pcong-Fp eq pFL0 : {n : ℕ } → FL0 {n} ≡ perm→FL pid pFL0 {zero} = refl pFL0 {suc n} = cong (λ k → zero :: k ) pFL0
{ "alphanum_fraction": 0.4517923753, "avg_line_length": 44.9346590909, "ext": "agda", "hexsha": "d93c856f4ac3aa7183c35ccdf9b3697341579e9e", "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": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "shinji-kono/Galois", "max_forks_repo_path": "src/Putil.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "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/Galois", "max_issues_repo_path": "src/Putil.agda", "max_line_length": 240, "max_stars_count": 1, "max_stars_repo_head_hexsha": "bf000643c139f40d5783e962bb3b63353ba3d6e4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "shinji-kono/Galois", "max_stars_repo_path": "src/Putil.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-16T03:37:05.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-16T03:37:05.000Z", "num_tokens": 15113, "size": 31634 }