Search is not available for this dataset
text
string
meta
dict
module foldr-++ where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; cong) open Eq.≡-Reasoning open import lists using (List; _∷_; []; _++_; foldr) -- 結合したリストの重畳は、重畳した結果を初期値とした重畳と等しいことの証明 foldr-++ : ∀ {A B : Set} → (_⊗_ : A → B → B) → (e : B) → (xs ys : List A) → foldr _⊗_ e (xs ++ ys) ≡ foldr _⊗_ (foldr _⊗_ e ys) xs foldr-++ _⊗_ e [] ys = begin foldr _⊗_ e ([] ++ ys) ≡⟨⟩ foldr _⊗_ e ys ≡⟨⟩ foldr _⊗_ (foldr _⊗_ e ys) [] ∎ foldr-++ _⊗_ e (x ∷ xs) ys = begin foldr _⊗_ e ((x ∷ xs) ++ ys) ≡⟨⟩ x ⊗ (foldr _⊗_ e (xs ++ ys)) ≡⟨ cong (x ⊗_) (foldr-++ _⊗_ e xs ys) ⟩ x ⊗ (foldr _⊗_ (foldr _⊗_ e ys) xs) ≡⟨⟩ foldr _⊗_ (foldr _⊗_ e ys) (x ∷ xs) ∎
{ "alphanum_fraction": 0.5195530726, "avg_line_length": 24.6896551724, "ext": "agda", "hexsha": "28335f0d8944a3f0abdcbc4a25260a8ffdb033d9", "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": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "akiomik/plfa-solutions", "max_forks_repo_path": "part1/lists/foldr-++.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "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": "akiomik/plfa-solutions", "max_issues_repo_path": "part1/lists/foldr-++.agda", "max_line_length": 73, "max_stars_count": 1, "max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "akiomik/plfa-solutions", "max_stars_repo_path": "part1/lists/foldr-++.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z", "num_tokens": 403, "size": 716 }
module LC.Subst.Term where open import LC.Base open import LC.Subst.Var open import Data.Nat open import Data.Nat.Properties open import Relation.Nullary -------------------------------------------------------------------------------- -- lifting terms lift : (n i : ℕ) → Term → Term lift n i (var x) = var (lift-var n i x) lift n i (ƛ M) = ƛ lift (suc n) i M lift n i (M ∙ N) = lift n i M ∙ lift n i N -------------------------------------------------------------------------------- -- properties of lift open import Relation.Binary.PropositionalEquality hiding ([_]) -- lift l (n + i) -- ∙ --------------------------> ∙ -- | | -- | | -- lift l (n + m + i) lift (l + n) m -- | | -- ∨ ∨ -- ∙ --------------------------> ∙ -- lift-lemma : ∀ l m n i N → lift l (n + m + i) N ≡ lift (l + n) m (lift l (n + i) N) lift-lemma l m n i (var x) = cong var_ (LC.Subst.Var.lift-var-lemma l m n i x) lift-lemma l m n i (ƛ M) = cong ƛ_ (lift-lemma (suc l) m n i M) lift-lemma l m n i (M ∙ N) = cong₂ _∙_ (lift-lemma l m n i M) (lift-lemma l m n i N) -- lift (l + n) i -- ∙ --------------------------> ∙ -- | | -- | | -- lift l m lift l m -- | | -- ∨ ∨ -- ∙ --------------------------> ∙ -- lift (l + m + n) i lift-lift : ∀ l m n i N → lift l m (lift (l + n) i N) ≡ lift (l + m + n) i (lift l m N) lift-lift l m n i (var x) = cong var_ (lift-var-lift-var l m n i x) lift-lift l m n i (ƛ N) = cong ƛ_ (lift-lift (suc l) m n i N) lift-lift l m n i (M ∙ N) = cong₂ _∙_ (lift-lift l m n i M) (lift-lift l m n i N) -------------------------------------------------------------------------------- -- substituting variables data Match : ℕ → ℕ → Set where Under : ∀ {i x} → x < i → Match x i Exact : ∀ {i x} → x ≡ i → Match x i Above : ∀ {i} v → suc v > i → Match (suc v) i open import Relation.Binary.Definitions match : (x i : ℕ) → Match x i match x i with <-cmp x i match x i | tri< a ¬b ¬c = Under a match x i | tri≈ ¬a b ¬c = Exact b match (suc x) i | tri> ¬a ¬b c = Above x c subst-var : ∀ {x i} → Match x i → Term → Term subst-var {x} (Under _) N = var x subst-var {_} {i} (Exact _) N = lift 0 i N subst-var (Above x _) N = var x -------------------------------------------------------------------------------- -- properties of subst-var open import Relation.Nullary.Negation using (contradiction) open ≡-Reasoning subst-var-match-< : ∀ {m n} N → (m<n : m < n) → subst-var (match m n) N ≡ var m subst-var-match-< {m} {n} N m<n with match m n ... | Under m<n' = refl ... | Exact m≡n = contradiction m≡n (<⇒≢ m<n) ... | Above _ m>n = contradiction m>n (<⇒≱ (≤-step m<n)) subst-var-match-≡ : ∀ {m n} N → (m≡n : m ≡ n) → subst-var {_} {n} (match m n) N ≡ lift 0 n N subst-var-match-≡ {m} {.m} N refl with match m m ... | Under m<m = contradiction refl (<⇒≢ m<m) ... | Exact m≡m = refl ... | Above _ m>m = contradiction refl (<⇒≢ m>m) subst-var-match-> : ∀ {m n} N → (1+m>n : suc m > n) → subst-var (match (suc m) n) N ≡ var m subst-var-match-> {m} {n} N 1+m<n with match (suc m) n ... | Under m<n = contradiction m<n (<⇒≱ (≤-step 1+m<n)) ... | Exact m≡n = contradiction (sym m≡n) (<⇒≢ 1+m<n) ... | Above _ m>n = refl -- subst-var (match x m) -- ∙ -------------------------------------------------------> ∙ -- | | -- | | -- lift n lift (m + n) -- | | -- ∨ ∨ -- ∙ --------------------------------------------------------> ∙ -- subst-var (match (lift-var (suc (m + n)) i x) m) open import Relation.Binary.PropositionalEquality hiding (preorder; [_]) open ≡-Reasoning subst-var-lift : ∀ m n i x N → subst-var (match (lift-var (suc (m + n)) i x) m) (lift n i N) ≡ lift (m + n) i (subst-var (match x m) N) subst-var-lift m n i x N with match x m ... | Under x<m = begin subst-var (match (lift-var (suc (m + n)) i x) m) (lift n i N) ≡⟨ cong (λ w → subst-var (match w m) (lift n i N)) (LC.Subst.Var.lift-var-> prop1) ⟩ subst-var (match x m) (lift n i N) ≡⟨ subst-var-match-< (lift n i N) x<m ⟩ var x ≡⟨ cong var_ (sym (LC.Subst.Var.lift-var-> prop2)) ⟩ lift (m + n) i (var x) ∎ where prop1 : suc (m + n) > x prop1 = ≤-trans x<m (≤-step (m≤m+n m n)) prop2 : m + n > x prop2 = ≤-trans x<m (m≤m+n m n) ... | Exact refl = begin subst-var (match (lift-var (suc (m + n)) i m) m) (lift n i N) ≡⟨ cong (λ w → subst-var (match w m) (lift n i N)) (LC.Subst.Var.lift-var-> prop) ⟩ subst-var (match m m) (lift n i N) ≡⟨ subst-var-match-≡ (lift n i N) refl ⟩ lift 0 m (lift n i N) ≡⟨ lift-lift 0 m n i N ⟩ lift (m + n) i (lift 0 m N) ∎ where prop : suc (m + n) > m prop = s≤s (m≤m+n m n) ... | Above v m≤v with inspectBinding (suc m + n) (suc v) ... | Free n≤x = begin subst-var (match (i + suc v) m) (lift n i N) ≡⟨ cong (λ w → subst-var (match w m) (lift n i N)) (+-suc i v) ⟩ subst-var (match (suc i + v) m) (lift n i N) ≡⟨ subst-var-match-> (lift n i N) prop ⟩ var (i + v) ≡⟨ cong var_ (sym (LC.Subst.Var.lift-var-≤ prop2)) ⟩ var (lift-var (m + n) i v) ∎ where prop : suc (i + v) > m prop = s≤s (≤-trans (≤-pred m≤v) (m≤n+m v i)) prop2 : m + n ≤ v prop2 = ≤-pred n≤x ... | Bound n>x = begin subst-var (match (suc v) m) (lift n i N) ≡⟨ subst-var-match-> {v} {m} (lift n i N) m≤v ⟩ var v ≡⟨ cong var_ (sym (LC.Subst.Var.lift-var-> {m + n} {i} {v} (≤-pred n>x))) ⟩ var (lift-var (m + n) i v) ∎
{ "alphanum_fraction": 0.4054950261, "avg_line_length": 35.9829545455, "ext": "agda", "hexsha": "a3ab38b89a0473615773daa6c22acc237e55cea0", "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": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/bidirectional", "max_forks_repo_path": "LC/Subst/Term.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "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": "banacorn/bidirectional", "max_issues_repo_path": "LC/Subst/Term.agda", "max_line_length": 92, "max_stars_count": 2, "max_stars_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/bidirectional", "max_stars_repo_path": "LC/Subst/Term.agda", "max_stars_repo_stars_event_max_datetime": "2020-08-25T14:05:01.000Z", "max_stars_repo_stars_event_min_datetime": "2020-08-25T07:34:40.000Z", "num_tokens": 2119, "size": 6333 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types open import LibraBFT.Concrete.Records open import LibraBFT.Concrete.System open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Impl.Consensus.ConsensusProvider as ConsensusProvider open import LibraBFT.Impl.Consensus.Properties.ConsensusProvider as ConsensusProviderProps import LibraBFT.Impl.IO.OBM.GenKeyFile as GenKeyFile open import LibraBFT.Impl.IO.OBM.InputOutputHandlers open import LibraBFT.Impl.IO.OBM.Start open import LibraBFT.Impl.OBM.Logging.Logging open import LibraBFT.Impl.Properties.Util open import LibraBFT.ImplShared.Base.Types open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.NetworkMsg open import LibraBFT.ImplShared.Util.Dijkstra.All open import Optics.All open import Util.PKCS open import Util.Prelude open import Yasm.System ℓ-RoundManager ℓ-VSFP ConcSysParms open Invariants open RoundManagerTransProps open InitProofDefs module LibraBFT.Impl.IO.OBM.Properties.Start where module startViaConsensusProviderSpec (now : Instant) (nfl : GenKeyFile.NfLiwsVsVvPe) (txTDS : TxTypeDependentStuffForNetwork) where -- It is somewhat of an overkill to write a separate contract for the last step, -- but keeping it explicit for pedagogical reasons contract-step₁ : ∀ (tup : (NodeConfig × OnChainConfigPayload × LedgerInfoWithSignatures × SK × ProposerElection)) → EitherD-weakestPre (startViaConsensusProvider-ed.step₁ now nfl txTDS tup) (InitContract nothing) contract-step₁ (nodeConfig , payload , liws , sk , pe) = startConsensusSpec.contract' nodeConfig now payload liws sk ObmNeedFetch∙new (txTDS ^∙ ttdsnProposalGenerator) (txTDS ^∙ ttdsnStateComputer) contract' : EitherD-weakestPre (startViaConsensusProvider-ed-abs now nfl txTDS) (InitContract nothing) contract' rewrite startViaConsensusProvider-ed-abs-≡ = -- TODO-2: this is silly; perhaps we should have an EitherD-⇒-bind-const or something for when -- we don't need to know anything about the values returned by part before the bind? EitherD-⇒-bind (ConsensusProvider.obmInitialData-ed-abs nfl) (EitherD-vacuous (ConsensusProvider.obmInitialData-ed-abs nfl)) P⇒Q where P⇒Q : EitherD-Post-⇒ (const Unit) (EitherD-weakestPre-bindPost _ (InitContract nothing)) P⇒Q (Left _) _ = tt P⇒Q (Right tup') _ c refl = contract-step₁ tup'
{ "alphanum_fraction": 0.7537688442, "avg_line_length": 48.0344827586, "ext": "agda", "hexsha": "20ae99d8b2d4486f41f17bad0d8cfebff614daf6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/IO/OBM/Properties/Start.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/IO/OBM/Properties/Start.agda", "max_line_length": 115, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/IO/OBM/Properties/Start.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 761, "size": 2786 }
open import Level open import Data.Product open import Relation.Nullary open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong) module AlgProg where -- 1.1 Datatypes private variable l : Level data Bool : Set where false : Bool true : Bool data Char : Set where ca : Char cb : Char cc : Char data Either : Set where bool : Bool → Either char : Char → Either data Both : Set where tuple : Bool × Char → Both not : Bool → Bool not false = true not true = false switch : Both → Both switch (tuple (b , c)) = tuple (not b , c) and : (Bool × Bool) → Bool and (false , _) = false and (true , b) = b cand : Bool → Bool → Bool cand false _ = false cand true b = b curry' : {A B C : Set} → (B → (C → A)) → ((B × C) → A) curry' f (b , c) = f b c data maybe (A : Set l) : Set l where nothing : maybe A just : (x : A) → maybe A -- 1.2 Natural Numbers data Nat : Set where zero' : Nat 1+ : Nat → Nat {-# BUILTIN NATURAL Nat #-} {- plus : Nat × Nat → Nat plus (n , zero') = n plus (n , succ m) = succ (plus (n , m)) mult : Nat × Nat → Nat mult (n , zero') = zero' mult (n , succ m) = plus (n , mult (n , m)) -} _+_ : Nat → Nat → Nat n + 0 = n n + (1+ m) = 1+ (n + m) _*_ : Nat → Nat → Nat n * 0 = 0 n * (1+ m) = n + (n * m) fact : Nat → Nat fact 0 = 1 fact (1+ n) = (1+ n) * (fact n) fib : Nat → Nat fib 0 = 0 fib (1+ 0) = 1 fib (1+ (1+ n)) = (fib n) + (fib (1+ n)) foldn : {A : Set} → A → (A → A) → (Nat → A) foldn c h 0 = c foldn c h (1+ n) = h (foldn c h n) foldn1+is+ : (m n : Nat) → (m + n) ≡ ((foldn m 1+) n) foldn1+is+ m 0 = refl foldn1+is+ m (1+ n) = cong 1+ (foldn1+is+ m n) foldn+is* : (m n : Nat) → m * n ≡ (foldn 0 (λ x → m + x)) n foldn+is* m 0 = refl foldn+is* m (1+ n) = cong (λ x → m + x) (foldn+is* m n) expn : Nat → Nat → Nat expn m = foldn 1 (λ n → m * n) outl : {A B : Set} → (A × B) → A outl (fst , snd) = fst outr : {A B : Set} → (A × B) → B outr (fst , snd) = snd f1 : (Nat × Nat) → Nat × Nat f1 (m , n) = (1+ m , (1+ m) * n) rec-× : {A B C D : Set} → (f : A → B) → (g : C → D) → ((A × C) -> (B × D)) rec-× f g (a , c) = (f a , g c) outrFoldnIsFact : (n : Nat) → (foldn (0 , 1) f1 n) ≡ (n , fact n) outrFoldnIsFact zero' = refl outrFoldnIsFact (1+ n) rewrite (outrFoldnIsFact n) = refl -- 1.3 Lists data listr (A : Set l) : Set l where nil : listr A cons : A → listr A → listr A data listl (A : Set l) : Set l where nil : listl A snoc : listl A → A → listl A snocr : {A : Set} → listr A → A → listr A snocr nil a = cons a nil snocr (cons a0 as) a1 = cons a0 (snocr as a1) convert : {A : Set} → listl A → listr A convert nil = nil convert (snoc xs x) = snocr (convert xs) x _++_ : {A : Set} → listl A → listl A → listl A xs ++ nil = xs xs ++ snoc ys x = snoc (xs ++ ys) x ++-assoc : {A : Set} → (xs ys zs : listl A) → (xs ++ (ys ++ zs)) ≡ ((xs ++ ys) ++ zs) ++-assoc xs ys nil = refl ++-assoc xs ys (snoc zs x) = cong (λ y → snoc y x) (++-assoc xs ys zs) listrF : {A B : Set} → (A → B) → listr A → listr B listrF f nil = nil listrF f (cons x as) = cons (f x) (listrF f as) foldr : {A B : Set} → B → (A → B → B) → (listr A → B) foldr c h nil = c foldr c h (cons a as) = h a (foldr c h as)
{ "alphanum_fraction": 0.5363321799, "avg_line_length": 20.3782051282, "ext": "agda", "hexsha": "d691dadfa72daf790e942a03a2dbefb29f7686b4", "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": "a95902da2286ff588f4a97f6b23700fd325a564f", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "polymonyrks/algprog", "max_forks_repo_path": "AlgProg.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a95902da2286ff588f4a97f6b23700fd325a564f", "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": "polymonyrks/algprog", "max_issues_repo_path": "AlgProg.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "a95902da2286ff588f4a97f6b23700fd325a564f", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "polymonyrks/algprog", "max_stars_repo_path": "AlgProg.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1346, "size": 3179 }
{- Formal verification of authenticated append-only skiplists in Agda, version 1.0. Copyright (c) 2020 Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import Data.Unit.NonEta open import Data.Empty open import Data.Sum open import Data.Product open import Data.Product.Properties open import Data.Fin open import Data.Fin.Properties renaming (_≟_ to _≟Fin_) open import Data.Nat renaming (_≟_ to _≟ℕ_; _≤?_ to _≤?ℕ_) open import Data.Nat.Divisibility open import Data.List renaming (map to List-map) open import Data.List.Properties using (∷-injective) open import Data.List.Relation.Unary.Any open import Data.List.Relation.Unary.All renaming (map to All-map) open import Data.List.Relation.Unary.All.Properties hiding (All-map) open import Data.List.Relation.Unary.Any.Properties open import Data.List.Relation.Binary.Pointwise using (decidable-≡) open import Data.Bool open import Data.Maybe renaming (map to Maybe-map) open import Function open import Relation.Binary.PropositionalEquality open import Relation.Binary.Core open import Relation.Nullary -- This module provides an injective way to encode natural numbers module Data.Nat.Encode where -- Represents a list of binary digits with -- a leading one in reverse order. -- -- 9, in binary: 1001 -- -- remove leading 1: 001, -- reverse: 100 -- -- as 𝔹+1: I O O ε -- data 𝔹+1 : Set where ε : 𝔹+1 O_ : 𝔹+1 → 𝔹+1 I_ : 𝔹+1 → 𝔹+1 from𝔹+1 : 𝔹+1 → ℕ from𝔹+1 ε = 1 from𝔹+1 (O b) = 2 * from𝔹+1 b from𝔹+1 (I b) = suc (2 * from𝔹+1 b) -- Adds zero to our representation data 𝔹 : Set where z : 𝔹 s : 𝔹+1 → 𝔹 from𝔹 : 𝔹 → ℕ from𝔹 z = 0 from𝔹 (s b) = from𝔹+1 b inc : 𝔹+1 → 𝔹+1 inc ε = O ε inc (O x) = I x inc (I x) = O (inc x) inc-ε-⊥ : ∀{b} → inc b ≡ ε → ⊥ inc-ε-⊥ {ε} () inc-ε-⊥ {O b} () inc-ε-⊥ {I b} () to𝔹+1 : ℕ → 𝔹+1 to𝔹+1 zero = ε to𝔹+1 (suc n) = inc (to𝔹+1 n) to𝔹 : ℕ → 𝔹 to𝔹 zero = z to𝔹 (suc n) = s (to𝔹+1 n) toBitString+1 : 𝔹+1 → List Bool toBitString+1 ε = [] toBitString+1 (I x) = true ∷ toBitString+1 x toBitString+1 (O x) = false ∷ toBitString+1 x toBitString : 𝔹 → List Bool toBitString z = [] -- For an actual binary number as we know, we need -- to reverse the result of toBitString+1; for the sake of encoding -- a number as a list of booleans, this works just fine toBitString (s x) = true ∷ toBitString+1 x encodeℕ : ℕ → List Bool encodeℕ = toBitString ∘ to𝔹 --------------------- -- Injectivity proofs O-inj : ∀{b1 b2} → O b1 ≡ O b2 → b1 ≡ b2 O-inj refl = refl I-inj : ∀{b1 b2} → I b1 ≡ I b2 → b1 ≡ b2 I-inj refl = refl s-inj : ∀{b1 b2} → s b1 ≡ s b2 → b1 ≡ b2 s-inj refl = refl inc-inj : ∀ b1 b2 → inc b1 ≡ inc b2 → b1 ≡ b2 inc-inj ε ε hip = refl inc-inj ε (I b2) hip = ⊥-elim (inc-ε-⊥ (sym (O-inj hip))) inc-inj (I b1) ε hip = ⊥-elim (inc-ε-⊥ (O-inj hip)) inc-inj (O b1) (O b2) hip = cong O_ (I-inj hip) inc-inj (I b1) (I b2) hip = cong I_ (inc-inj b1 b2 (O-inj hip)) to𝔹+1-inj : ∀ n m → to𝔹+1 n ≡ to𝔹+1 m → n ≡ m to𝔹+1-inj zero zero hip = refl to𝔹+1-inj zero (suc m) hip = ⊥-elim (inc-ε-⊥ (sym hip)) to𝔹+1-inj (suc n) zero hip = ⊥-elim (inc-ε-⊥ hip) to𝔹+1-inj (suc n) (suc m) hip = cong suc (to𝔹+1-inj n m (inc-inj _ _ hip)) to𝔹-inj : ∀ n m → to𝔹 n ≡ to𝔹 m → n ≡ m to𝔹-inj zero zero hip = refl to𝔹-inj (suc n) (suc m) hip = cong suc (to𝔹+1-inj n m (s-inj hip)) toBitString+1-inj : ∀ b1 b2 → toBitString+1 b1 ≡ toBitString+1 b2 → b1 ≡ b2 toBitString+1-inj ε ε hip = refl toBitString+1-inj (O b1) (O b2) hip = cong O_ (toBitString+1-inj b1 b2 (proj₂ (∷-injective hip))) toBitString+1-inj (I b1) (I b2) hip = cong I_ (toBitString+1-inj b1 b2 (proj₂ (∷-injective hip))) toBitString-inj : ∀ b1 b2 → toBitString b1 ≡ toBitString b2 → b1 ≡ b2 toBitString-inj z z hip = refl toBitString-inj (s x) (s x₁) hip = cong s (toBitString+1-inj x x₁ (proj₂ (∷-injective hip))) encodeℕ-inj : ∀ n m → encodeℕ n ≡ encodeℕ m → n ≡ m encodeℕ-inj n m hip = to𝔹-inj n m (toBitString-inj (to𝔹 n) (to𝔹 m) hip)
{ "alphanum_fraction": 0.6353310778, "avg_line_length": 28.9370629371, "ext": "agda", "hexsha": "2cfab2026a47f2d569d7b66e2e123c5ecefb6be2", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-02-18T04:33:50.000Z", "max_forks_repo_forks_event_min_datetime": "2020-12-22T00:01:03.000Z", "max_forks_repo_head_hexsha": "318881fb24af06bbaafa33edeea0745eca1873f0", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/aaosl-agda", "max_forks_repo_path": "Data/Nat/Encode.agda", "max_issues_count": 5, "max_issues_repo_head_hexsha": "318881fb24af06bbaafa33edeea0745eca1873f0", "max_issues_repo_issues_event_max_datetime": "2021-02-12T04:16:40.000Z", "max_issues_repo_issues_event_min_datetime": "2021-01-04T03:45:34.000Z", "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/aaosl-agda", "max_issues_repo_path": "Data/Nat/Encode.agda", "max_line_length": 111, "max_stars_count": 9, "max_stars_repo_head_hexsha": "318881fb24af06bbaafa33edeea0745eca1873f0", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/aaosl-agda", "max_stars_repo_path": "Data/Nat/Encode.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-31T10:16:38.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-22T00:01:00.000Z", "num_tokens": 1703, "size": 4138 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import groups.Pointed module groups.Int where abstract ℤ→ᴳ-η : ∀ {i} {G : Group i} (φ : ℤ-group →ᴳ G) → GroupHom.f φ ∼ Group.exp G (GroupHom.f φ 1) ℤ→ᴳ-η φ (pos 0) = GroupHom.pres-ident φ ℤ→ᴳ-η φ (pos 1) = idp ℤ→ᴳ-η {G = G} φ (pos (S (S n))) = GroupHom.pres-comp φ 1 (pos (S n)) ∙ ap (Group.comp G (GroupHom.f φ 1)) (ℤ→ᴳ-η φ (pos (S n))) ∙ ! (Group.exp-+ G (GroupHom.f φ 1) 1 (pos (S n))) ℤ→ᴳ-η φ (negsucc 0) = GroupHom.pres-inv φ 1 ℤ→ᴳ-η {G = G} φ (negsucc (S n)) = GroupHom.pres-comp φ -1 (negsucc n) ∙ ap2 (Group.comp G) (GroupHom.pres-inv φ 1) (ℤ→ᴳ-η φ (negsucc n)) ∙ ! (Group.exp-+ G (GroupHom.f φ 1) -1 (negsucc n)) ℤ-idf-η : ∀ i → i == Group.exp ℤ-group 1 i ℤ-idf-η = ℤ→ᴳ-η (idhom _) ℤ→ᴳ-unicity : ∀ {i} {G : Group i} → (φ ψ : ℤ-group →ᴳ G) → GroupHom.f φ 1 == GroupHom.f ψ 1 → GroupHom.f φ ∼ GroupHom.f ψ ℤ→ᴳ-unicity {G = G} φ ψ p i = ℤ→ᴳ-η φ i ∙ ap (λ g₁ → Group.exp G g₁ i) p ∙ ! (ℤ→ᴳ-η ψ i) ℤ→ᴳ-equiv-idf : ∀ {i} (G : Group i) → (ℤ-group →ᴳ G) ≃ Group.El G ℤ→ᴳ-equiv-idf G = equiv (λ φ → GroupHom.f φ 1) (exp-hom G) (λ _ → idp) (λ φ → group-hom= $ λ= $ ! ∘ ℤ→ᴳ-η φ) where open Group G ℤ→ᴳ-iso-idf : ∀ {i} (G : AbGroup i) → hom-group ℤ-group G ≃ᴳ AbGroup.grp G ℤ→ᴳ-iso-idf G = ≃-to-≃ᴳ (ℤ→ᴳ-equiv-idf (AbGroup.grp G)) (λ _ _ → idp) ℤ-⊙group : ⊙Group₀ ℤ-⊙group = ⊙[ ℤ-group , 1 ]ᴳ ℤ-is-infinite-cyclic : is-infinite-cyclic ℤ-⊙group ℤ-is-infinite-cyclic = is-eq (Group.exp ℤ-group 1) (idf ℤ) (! ∘ ℤ-idf-η) (! ∘ ℤ-idf-η)
{ "alphanum_fraction": 0.552496799, "avg_line_length": 31.24, "ext": "agda", "hexsha": "b27e58ed69458b4b0c931a4cdc334e26dce35d3b", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/groups/Int.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/groups/Int.agda", "max_line_length": 74, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/groups/Int.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 803, "size": 1562 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import LogicalFormulae open import Sets.EquivalenceRelations open import Setoids.Setoids module Setoids.Equality {a b : _} {A : Set a} (S : Setoid {a} {b} A) where open import Setoids.Subset S _=S_ : {c d : _} {pred1 : A → Set c} {pred2 : A → Set d} (s1 : subset pred1) (s2 : subset pred2) → Set _ _=S_ {pred1 = pred1} {pred2} s1 s2 = (x : A) → (pred1 x → pred2 x) && (pred2 x → pred1 x) setoidEqualitySymmetric : {c d : _} {pred1 : A → Set c} {pred2 : A → Set d} → (s1 : subset pred1) (s2 : subset pred2) → s1 =S s2 → s2 =S s1 setoidEqualitySymmetric s1 s2 s1=s2 x = _&&_.snd (s1=s2 x) ,, _&&_.fst (s1=s2 x) setoidEqualityTransitive : {c d e : _} {pred1 : A → Set c} {pred2 : A → Set d} {pred3 : A → Set e} (s1 : subset pred1) (s2 : subset pred2) (s3 : subset pred3) → s1 =S s2 → s2 =S s3 → s1 =S s3 setoidEqualityTransitive s1 s2 s3 s1=s2 s2=s3 x with s1=s2 x setoidEqualityTransitive s1 s2 s3 s1=s2 s2=s3 x | p1top2 ,, p1top2' with s2=s3 x setoidEqualityTransitive s1 s2 s3 s1=s2 s2=s3 x | p1top2 ,, p1top2' | fst ,, snd = (λ i → fst (p1top2 i)) ,, λ i → p1top2' (snd i) setoidEqualityReflexive : {c : _} {pred : A → Set c} (s : subset pred) → s =S s setoidEqualityReflexive s x = (λ x → x) ,, λ x → x
{ "alphanum_fraction": 0.6360211002, "avg_line_length": 53.08, "ext": "agda", "hexsha": "f75ace318895ae46f20b7f0cb6a8225c07771f7c", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Setoids/Equality.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Setoids/Equality.agda", "max_line_length": 191, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Setoids/Equality.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": 550, "size": 1327 }
-- Andreas, 2015-10-28 adapted from test case by -- Ulf, 2014-02-06, shrunk from Wolfram Kahl's report open import Common.Equality open import Common.Unit open import Common.Nat postulate prop : ∀ x → x ≡ unit record StrictTotalOrder : Set where field compare : Unit open StrictTotalOrder module M (Key : StrictTotalOrder) where postulate intersection′-₁ : ∀ x → x ≡ compare Key to-∈-intersection′ : Nat → Unit → Unit → Set to-∈-intersection′ zero x h = Unit to-∈-intersection′ (suc n) x h with intersection′-₁ x to-∈-intersection′ (suc n) ._ h | refl with prop h to-∈-intersection′ (suc n) ._ ._ | refl | refl = to-∈-intersection′ n unit unit
{ "alphanum_fraction": 0.6705370102, "avg_line_length": 27.56, "ext": "agda", "hexsha": "49803acff2c37ffdee59ed68ee9a3a2c6fa52461", "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/Issue1035.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/Issue1035.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/Succeed/Issue1035.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": 226, "size": 689 }
------------------------------------------------------------------------ -- A non-recursive variant of H-level.Truncation.Propositional.Erased ------------------------------------------------------------------------ -- The definition does use natural numbers. The code is based on van -- Doorn's "Constructing the Propositional Truncation using -- Non-recursive HITs". {-# OPTIONS --erased-cubical --safe #-} import Equality.Path as P module H-level.Truncation.Propositional.Non-recursive.Erased {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where private open module PD = P.Derived-definitions-and-properties eq hiding (elim) open import Logical-equivalence using (_⇔_) open import Prelude hiding ([_,_]) open import Colimit.Sequential.Very-erased eq as C using (Colimitᴱ) open import Equality.Decidable-UIP equality-with-J open import Equality.Path.Isomorphisms eq open import Equivalence equality-with-J as Eq using (_≃_) open import Equivalence.Erased.Cubical eq as EEq using (_≃ᴱ_) open import Erased.Cubical eq open import Function-universe equality-with-J as F hiding (_∘_) open import H-level equality-with-J open import H-level.Closure equality-with-J open import H-level.Truncation.Propositional.One-step eq as O using (∥_∥¹-out-^) private variable a p : Level A : Type a P : A → Type p e x z : A ------------------------------------------------------------------------ -- The type -- The propositional truncation operator. ∥_∥ᴱ : Type a → Type a ∥ A ∥ᴱ = Colimitᴱ A (∥ A ∥¹-out-^ ∘ suc) O.∣_∣ O.∣_∣ -- The point constructor. ∣_∣ : A → ∥ A ∥ᴱ ∣_∣ = C.∣_∣₀ -- The eliminator. record Elim {A : Type a} (P : ∥ A ∥ᴱ → Type p) : Type (a ⊔ p) where no-eta-equality field ∣∣ʳ : ∀ x → P ∣ x ∣ @0 is-propositionʳ : ∀ x → Is-proposition (P x) open Elim public elim : Elim P → (x : ∥ A ∥ᴱ) → P x elim {A = A} {P = P} e = C.elim λ where .C.Elim.∣∣₀ʳ → E.∣∣ʳ .C.Elim.∣∣₊ʳ {n = n} → helper n .C.Elim.∣∣₊≡∣∣₀ʳ x → subst P (C.∣∣₊≡∣∣₀ x) (subst P (sym (C.∣∣₊≡∣∣₀ x)) (E.∣∣ʳ x)) ≡⟨ subst-subst-sym _ _ _ ⟩∎ E.∣∣ʳ x ∎ .C.Elim.∣∣₊≡∣∣₊ʳ {n = n} x → subst P (C.∣∣₊≡∣∣₊ x) (subst P (sym (C.∣∣₊≡∣∣₊ x)) (helper n x)) ≡⟨ subst-subst-sym _ _ _ ⟩∎ helper n x ∎ where module E = Elim e @0 helper : ∀ n (x : ∥ A ∥¹-out-^ (suc n)) → P C.∣ x ∣₊ helper zero = O.elim e₀ where e₀ : O.Elim _ e₀ .O.Elim.∣∣ʳ x = subst P (sym (C.∣∣₊≡∣∣₀ x)) (E.∣∣ʳ x) e₀ .O.Elim.∣∣-constantʳ _ _ = E.is-propositionʳ _ _ _ helper (suc n) = O.elim e₊ where e₊ : O.Elim _ e₊ .O.Elim.∣∣ʳ x = subst P (sym (C.∣∣₊≡∣∣₊ x)) (helper n x) e₊ .O.Elim.∣∣-constantʳ _ _ = E.is-propositionʳ _ _ _ _ : elim e ∣ x ∣ ≡ e .∣∣ʳ x _ = refl _ -- The propositional truncation operator returns propositions (in -- erased contexts). @0 ∥∥ᴱ-proposition : Is-proposition ∥ A ∥ᴱ ∥∥ᴱ-proposition {A = A} = elim lemma₅ where lemma₀ : ∀ n (x : A) → C.∣ O.∣ x ∣-out-^ (1 + n) ∣₊ ≡ ∣ x ∣ lemma₀ zero x = C.∣ O.∣ x ∣ ∣₊ ≡⟨ C.∣∣₊≡∣∣₀ x ⟩∎ C.∣ x ∣₀ ∎ lemma₀ (suc n) x = C.∣ O.∣ O.∣ x ∣-out-^ (1 + n) ∣ ∣₊ ≡⟨ C.∣∣₊≡∣∣₊ (O.∣ x ∣-out-^ (1 + n)) ⟩ C.∣ O.∣ x ∣-out-^ (1 + n) ∣₊ ≡⟨ lemma₀ n x ⟩∎ ∣ x ∣ ∎ lemma₁₀ : ∀ (x y : A) → ∣ x ∣ ≡ C.∣ y ∣₀ lemma₁₀ x y = ∣ x ∣ ≡⟨ sym (lemma₀ 0 x) ⟩ C.∣ O.∣ x ∣-out-^ 1 ∣₊ ≡⟨⟩ C.∣ O.∣ O.∣ x ∣-out-^ 0 ∣ ∣₊ ≡⟨ cong C.∣_∣₊ (O.∣∣-constant _ _) ⟩ C.∣ O.∣ y ∣ ∣₊ ≡⟨ C.∣∣₊≡∣∣₀ y ⟩∎ C.∣ y ∣₀ ∎ lemma₁₊ : ∀ n (x : A) (y : ∥ A ∥¹-out-^ (1 + n)) → ∣ x ∣ ≡ C.∣ y ∣₊ lemma₁₊ n x y = ∣ x ∣ ≡⟨ sym (lemma₀ (1 + n) x) ⟩ C.∣ O.∣ x ∣-out-^ (2 + n) ∣₊ ≡⟨⟩ C.∣ O.∣ O.∣ x ∣-out-^ (1 + n) ∣ ∣₊ ≡⟨ cong C.∣_∣₊ (O.∣∣-constant _ _) ⟩ C.∣ O.∣ y ∣ ∣₊ ≡⟨ C.∣∣₊≡∣∣₊ y ⟩∎ C.∣ y ∣₊ ∎ lemma₂ : ∀ n (x y : ∥ A ∥¹-out-^ (1 + n)) (p : x ≡ y) (q : O.∣ x ∣ ≡ O.∣ y ∣) → trans (C.∣∣₊≡∣∣₊ {P₊ = ∥ A ∥¹-out-^ ∘ suc} {step₀ = O.∣_∣} x) (cong C.∣_∣₊ p) ≡ trans (cong C.∣_∣₊ q) (C.∣∣₊≡∣∣₊ y) lemma₂ n x y p q = trans (C.∣∣₊≡∣∣₊ x) (cong C.∣_∣₊ p) ≡⟨ PD.elim (λ {x y} p → trans (C.∣∣₊≡∣∣₊ x) (cong C.∣_∣₊ p) ≡ trans (cong C.∣_∣₊ (cong O.∣_∣ p)) (C.∣∣₊≡∣∣₊ y)) (λ x → trans (C.∣∣₊≡∣∣₊ x) (cong C.∣_∣₊ (refl _)) ≡⟨ cong (trans _) $ cong-refl _ ⟩ trans (C.∣∣₊≡∣∣₊ x) (refl _) ≡⟨ trans-reflʳ _ ⟩ C.∣∣₊≡∣∣₊ x ≡⟨ sym $ trans-reflˡ _ ⟩ trans (refl _) (C.∣∣₊≡∣∣₊ x) ≡⟨ cong (flip trans _) $ sym $ trans (cong (cong C.∣_∣₊) $ cong-refl _) $ cong-refl _ ⟩∎ trans (cong C.∣_∣₊ (cong O.∣_∣ (refl _))) (C.∣∣₊≡∣∣₊ x) ∎) p ⟩ trans (cong C.∣_∣₊ (cong O.∣_∣ p)) (C.∣∣₊≡∣∣₊ y) ≡⟨ cong (flip trans _) $ cong-preserves-Constant (λ u v → C.∣ u ∣₊ ≡⟨ sym (C.∣∣₊≡∣∣₊ u) ⟩ C.∣ O.∣ u ∣ ∣₊ ≡⟨ cong C.∣_∣₊ (O.∣∣-constant _ _) ⟩ C.∣ O.∣ v ∣ ∣₊ ≡⟨ C.∣∣₊≡∣∣₊ v ⟩∎ C.∣ v ∣₊ ∎) _ _ ⟩∎ trans (cong C.∣_∣₊ q) (C.∣∣₊≡∣∣₊ y) ∎ lemma₃ : ∀ n x y (p : C.∣ O.∣ y ∣ ∣₊ ≡ z) → subst (∣ x ∣ ≡_) p (lemma₁₊ n x O.∣ y ∣) ≡ trans (sym (lemma₀ n x)) (trans (cong C.∣_∣₊ (O.∣∣-constant _ _)) p) lemma₃ n x y p = subst (∣ x ∣ ≡_) p (lemma₁₊ n x O.∣ y ∣) ≡⟨ sym trans-subst ⟩ trans (lemma₁₊ n x O.∣ y ∣) p ≡⟨⟩ trans (trans (sym (trans (C.∣∣₊≡∣∣₊ (O.∣ x ∣-out-^ (1 + n))) (lemma₀ n x))) (trans (cong C.∣_∣₊ (O.∣∣-constant (O.∣ x ∣-out-^ (1 + n)) O.∣ y ∣)) (C.∣∣₊≡∣∣₊ O.∣ y ∣))) p ≡⟨ trans (cong (λ eq → trans (trans eq (trans (cong C.∣_∣₊ (O.∣∣-constant _ _)) (C.∣∣₊≡∣∣₊ _))) p) $ sym-trans _ _) $ trans (trans-assoc _ _ _) $ trans (trans-assoc _ _ _) $ cong (trans (sym (lemma₀ n _))) $ sym $ trans-assoc _ _ _ ⟩ trans (sym (lemma₀ n x)) (trans (trans (sym (C.∣∣₊≡∣∣₊ (O.∣ x ∣-out-^ (1 + n)))) (trans (cong C.∣_∣₊ (O.∣∣-constant (O.∣ x ∣-out-^ (1 + n)) O.∣ y ∣)) (C.∣∣₊≡∣∣₊ O.∣ y ∣))) p) ≡⟨ cong (λ eq → trans (sym (lemma₀ n _)) (trans (trans (sym (C.∣∣₊≡∣∣₊ _)) eq) p)) $ sym $ lemma₂ _ _ _ _ _ ⟩ trans (sym (lemma₀ n x)) (trans (trans (sym (C.∣∣₊≡∣∣₊ (O.∣ x ∣-out-^ (1 + n)))) (trans (C.∣∣₊≡∣∣₊ (O.∣ x ∣-out-^ (1 + n))) (cong C.∣_∣₊ (O.∣∣-constant _ _)))) p) ≡⟨ cong (λ eq → trans (sym (lemma₀ n _)) (trans eq p)) $ trans-sym-[trans] _ _ ⟩∎ trans (sym (lemma₀ n x)) (trans (cong C.∣_∣₊ (O.∣∣-constant _ _)) p) ∎ lemma₄ : ∀ _ → C.Elim _ lemma₄ x .C.Elim.∣∣₀ʳ = lemma₁₀ x lemma₄ x .C.Elim.∣∣₊ʳ = lemma₁₊ _ x lemma₄ x .C.Elim.∣∣₊≡∣∣₀ʳ y = subst (∣ x ∣ ≡_) (C.∣∣₊≡∣∣₀ y) (lemma₁₊ 0 x O.∣ y ∣) ≡⟨ lemma₃ _ _ _ _ ⟩ trans (sym (lemma₀ 0 x)) (trans (cong C.∣_∣₊ (O.∣∣-constant _ _)) (C.∣∣₊≡∣∣₀ y)) ≡⟨⟩ lemma₁₀ x y ∎ lemma₄ x .C.Elim.∣∣₊≡∣∣₊ʳ {n = n} y = subst (∣ x ∣ ≡_) (C.∣∣₊≡∣∣₊ y) (lemma₁₊ (1 + n) x O.∣ y ∣) ≡⟨ lemma₃ _ _ _ _ ⟩ trans (sym (lemma₀ (1 + n) x)) (trans (cong C.∣_∣₊ (O.∣∣-constant _ _)) (C.∣∣₊≡∣∣₊ y)) ≡⟨⟩ lemma₁₊ n x y ∎ lemma₅ : Elim _ lemma₅ .is-propositionʳ = Π≡-proposition ext lemma₅ .∣∣ʳ x = C.elim (lemma₄ x) ------------------------------------------------------------------------ -- A lemma -- A function of type (x : ∥ A ∥ᴱ) → P x, along with an erased proof -- showing that the function is equal to some erased function, is -- equivalent to a function of type (x : A) → P ∣ x ∣, along with an -- erased equality proof. Σ-Π-∥∥ᴱ-Erased-≡-≃ : {@0 g : (x : ∥ A ∥ᴱ) → P x} → (∃ λ (f : (x : ∥ A ∥ᴱ) → P x) → Erased (f ≡ g)) ≃ (∃ λ (f : (x : A) → P ∣ x ∣) → Erased (f ≡ g ∘ ∣_∣)) Σ-Π-∥∥ᴱ-Erased-≡-≃ {A = A} {P = P} {g = g} = (∃ λ (f : (x : ∥ A ∥ᴱ) → P x) → Erased (f ≡ g)) ↝⟨ (inverse $ Σ-cong (inverse C.universal-property-Π) λ _ → F.id) ⟩ (∃ λ (f : ∃ λ (f₀ : (x : A) → P ∣ x ∣) → Erased ( ∃ λ (f₊ : ∀ n (x : ∥ A ∥¹-out-^ (suc n)) → P C.∣ x ∣₊) → (∀ x → subst P (C.∣∣₊≡∣∣₀ x) (f₊ zero O.∣ x ∣) ≡ f₀ x) × (∀ n x → subst P (C.∣∣₊≡∣∣₊ x) (f₊ (suc n) O.∣ x ∣) ≡ f₊ n x))) → Erased (u⁻¹ f ≡ g)) ↔⟨ inverse $ Σ-assoc F.∘ (∃-cong λ _ → Erased-Σ↔Σ F.∘ (from-equivalence $ Erased-cong (∃-cong λ _ → Eq.extensionality-isomorphism bad-ext))) ⟩ (∃ λ (f : (x : A) → P ∣ x ∣) → Erased ( ∃ λ (e : ∃ λ (f₊ : ∀ n (x : ∥ A ∥¹-out-^ (suc n)) → P C.∣ x ∣₊) → (∀ x → subst P (C.∣∣₊≡∣∣₀ x) (f₊ zero O.∣ x ∣) ≡ f x) × (∀ n x → subst P (C.∣∣₊≡∣∣₊ x) (f₊ (suc n) O.∣ x ∣) ≡ f₊ n x)) → ∀ x → u⁻¹ (f , [ e ]) x ≡ g x)) ↝⟨ (∃-cong λ _ → Erased-cong (∃-cong λ _ → (∃-cong λ _ → from-bijection $ erased Erased↔) F.∘ C.universal-property-Π)) ⟩ (∃ λ (f : (x : A) → P ∣ x ∣) → Erased ( ∃ λ ((f₊ , eq₀ , eq₊) : ∃ λ (f₊ : ∀ n (x : ∥ A ∥¹-out-^ (suc n)) → P C.∣ x ∣₊) → (∀ x → subst P (C.∣∣₊≡∣∣₀ x) (f₊ zero O.∣ x ∣) ≡ f x) × (∀ n x → subst P (C.∣∣₊≡∣∣₊ x) (f₊ (suc n) O.∣ x ∣) ≡ f₊ n x)) → ∃ λ (f≡g₀ : (x : A) → f x ≡ g ∣ x ∣) → ∃ λ (f≡g₊ : ∀ n (x : ∥ A ∥¹-out-^ (suc n)) → f₊ n x ≡ g C.∣ x ∣₊) → (∀ x → subst (λ x → u⁻¹ (f , [ f₊ , eq₀ , eq₊ ]) x ≡ g x) (C.∣∣₊≡∣∣₀ x) (f≡g₊ zero O.∣ x ∣) ≡ f≡g₀ x) × (∀ n (x : ∥ A ∥¹-out-^ (suc n)) → subst (λ x → u⁻¹ (f , [ f₊ , eq₀ , eq₊ ]) x ≡ g x) (C.∣∣₊≡∣∣₊ x) (f≡g₊ (suc n) O.∣ x ∣) ≡ f≡g₊ n x))) ↔⟨ (∃-cong λ _ → Erased-cong ( (∃-cong λ _ → (∃-cong λ _ → inverse Σ-assoc) F.∘ Σ-assoc F.∘ (∃-cong λ _ → (inverse $ Σ-cong (inverse $ Eq.extensionality-isomorphism bad-ext F.∘ (∀-cong ext λ _ → Eq.extensionality-isomorphism bad-ext)) λ _ → F.id) F.∘ ∃-comm) F.∘ inverse Σ-assoc) F.∘ ∃-comm)) ⟩ (∃ λ (f : (x : A) → P ∣ x ∣) → Erased ( ∃ λ (f≡g₀ : (x : A) → f x ≡ g ∣ x ∣) → ∃ λ ((f₊ , f≡g₊) : ∃ λ (f₊ : ∀ n (x : ∥ A ∥¹-out-^ (suc n)) → P C.∣ x ∣₊) → f₊ ≡ λ _ x → g C.∣ x ∣₊) → ∃ λ (eq₀ : ∀ x → subst P (C.∣∣₊≡∣∣₀ x) (f₊ zero O.∣ x ∣) ≡ f x) → ∃ λ (eq₊ : ∀ n x → subst P (C.∣∣₊≡∣∣₊ x) (f₊ (suc n) O.∣ x ∣) ≡ f₊ n x) → (∀ x → subst (λ x → u⁻¹ (f , [ f₊ , eq₀ , eq₊ ]) x ≡ g x) (C.∣∣₊≡∣∣₀ x) (cong (_$ O.∣ x ∣) (cong (_$ zero) f≡g₊)) ≡ f≡g₀ x) × (∀ n (x : ∥ A ∥¹-out-^ (suc n)) → subst (λ x → u⁻¹ (f , [ f₊ , eq₀ , eq₊ ]) x ≡ g x) (C.∣∣₊≡∣∣₊ x) (cong (_$ O.∣ x ∣) (cong (_$ suc n) f≡g₊)) ≡ cong (_$ x) (cong (_$ n) f≡g₊)))) ↔⟨ (∃-cong λ _ → Erased-cong (∃-cong λ _ → (∃-cong λ _ → ∃-cong λ _ → (∀-cong ext λ _ → ≡⇒↝ _ $ cong (_≡ _) $ cong (subst (λ x → u⁻¹ _ x ≡ g x) _) $ trans (cong (cong (_$ _)) $ cong-refl _) $ cong-refl _) ×-cong (∀-cong ext λ _ → ∀-cong ext λ _ → ≡⇒↝ _ $ cong₂ _≡_ (cong (subst (λ x → u⁻¹ _ x ≡ g x) _) $ trans (cong (cong (_$ _)) $ cong-refl _) $ cong-refl _) (trans (cong (cong (_$ _)) $ cong-refl _) $ cong-refl _))) F.∘ (drop-⊤-left-Σ $ _⇔_.to contractible⇔↔⊤ $ singleton-contractible _))) ⟩ (∃ λ (f : (x : A) → P ∣ x ∣) → Erased ( ∃ λ (f≡g₀ : (x : A) → f x ≡ g ∣ x ∣) → ∃ λ (eq₀ : ∀ x → subst P (C.∣∣₊≡∣∣₀ x) (g C.∣ O.∣ x ∣ ∣₊) ≡ f x) → ∃ λ (eq₊ : ∀ n x → subst P (C.∣∣₊≡∣∣₊ x) (g C.∣ O.∣ x ∣ ∣₊) ≡ g C.∣ x ∣₊) → (∀ x → subst (λ x → u⁻¹ (f , [ (λ _ → g ∘ C.∣_∣₊) , eq₀ , eq₊ ]) x ≡ g x) (C.∣∣₊≡∣∣₀ x) (refl _) ≡ f≡g₀ x) × (∀ n (x : ∥ A ∥¹-out-^ (suc n)) → subst (λ x → u⁻¹ (f , [ (λ _ → g ∘ C.∣_∣₊) , eq₀ , eq₊ ]) x ≡ g x) (C.∣∣₊≡∣∣₊ x) (refl _) ≡ refl _))) ↝⟨ (∃-cong λ _ → Erased-cong (∃-cong λ _ → ∃-cong λ _ → ∃-cong λ _ → (∀-cong ext λ _ → ≡⇒↝ _ $ cong (_≡ _) $ lemma₀ _ _ _ _) ×-cong (∀-cong ext λ _ → ∀-cong ext λ _ → ≡⇒↝ _ $ cong (_≡ refl _) $ lemma₊ _ _ _ _ _))) ⟩ (∃ λ (f : (x : A) → P ∣ x ∣) → Erased ( ∃ λ (f≡g₀ : (x : A) → f x ≡ g ∣ x ∣) → ∃ λ (eq₀ : ∀ x → subst P (C.∣∣₊≡∣∣₀ x) (g C.∣ O.∣ x ∣ ∣₊) ≡ f x) → ∃ λ (eq₊ : ∀ n x → subst P (C.∣∣₊≡∣∣₊ x) (g C.∣ O.∣ x ∣ ∣₊) ≡ g C.∣ x ∣₊) → (∀ x → trans (sym (eq₀ x)) (dcong g (C.∣∣₊≡∣∣₀ x)) ≡ f≡g₀ x) × (∀ n (x : ∥ A ∥¹-out-^ (suc n)) → trans (sym (eq₊ n x)) (dcong g (C.∣∣₊≡∣∣₊ x)) ≡ refl _))) ↝⟨ (∃-cong λ _ → Erased-cong (∃-cong λ _ → ∃-cong λ eq₀ → ∃-cong λ eq₊ → (Eq.extensionality-isomorphism bad-ext F.∘ (∀-cong ext λ _ → Eq.≃-≡ (Eq.↔⇒≃ ≡-comm) F.∘ (≡⇒↝ _ $ trans ([trans≡]≡[≡trans-symʳ] _ _ _) $ cong (sym (eq₀ _) ≡_) $ sym $ sym-sym _))) ×-cong (Eq.extensionality-isomorphism bad-ext F.∘ (∀-cong ext λ _ → Eq.extensionality-isomorphism bad-ext F.∘ (∀-cong ext λ _ → Eq.≃-≡ (Eq.↔⇒≃ ≡-comm) F.∘ (≡⇒↝ _ $ trans ([trans≡]≡[≡trans-symʳ] _ _ _) $ cong (sym (eq₊ _ _) ≡_) $ sym $ sym-sym _)))))) ⟩ (∃ λ (f : (x : A) → P ∣ x ∣) → Erased ( ∃ λ (f≡g₀ : (x : A) → f x ≡ g ∣ x ∣) → ∃ λ (eq₀ : ∀ x → subst P (C.∣∣₊≡∣∣₀ x) (g C.∣ O.∣ x ∣ ∣₊) ≡ f x) → ∃ λ (eq₊ : ∀ n x → subst P (C.∣∣₊≡∣∣₊ x) (g C.∣ O.∣ x ∣ ∣₊) ≡ g C.∣ x ∣₊) → eq₀ ≡ (λ x → sym (trans (f≡g₀ x) (sym (dcong g (C.∣∣₊≡∣∣₀ x))))) × eq₊ ≡ (λ _ x → sym (trans (refl _) (sym (dcong g (C.∣∣₊≡∣∣₊ x))))))) ↔⟨ (∃-cong λ _ → Erased-cong (∃-cong λ _ → ∃-cong λ _ → (drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ singleton-contractible _) F.∘ ∃-comm)) ⟩ (∃ λ (f : (x : A) → P ∣ x ∣) → Erased ( ∃ λ (f≡g₀ : (x : A) → f x ≡ g ∣ x ∣) → ∃ λ (eq₀ : ∀ x → subst P (C.∣∣₊≡∣∣₀ x) (g C.∣ O.∣ x ∣ ∣₊) ≡ f x) → eq₀ ≡ (λ x → sym (trans (f≡g₀ x) (sym (dcong g (C.∣∣₊≡∣∣₀ x))))))) ↔⟨ (∃-cong λ _ → Erased-cong ( drop-⊤-right λ _ → _⇔_.to contractible⇔↔⊤ $ singleton-contractible _)) ⟩ (∃ λ (f : (x : A) → P ∣ x ∣) → Erased ((x : A) → f x ≡ g ∣ x ∣)) ↝⟨ (∃-cong λ _ → Erased-cong ( Eq.extensionality-isomorphism bad-ext)) ⟩□ (∃ λ (f : (x : A) → P ∣ x ∣) → Erased (f ≡ g ∘ ∣_∣)) □ where u⁻¹ = _≃_.from C.universal-property-Π @0 lemma₀ : ∀ _ _ _ _ → _ lemma₀ f eq₀ eq₊ x = subst (λ x → u⁻¹ (f , [ (λ _ → g ∘ C.∣_∣₊) , eq₀ , eq₊ ]) x ≡ g x) (C.∣∣₊≡∣∣₀ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩ trans (sym (dcong (u⁻¹ (f , [ (λ _ → g ∘ C.∣_∣₊) , eq₀ , eq₊ ])) (C.∣∣₊≡∣∣₀ x))) (trans (cong (subst P (C.∣∣₊≡∣∣₀ x)) (refl _)) (dcong g (C.∣∣₊≡∣∣₀ x))) ≡⟨ cong₂ (trans ∘ sym) C.elim-∣∣₊≡∣∣₀ (trans (cong (flip trans _) $ cong-refl _) $ trans-reflˡ _) ⟩∎ trans (sym (eq₀ x)) (dcong g (C.∣∣₊≡∣∣₀ x)) ∎ @0 lemma₊ : ∀ _ _ _ _ _ → _ lemma₊ f eq₀ eq₊ n x = subst (λ x → u⁻¹ (f , [ (λ _ → g ∘ C.∣_∣₊) , eq₀ , eq₊ ]) x ≡ g x) (C.∣∣₊≡∣∣₊ x) (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩ trans (sym (dcong (u⁻¹ (f , [ (λ _ → g ∘ C.∣_∣₊) , eq₀ , eq₊ ])) (C.∣∣₊≡∣∣₊ x))) (trans (cong (subst P (C.∣∣₊≡∣∣₊ x)) (refl _)) (dcong g (C.∣∣₊≡∣∣₊ x))) ≡⟨ cong₂ (trans ∘ sym) C.elim-∣∣₊≡∣∣₊ (trans (cong (flip trans _) $ cong-refl _) $ trans-reflˡ _) ⟩∎ trans (sym (eq₊ n x)) (dcong g (C.∣∣₊≡∣∣₊ x)) ∎
{ "alphanum_fraction": 0.2602912703, "avg_line_length": 56.7016706444, "ext": "agda", "hexsha": "0dc20ae47ce9c74f48365abedd0bbedd26d25625", "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/H-level/Truncation/Propositional/Non-recursive/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/H-level/Truncation/Propositional/Non-recursive/Erased.agda", "max_line_length": 146, "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/H-level/Truncation/Propositional/Non-recursive/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": 8593, "size": 23758 }
module Pi-.Properties where open import Data.Empty open import Data.Unit open import Data.Sum open import Data.Product open import Relation.Binary.Core open import Relation.Binary open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Data.Nat open import Data.Nat.Induction open import Data.Nat.Properties open import Function using (_∘_) open import Base open import Pi-.Syntax open import Pi-.Opsem open import Pi-.NoRepeat open import Pi-.Invariants open import Pi-.Eval open import Pi-.Interp -- Change the direction of the given state flip : State → State flip ⟨ c ∣ v ∣ κ ⟩▷ = ⟨ c ∣ v ∣ κ ⟩◁ flip [ c ∣ v ∣ κ ]▷ = [ c ∣ v ∣ κ ]◁ flip ⟨ c ∣ v ∣ κ ⟩◁ = ⟨ c ∣ v ∣ κ ⟩▷ flip [ c ∣ v ∣ κ ]◁ = [ c ∣ v ∣ κ ]▷ Rev : ∀ {st st'} → st ↦ st' → flip st' ↦ flip st Rev ↦⃗₁ = ↦⃖₁ Rev ↦⃗₂ = ↦⃖₂ Rev ↦⃗₃ = ↦⃖₃ Rev ↦⃗₄ = ↦⃖₄ Rev ↦⃗₅ = ↦⃖₅ Rev ↦⃗₆ = ↦⃖₆ Rev ↦⃗₇ = ↦⃖₇ Rev ↦⃗₈ = ↦⃖₈ Rev ↦⃗₉ = ↦⃖₉ Rev ↦⃗₁₀ = ↦⃖₁₀ Rev ↦⃗₁₁ = ↦⃖₁₁ Rev ↦⃗₁₂ = ↦⃖₁₂ Rev ↦⃖₁ = ↦⃗₁ Rev ↦⃖₂ = ↦⃗₂ Rev ↦⃖₃ = ↦⃗₃ Rev ↦⃖₄ = ↦⃗₄ Rev ↦⃖₅ = ↦⃗₅ Rev ↦⃖₆ = ↦⃗₆ Rev ↦⃖₇ = ↦⃗₇ Rev ↦⃖₈ = ↦⃗₈ Rev ↦⃖₉ = ↦⃗₉ Rev ↦⃖₁₀ = ↦⃗₁₀ Rev ↦⃖₁₁ = ↦⃗₁₁ Rev ↦⃖₁₂ = ↦⃗₁₂ Rev ↦η₁ = ↦η₂ Rev ↦η₂ = ↦η₁ Rev ↦ε₁ = ↦ε₂ Rev ↦ε₂ = ↦ε₁ Rev* : ∀ {st st'} → st ↦* st' → flip st' ↦* flip st Rev* ◾ = ◾ Rev* (r ∷ rs) = Rev* rs ++↦ (Rev r ∷ ◾) -- Helper functions inspect⊎ : ∀ {ℓ ℓ' ℓ''} {P : Set ℓ} {Q : Set ℓ'} {R : Set ℓ''} → (f : P → Q ⊎ R) → (p : P) → (∃[ q ] (inj₁ q ≡ f p)) ⊎ (∃[ r ] (inj₂ r ≡ f p)) inspect⊎ f p with f p ... | inj₁ q = inj₁ (q , refl) ... | inj₂ r = inj₂ (r , refl) toState : ∀ {A B} → (c : A ↔ B) → Val B A → State toState c (b ⃗) = [ c ∣ b ∣ ☐ ]▷ toState c (a ⃖) = ⟨ c ∣ a ∣ ☐ ⟩◁ is-stuck-toState : ∀ {A B} → (c : A ↔ B) → (v : Val B A) → is-stuck (toState c v) is-stuck-toState c (b ⃗) = λ () is-stuck-toState c (a ⃖) = λ () toState≡₁ : ∀ {A B b} {c : A ↔ B} {x : Val B A} → toState c x ≡ [ c ∣ b ∣ ☐ ]▷ → x ≡ b ⃗ toState≡₁ {x = x ⃗} refl = refl toState≡₂ : ∀ {A B a} {c : A ↔ B} {x : Val B A} → toState c x ≡ ⟨ c ∣ a ∣ ☐ ⟩◁ → x ≡ a ⃖ toState≡₂ {x = x ⃖} refl = refl eval-toState₁ : ∀ {A B a x} {c : A ↔ B} → ⟨ c ∣ a ∣ ☐ ⟩▷ ↦* (toState c x) → eval c (a ⃗) ≡ x eval-toState₁ {a = a} {b ⃗} {c} rs with inspect⊎ (run ⟨ c ∣ a ∣ ☐ ⟩▷) (λ ()) eval-toState₁ {a = a} {b ⃗} {c} rs | inj₁ ((a' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₁ {a = a} {b ⃗} {c} rs | inj₂ ((b' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | refl = subst (λ x → [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x ≡ b ⃗) eq refl eval-toState₁ {a = a} {a' ⃖} {c} rs with inspect⊎ (run ⟨ c ∣ a ∣ ☐ ⟩▷) (λ ()) eval-toState₁ {a = a} {a' ⃖} {c} rs | inj₁ ((a'' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | refl = subst (λ x → [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x ≡ a'' ⃖) eq refl eval-toState₁ {a = a} {a' ⃖} {c} rs | inj₂ ((b' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₂ : ∀ {A B b x} {c : A ↔ B} → [ c ∣ b ∣ ☐ ]◁ ↦* (toState c x) → eval c (b ⃖) ≡ x eval-toState₂ {b = b} {b' ⃗} {c} rs with inspect⊎ (run [ c ∣ b ∣ ☐ ]◁) (λ ()) eval-toState₂ {b = b} {b' ⃗} {c} rs | inj₁ ((a' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | () eval-toState₂ {b = b} {b' ⃗} {c} rs | inj₂ ((b'' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | refl = subst (λ x → [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x ≡ b'' ⃗) eq refl eval-toState₂ {b = b} {a ⃖} {c} rs with inspect⊎ (run [ c ∣ b ∣ ☐ ]◁) (λ ()) eval-toState₂ {b = b} {a ⃖} {c} rs | inj₁ ((a' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | refl = subst (λ x → [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x ≡ a' ⃖) eq refl eval-toState₂ {b = b} {a ⃖} {c} rs | inj₂ ((b'' , rs') , eq) with deterministic* rs rs' (λ ()) (λ ()) ... | () getₜᵣ⃗ : ∀ {A B} → (c : A ↔ B) → {v : ⟦ A ⟧} {v' : Val B A} → eval c (v ⃗) ≡ v' → ⟨ c ∣ v ∣ ☐ ⟩▷ ↦* toState c v' getₜᵣ⃗ c {v} {v'} eq with inspect⊎ (run ⟨ c ∣ v ∣ ☐ ⟩▷) (λ ()) getₜᵣ⃗ c {v} {v' ⃗} eq | inj₁ ((v'' , rs) , eq') with trans (subst (λ x → (v'' ⃖) ≡ [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) eq' refl) eq ... | () getₜᵣ⃗ c {v} {v' ⃖} eq | inj₁ ((v'' , rs) , eq') with trans (subst (λ x → (v'' ⃖) ≡ [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) eq' refl) eq ... | refl = rs getₜᵣ⃗ c {v} {v' ⃗} eq | inj₂ ((v'' , rs) , eq') with trans (subst (λ x → (v'' ⃗) ≡ [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) eq' refl) eq ... | refl = rs getₜᵣ⃗ c {v} {v' ⃖} eq | inj₂ ((v'' , rs) , eq') with trans (subst (λ x → (v'' ⃗) ≡ [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) eq' refl) eq ... | () getₜᵣ⃖ : ∀ {A B} → (c : A ↔ B) → {v : ⟦ B ⟧} {v' : Val B A} → eval c (v ⃖) ≡ v' → [ c ∣ v ∣ ☐ ]◁ ↦* toState c v' getₜᵣ⃖ c {v} {v'} eq with inspect⊎ (run [ c ∣ v ∣ ☐ ]◁) (λ ()) getₜᵣ⃖ c {v} {v' ⃗} eq | inj₁ ((v'' , rs) , eq') with trans (subst (λ x → (v'' ⃖) ≡ [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) eq' refl) eq ... | () getₜᵣ⃖ c {v} {v' ⃖} eq | inj₁ ((v'' , rs) , eq') with trans (subst (λ x → (v'' ⃖) ≡ [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) eq' refl) eq ... | refl = rs getₜᵣ⃖ c {v} {v' ⃗} eq | inj₂ ((v'' , rs) , eq') with trans (subst (λ x → (v'' ⃗) ≡ [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) eq' refl) eq ... | refl = rs getₜᵣ⃖ c {v} {v' ⃖} eq | inj₂ ((v'' , rs) , eq') with trans (subst (λ x → (v'' ⃗) ≡ [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) eq' refl) eq ... | () -- Forward evaluator is reversible evalisRev : ∀ {A B} → (c : A ↔ B) → (v : Val A B) → evalᵣₑᵥ c (eval c v) ≡ v evalisRev c (v ⃖) with inspect⊎ (run [ c ∣ v ∣ ☐ ]◁) (λ ()) evalisRev c (v ⃖) | inj₁ ((v' , rs) , eq) with inspect⊎ (run ⟨ c ∣ v' ∣ ☐ ⟩▷) (λ ()) evalisRev c (v ⃖) | inj₁ ((v' , rs) , eq) | inj₁ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | () evalisRev c (v ⃖) | inj₁ ((v' , rs) , eq) | inj₂ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | refl = subst (λ x → evalᵣₑᵥ c ([ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) ≡ (v ⃖)) eq (subst (λ x → [ _⃗ ∘ proj₁ , _⃖ ∘ proj₁ ]′ x ≡ (v ⃖)) eq' refl) evalisRev c (v ⃖) | inj₂ ((v' , rs) , eq) with inspect⊎ (run [ c ∣ v' ∣ ☐ ]◁) (λ ()) evalisRev c (v ⃖) | inj₂ ((v' , rs) , eq) | inj₁ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | () evalisRev c (v ⃖) | inj₂ ((v' , rs) , eq) | inj₂ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | refl = subst (λ x → evalᵣₑᵥ c ([ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) ≡ (v ⃖)) eq (subst (λ x → [ _⃗ ∘ proj₁ , _⃖ ∘ proj₁ ]′ x ≡ (v ⃖)) eq' refl) evalisRev c (v ⃗) with inspect⊎ (run ⟨ c ∣ v ∣ ☐ ⟩▷) (λ ()) evalisRev c (v ⃗) | inj₁ ((v' , rs) , eq) with inspect⊎ (run ⟨ c ∣ v' ∣ ☐ ⟩▷) (λ ()) evalisRev c (v ⃗) | inj₁ ((v' , rs) , eq) | inj₁ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | refl = subst (λ x → evalᵣₑᵥ c ([ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) ≡ (v ⃗)) eq (subst (λ x → [ _⃗ ∘ proj₁ , _⃖ ∘ proj₁ ]′ x ≡ (v ⃗)) eq' refl) evalisRev c (v ⃗) | inj₁ ((v' , rs) , eq) | inj₂ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | () evalisRev c (v ⃗) | inj₂ ((v' , rs) , eq) with inspect⊎ (run [ c ∣ v' ∣ ☐ ]◁) (λ ()) evalisRev c (v ⃗) | inj₂ ((v' , rs) , eq) | inj₁ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | refl = subst (λ x → evalᵣₑᵥ c ([ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x) ≡ (v ⃗)) eq (subst (λ x → [ _⃗ ∘ proj₁ , _⃖ ∘ proj₁ ]′ x ≡ (v ⃗)) eq' refl) evalisRev c (v ⃗) | inj₂ ((v' , rs) , eq) | inj₂ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | () -- Backward evaluator is reversible evalᵣₑᵥisRev : ∀ {A B} → (c : A ↔ B) → (v : Val B A) → eval c (evalᵣₑᵥ c v) ≡ v evalᵣₑᵥisRev c (v ⃖) with inspect⊎ (run ⟨ c ∣ v ∣ ☐ ⟩▷) (λ ()) evalᵣₑᵥisRev c (v ⃖) | inj₁ ((v' , rs) , eq) with inspect⊎ (run ⟨ c ∣ v' ∣ ☐ ⟩▷) (λ ()) evalᵣₑᵥisRev c (v ⃖) | inj₁ ((v' , rs) , eq) | inj₁ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | refl = subst (λ x → eval c ([ _⃗ ∘ proj₁ , _⃖ ∘ proj₁ ]′ x) ≡ (v ⃖)) eq (subst (λ x → [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x ≡ (v ⃖)) eq' refl) evalᵣₑᵥisRev c (v ⃖) | inj₁ ((v' , rs) , eq) | inj₂ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | () evalᵣₑᵥisRev c (v ⃖) | inj₂ ((v' , rs) , eq) with inspect⊎ (run [ c ∣ v' ∣ ☐ ]◁) (λ ()) evalᵣₑᵥisRev c (v ⃖) | inj₂ ((v' , rs) , eq) | inj₁ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | refl = subst (λ x → eval c ([ _⃗ ∘ proj₁ , _⃖ ∘ proj₁ ]′ x) ≡ (v ⃖)) eq (subst (λ x → [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x ≡ (v ⃖)) eq' refl) evalᵣₑᵥisRev c (v ⃖) | inj₂ ((v' , rs) , eq) | inj₂ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | () evalᵣₑᵥisRev c (v ⃗) with inspect⊎ (run [ c ∣ v ∣ ☐ ]◁) (λ ()) evalᵣₑᵥisRev c (v ⃗) | inj₁ ((v' , rs) , eq) with inspect⊎ (run ⟨ c ∣ v' ∣ ☐ ⟩▷) (λ ()) evalᵣₑᵥisRev c (v ⃗) | inj₁ ((v' , rs) , eq) | inj₁ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | () evalᵣₑᵥisRev c (v ⃗) | inj₁ ((v' , rs) , eq) | inj₂ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | refl = subst (λ x → eval c ([ _⃗ ∘ proj₁ , _⃖ ∘ proj₁ ]′ x) ≡ (v ⃗)) eq (subst (λ x → [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x ≡ (v ⃗)) eq' refl) evalᵣₑᵥisRev c (v ⃗) | inj₂ ((v' , rs) , eq) with inspect⊎ (run [ c ∣ v' ∣ ☐ ]◁) (λ ()) evalᵣₑᵥisRev c (v ⃗) | inj₂ ((v' , rs) , eq) | inj₁ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | () evalᵣₑᵥisRev c (v ⃗) | inj₂ ((v' , rs) , eq) | inj₂ ((_ , rs') , eq') with deterministic* (Rev* rs) rs' (λ ()) (λ ()) ... | refl = subst (λ x → eval c ([ _⃗ ∘ proj₁ , _⃖ ∘ proj₁ ]′ x) ≡ (v ⃗)) eq (subst (λ x → [ _⃖ ∘ proj₁ , _⃗ ∘ proj₁ ]′ x ≡ (v ⃗)) eq' refl) -- The abstract machine semantics is equivalent to the big-step semantics module eval≡interp where mutual eval≡interp : ∀ {A B} → (c : A ↔ B) → (v : Val A B) → eval c v ≡ interp c v eval≡interp unite₊l (inj₂ v ⃗) = refl eval≡interp unite₊l (v ⃖) = refl eval≡interp uniti₊l (v ⃗) = refl eval≡interp uniti₊l (inj₂ v ⃖) = refl eval≡interp swap₊ (inj₁ x ⃗) = refl eval≡interp swap₊ (inj₂ y ⃗) = refl eval≡interp swap₊ (inj₁ x ⃖) = refl eval≡interp swap₊ (inj₂ y ⃖) = refl eval≡interp assocl₊ (inj₁ x ⃗) = refl eval≡interp assocl₊ (inj₂ (inj₁ y) ⃗) = refl eval≡interp assocl₊ (inj₂ (inj₂ z) ⃗) = refl eval≡interp assocl₊ (inj₁ (inj₁ x) ⃖) = refl eval≡interp assocl₊ (inj₁ (inj₂ y) ⃖) = refl eval≡interp assocl₊ (inj₂ z ⃖) = refl eval≡interp assocr₊ (inj₁ (inj₁ x) ⃗) = refl eval≡interp assocr₊ (inj₁ (inj₂ y) ⃗) = refl eval≡interp assocr₊ (inj₂ z ⃗) = refl eval≡interp assocr₊ (inj₁ x ⃖) = refl eval≡interp assocr₊ (inj₂ (inj₁ y) ⃖) = refl eval≡interp assocr₊ (inj₂ (inj₂ z) ⃖) = refl eval≡interp unite⋆l ((tt , v) ⃗) = refl eval≡interp unite⋆l (v ⃖) = refl eval≡interp uniti⋆l (v ⃗) = refl eval≡interp uniti⋆l ((tt , v) ⃖) = refl eval≡interp swap⋆ ((x , y) ⃗) = refl eval≡interp swap⋆ ((y , x) ⃖) = refl eval≡interp assocl⋆ ((x , (y , z)) ⃗) = refl eval≡interp assocl⋆ (((x , y) , z) ⃖) = refl eval≡interp assocr⋆ (((x , y) , z) ⃗) = refl eval≡interp assocr⋆ ((x , (y , z)) ⃖) = refl eval≡interp absorbr (() ⃗) eval≡interp absorbr (() ⃖) eval≡interp factorzl (() ⃗) eval≡interp factorzl (() ⃖) eval≡interp dist ((inj₁ x , z) ⃗) = refl eval≡interp dist ((inj₂ y , z) ⃗) = refl eval≡interp dist (inj₁ (x , z) ⃖) = refl eval≡interp dist (inj₂ (y , z) ⃖) = refl eval≡interp factor (inj₁ (x , z) ⃗) = refl eval≡interp factor (inj₂ (y , z) ⃗) = refl eval≡interp factor ((inj₁ x , z) ⃖) = refl eval≡interp factor ((inj₂ y , z) ⃖) = refl eval≡interp id↔ (v ⃗) = refl eval≡interp id↔ (v ⃖) = refl eval≡interp (c₁ ⨾ c₂) (a ⃗) with interp c₁ (a ⃗) | inspect (interp c₁) (a ⃗) eval≡interp (c₁ ⨾ c₂) (a ⃗) | b ⃗ | [ eq ] = (proj₁ (loop (len↦ rs') b) rs' refl) where rs : ⟨ c₁ ⨾ c₂ ∣ a ∣ ☐ ⟩▷ ↦* toState (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (a ⃗)) rs = getₜᵣ⃗ (c₁ ⨾ c₂) refl rs' : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* toState (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (a ⃗)) rs' = proj₁ (deterministic*' (↦⃗₃ ∷ appendκ↦* ((getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (a ⃗)) eq))) refl (☐⨾ c₂ • ☐)) rs (is-stuck-toState _ _)) eval≡interp (c₁ ⨾ c₂) (a ⃗) | a' ⃖ | [ eq ] = eval-toState₁ rs where rs : ⟨ c₁ ⨾ c₂ ∣ a ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⨾ c₂ ∣ a' ∣ ☐ ⟩◁ rs = ↦⃗₃ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (a ⃗)) eq)) refl (☐⨾ c₂ • ☐) ++↦ ↦⃖₃ ∷ ◾ eval≡interp (c₁ ⨾ c₂) (c ⃖) with interp c₂ (c ⃖) | inspect (interp c₂) (c ⃖) eval≡interp (c₁ ⨾ c₂) (c ⃖) | b ⃖ | [ eq' ] = proj₂ (loop (len↦ rs') b) rs' refl where rs : [ c₁ ⨾ c₂ ∣ c ∣ ☐ ]◁ ↦* toState (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (c ⃖)) rs = getₜᵣ⃖ (c₁ ⨾ c₂) refl rs' : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* toState (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (c ⃖)) rs' = proj₁ (deterministic*' (↦⃖₁₀ ∷ appendκ↦* ((getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (c ⃖)) eq'))) refl (c₁ ⨾☐• ☐)) rs (is-stuck-toState _ _)) eval≡interp (c₁ ⨾ c₂) (c ⃖) | (c' ⃗) | [ eq ] = eval-toState₂ rs where rs : [ c₁ ⨾ c₂ ∣ c ∣ ☐ ]◁ ↦* [ c₁ ⨾ c₂ ∣ c' ∣ ☐ ]▷ rs = ↦⃖₁₀ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (c ⃖)) eq)) refl (c₁ ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃗) with interp c₁ (x ⃗) | inspect (interp c₁) (x ⃗) eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃗) | x' ⃗ | [ eq ] = eval-toState₁ rs where rs : ⟨ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ⟩▷ ↦* [ c₁ ⊕ c₂ ∣ inj₁ x' ∣ ☐ ]▷ rs = ↦⃗₄ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq)) refl (☐⊕ c₂ • ☐) ++↦ ↦⃗₁₁ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃗) | x' ⃖ | [ eq ] = eval-toState₁ rs where rs : ⟨ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₁ x' ∣ ☐ ⟩◁ rs = ↦⃗₄ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq)) refl (☐⊕ c₂ • ☐) ++↦ ↦⃖₄ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃗) with interp c₂ (y ⃗) | inspect (interp c₂) (y ⃗) eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃗) | y' ⃗ | [ eq ] = eval-toState₁ rs where rs : ⟨ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ⟩▷ ↦* [ c₁ ⊕ c₂ ∣ inj₂ y' ∣ ☐ ]▷ rs = ↦⃗₅ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (y ⃗)) eq)) refl (c₁ ⊕☐• ☐) ++↦ ↦⃗₁₂ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃗) | y' ⃖ | [ eq ] = eval-toState₁ rs where rs : ⟨ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₂ y' ∣ ☐ ⟩◁ rs = ↦⃗₅ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (y ⃗)) eq)) refl (c₁ ⊕☐• ☐) ++↦ ↦⃖₅ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃖) with interp c₁ (x ⃖) | inspect (interp c₁) (x ⃖) eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃖) | x' ⃗ | [ eq ] = eval-toState₂ rs where rs : [ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ]◁ ↦* [ c₁ ⊕ c₂ ∣ inj₁ x' ∣ ☐ ]▷ rs = ↦⃖₁₁ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (x ⃖)) eq)) refl (☐⊕ c₂ • ☐) ++↦ ↦⃗₁₁ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₁ x ⃖) | x' ⃖ | [ eq ] = eval-toState₂ rs where rs : [ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ]◁ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₁ x' ∣ ☐ ⟩◁ rs = ↦⃖₁₁ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (x ⃖)) eq)) refl (☐⊕ c₂ • ☐) ++↦ ↦⃖₄ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃖) with interp c₂ (y ⃖) | inspect (interp c₂) (y ⃖) eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃖) | y' ⃖ | [ eq ] = eval-toState₂ rs where rs : [ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ]◁ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₂ y' ∣ ☐ ⟩◁ rs = ↦⃖₁₂ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq)) refl (c₁ ⊕☐• ☐) ++↦ ↦⃖₅ ∷ ◾ eval≡interp (c₁ ⊕ c₂) (inj₂ y ⃖) | y' ⃗ | [ eq ] = eval-toState₂ rs where rs : [ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ]◁ ↦* [ c₁ ⊕ c₂ ∣ inj₂ y' ∣ ☐ ]▷ rs = ↦⃖₁₂ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq)) refl (c₁ ⊕☐• ☐) ++↦ ↦⃗₁₂ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) with interp c₁ (x ⃗) | inspect (interp c₁) (x ⃗) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) | x₁ ⃗ | [ eq₁ ] with interp c₂ (y ⃗) | inspect (interp c₂) (y ⃗) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) | x₁ ⃗ | [ eq₁ ] | y₁ ⃗ | [ eq₂ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ⟩▷ ↦* [ c₁ ⊗ c₂ ∣ (x₁ , y₁) ∣ ☐ ]▷ rs' = ↦⃗₆ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) refl (☐⊗[ c₂ , y ]• ☐) ++↦ ↦⃗₈ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (y ⃗)) eq₂)) refl ([ c₁ , x₁ ]⊗☐• ☐) ++↦ ↦⃗₉ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) | x₁ ⃗ | [ eq₁ ] | y₁ ⃖ | [ eq₂ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊗ c₂ ∣ (x , y₁) ∣ ☐ ⟩◁ rs' = ↦⃗₆ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) refl (☐⊗[ c₂ , y ]• ☐) ++↦ ↦⃗₈ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (y ⃗)) eq₂)) refl ([ c₁ , x₁ ]⊗☐• ☐) ++↦ ↦⃖₈ ∷ Rev* (appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) refl (☐⊗[ c₂ , y₁ ]• ☐)) ++↦ ↦⃖₆ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃗) | x₁ ⃖ | [ eq₁ ] = eval-toState₁ rs' where rs' : ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊗ c₂ ∣ (x₁ , y) ∣ ☐ ⟩◁ rs' = ↦⃗₆ ∷ appendκ↦* (getₜᵣ⃗ c₁ (trans (eval≡interp c₁ (x ⃗)) eq₁)) refl (☐⊗[ c₂ , y ]• ☐) ++↦ ↦⃖₆ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) with interp c₂ (y ⃖) | inspect (interp c₂) (y ⃖) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) | y₁ ⃗ | [ eq₂ ] = eval-toState₂ rs' where rs' : [ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ]◁ ↦* [ c₁ ⊗ c₂ ∣ (x , y₁) ∣ ☐ ]▷ rs' = ↦⃖₉ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₂)) refl ([ c₁ , x ]⊗☐• ☐) ++↦ ↦⃗₉ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) | y₁ ⃖ | [ eq₂ ] with interp c₁ (x ⃖) | inspect (interp c₁) (x ⃖) eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) | y₁ ⃖ | [ eq₂ ] | x₁ ⃗ | [ eq₁ ] = eval-toState₂ rs' where rs' : [ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ]◁ ↦* [ c₁ ⊗ c₂ ∣ (x₁ , y) ∣ ☐ ]▷ rs' = ↦⃖₉ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₂)) refl ([ c₁ , x ]⊗☐• ☐) ++↦ ↦⃖₈ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (x ⃖)) eq₁)) refl (☐⊗[ c₂ , y₁ ]• ☐) ++↦ ↦⃗₈ ∷ Rev* (appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₂)) refl ([ c₁ , x₁ ]⊗☐• ☐)) ++↦ ↦⃗₉ ∷ ◾ eval≡interp (c₁ ⊗ c₂) ((x , y) ⃖) | y₁ ⃖ | [ eq₂ ] | x₁ ⃖ | [ eq₁ ] = eval-toState₂ rs' where rs' : [ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ]◁ ↦* ⟨ c₁ ⊗ c₂ ∣ (x₁ , y₁) ∣ ☐ ⟩◁ rs' = ↦⃖₉ ∷ appendκ↦* (getₜᵣ⃖ c₂ (trans (eval≡interp c₂ (y ⃖)) eq₂)) refl ([ c₁ , x ]⊗☐• ☐) ++↦ ↦⃖₈ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (x ⃖)) eq₁)) refl (☐⊗[ c₂ , y₁ ]• ☐) ++↦ ↦⃖₆ ∷ ◾ eval≡interp η₊ (inj₁ x ⃖) = refl eval≡interp η₊ (inj₂ (- x) ⃖) = refl eval≡interp ε₊ (inj₁ x ⃗) = refl eval≡interp ε₊ (inj₂ (- x) ⃗) = refl private loop : ∀ {A B C x} {c₁ : A ↔ B} {c₂ : B ↔ C} (n : ℕ) → ∀ b → ((rs : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → x ≡ c₁ ⨾[ b ⃗]⨾ c₂) × ((rs : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → x ≡ c₁ ⨾[ b ⃖]⨾ c₂) loop {A} {B} {C} {x} {c₁} {c₂} = <′-rec (λ n → _) loop-rec where loop-rec : (n : ℕ) → (∀ m → m <′ n → _) → _ loop-rec n R b = loop₁ , loop₂ where loop₁ : (rs : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → x ≡ c₁ ⨾[ b ⃗]⨾ c₂ loop₁ rs refl with interp c₂ (b ⃗) | inspect (interp c₂) (b ⃗) loop₁ rs refl | c ⃗ | [ eq ] = toState≡₁ (deterministic* rs rsb→c (is-stuck-toState _ _) (λ ())) where rsb→c : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* [ c₁ ⨾ c₂ ∣ c ∣ ☐ ]▷ rsb→c = ↦⃗₇ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (b ⃗)) eq)) refl (c₁ ⨾☐• ☐) ++↦ (↦⃗₁₀ ∷ ◾) loop₁ rs refl | b' ⃖ | [ eq ] = proj₂ (R (len↦ rsb') le b') rsb' refl where rsb→b' : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* ⟨ c₂ ∣ b' ∣ c₁ ⨾☐• ☐ ⟩◁ rsb→b' = ↦⃗₇ ∷ appendκ↦* (getₜᵣ⃗ c₂ (trans (eval≡interp c₂ (b ⃗)) eq)) refl (c₁ ⨾☐• ☐) rsb' : ⟨ c₂ ∣ b' ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* toState (c₁ ⨾ c₂) x rsb' = proj₁ (deterministic*' rsb→b' rs (is-stuck-toState _ _)) req : len↦ rs ≡ len↦ rsb→b' + len↦ rsb' req = proj₂ (deterministic*' rsb→b' rs (is-stuck-toState _ _)) le : len↦ rsb' <′ len↦ rs le rewrite req = s≤′s (n≤′m+n _ _) loop₂ : (rs : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → x ≡ c₁ ⨾[ b ⃖]⨾ c₂ loop₂ rs refl with interp c₁ (b ⃖) | inspect (interp c₁) (b ⃖) loop₂ rs refl | a' ⃖ | [ eq ] = toState≡₂ (deterministic* rs rsb→a (is-stuck-toState _ _) (λ ())) where rsb→a : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* ⟨ c₁ ⨾ c₂ ∣ a' ∣ ☐ ⟩◁ rsb→a = ↦⃖₇ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (b ⃖)) eq)) refl (☐⨾ c₂ • ☐) ++↦ (↦⃖₃ ∷ ◾) loop₂ rs refl | b' ⃗ | [ eq ] = proj₁ (R (len↦ rsb') le b') rsb' refl where rsb→b' : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* [ c₁ ∣ b' ∣ ☐⨾ c₂ • ☐ ]▷ rsb→b' = ↦⃖₇ ∷ appendκ↦* (getₜᵣ⃖ c₁ (trans (eval≡interp c₁ (b ⃖)) eq)) refl (☐⨾ c₂ • ☐) rsb' : [ c₁ ∣ b' ∣ ☐⨾ c₂ • ☐ ]▷ ↦* toState (c₁ ⨾ c₂) x rsb' = proj₁ (deterministic*' rsb→b' rs (is-stuck-toState _ _)) req : len↦ rs ≡ len↦ rsb→b' + len↦ rsb' req = proj₂ (deterministic*' rsb→b' rs (is-stuck-toState _ _)) le : len↦ rsb' <′ len↦ rs le rewrite req = s≤′s (n≤′m+n _ _) open eval≡interp public module ∘-resp-≈ {A B C : 𝕌} {g i : B ↔ C} {f h : A ↔ B} (g~i : eval g ∼ eval i) (f~h : eval f ∼ eval h) where private loop : ∀ {x} (n : ℕ) → ∀ b → ((rs : [ f ∣ b ∣ ☐⨾ g • ☐ ]▷ ↦* toState (f ⨾ g) x) → len↦ rs ≡ n → [ h ∣ b ∣ ☐⨾ i • ☐ ]▷ ↦* toState (h ⨾ i) x) × ((rs : ⟨ g ∣ b ∣ f ⨾☐• ☐ ⟩◁ ↦* toState (f ⨾ g) x) → len↦ rs ≡ n → ⟨ i ∣ b ∣ h ⨾☐• ☐ ⟩◁ ↦* toState (h ⨾ i) x) loop {x} = <′-rec (λ n → _) loop-rec where loop-rec : (n : ℕ) → (∀ m → m <′ n → _) → _ loop-rec n R b = loop₁ , loop₂ where loop₁ : (rs : [ f ∣ b ∣ ☐⨾ g • ☐ ]▷ ↦* toState (f ⨾ g) x) → len↦ rs ≡ n → [ h ∣ b ∣ ☐⨾ i • ☐ ]▷ ↦* toState (h ⨾ i) x loop₁ rs refl with inspect⊎ (run ⟨ g ∣ b ∣ ☐ ⟩▷) (λ ()) loop₁ rs refl | inj₁ ((b₁ , rs₁) , eq₁) = ↦⃗₇ ∷ appendκ↦* rs₂ refl (h ⨾☐• ☐) ++↦ proj₂ (R (len↦ rs₁'') le b₁) rs₁'' refl where rs₁' : [ f ∣ b ∣ ☐⨾ g • ☐ ]▷ ↦* ⟨ g ∣ b₁ ∣ f ⨾☐• ☐ ⟩◁ rs₁' = ↦⃗₇ ∷ appendκ↦* rs₁ refl (f ⨾☐• ☐) rs₂ : ⟨ i ∣ b ∣ ☐ ⟩▷ ↦* ⟨ i ∣ b₁ ∣ ☐ ⟩◁ rs₂ = getₜᵣ⃗ i (trans (sym (g~i (b ⃗))) (eval-toState₁ rs₁)) rs₁'' : ⟨ g ∣ b₁ ∣ f ⨾☐• ☐ ⟩◁ ↦* toState (f ⨾ g) x rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) loop₁ rs refl | inj₂ ((c₁ , rs₁) , eq₁) = rs₂' where rs₁' : [ f ∣ b ∣ ☐⨾ g • ☐ ]▷ ↦* [ f ⨾ g ∣ c₁ ∣ ☐ ]▷ rs₁' = ↦⃗₇ ∷ appendκ↦* rs₁ refl (f ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ rs₂ : ⟨ i ∣ b ∣ ☐ ⟩▷ ↦* [ i ∣ c₁ ∣ ☐ ]▷ rs₂ = getₜᵣ⃗ i (trans (sym (g~i (b ⃗))) (eval-toState₁ rs₁)) xeq : x ≡ c₁ ⃗ xeq = toState≡₁ (sym (deterministic* rs₁' rs (λ ()) (is-stuck-toState _ _))) rs₂' : [ h ∣ b ∣ ☐⨾ i • ☐ ]▷ ↦* toState (h ⨾ i) x rs₂' rewrite xeq = ↦⃗₇ ∷ appendκ↦* rs₂ refl (h ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ loop₂ : (rs : ⟨ g ∣ b ∣ f ⨾☐• ☐ ⟩◁ ↦* toState (f ⨾ g) x) → len↦ rs ≡ n → ⟨ i ∣ b ∣ h ⨾☐• ☐ ⟩◁ ↦* toState (h ⨾ i) x loop₂ rs refl with inspect⊎ (run [ f ∣ b ∣ ☐ ]◁) (λ ()) loop₂ rs refl | inj₁ ((a₁ , rs₁) , eq₁) = rs₂' where rs₁' : ⟨ g ∣ b ∣ f ⨾☐• ☐ ⟩◁ ↦* ⟨ f ⨾ g ∣ a₁ ∣ ☐ ⟩◁ rs₁' = ↦⃖₇ ∷ appendκ↦* rs₁ refl (☐⨾ g • ☐) ++↦ ↦⃖₃ ∷ ◾ rs₂ : [ h ∣ b ∣ ☐ ]◁ ↦* ⟨ h ∣ a₁ ∣ ☐ ⟩◁ rs₂ = getₜᵣ⃖ h (trans (sym (f~h (b ⃖))) (eval-toState₂ rs₁)) xeq : x ≡ a₁ ⃖ xeq = toState≡₂ (sym (deterministic* rs₁' rs (λ ()) (is-stuck-toState _ _))) rs₂' : ⟨ i ∣ b ∣ h ⨾☐• ☐ ⟩◁ ↦* toState (h ⨾ i) x rs₂' rewrite xeq = ↦⃖₇ ∷ appendκ↦* rs₂ refl (☐⨾ i • ☐) ++↦ ↦⃖₃ ∷ ◾ loop₂ rs refl | inj₂ ((b₁ , rs₁) , eq₁) = (↦⃖₇ ∷ appendκ↦* rs₂ refl (☐⨾ i • ☐)) ++↦ proj₁ (R (len↦ rs₁'') le b₁) rs₁'' refl where rs₁' : ⟨ g ∣ b ∣ f ⨾☐• ☐ ⟩◁ ↦* [ f ∣ b₁ ∣ ☐⨾ g • ☐ ]▷ rs₁' = ↦⃖₇ ∷ appendκ↦* rs₁ refl (☐⨾ g • ☐) rs₂ : [ h ∣ b ∣ ☐ ]◁ ↦* [ h ∣ b₁ ∣ ☐ ]▷ rs₂ = getₜᵣ⃖ h (trans (sym (f~h (b ⃖))) (eval-toState₂ rs₁)) rs₁'' : [ f ∣ b₁ ∣ ☐⨾ g • ☐ ]▷ ↦* toState (f ⨾ g) x rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) ∘-resp-≈ : eval (f ⨾ g) ∼ eval (h ⨾ i) ∘-resp-≈ (a ⃗) with inspect⊎ (run ⟨ f ∣ a ∣ ☐ ⟩▷) (λ ()) ∘-resp-≈ (a ⃗) | inj₁ ((a₁ , rs₁) , eq₁) = lem where rs₁' : ⟨ f ⨾ g ∣ a ∣ ☐ ⟩▷ ↦* ⟨ f ⨾ g ∣ a₁ ∣ ☐ ⟩◁ rs₁' = ↦⃗₃ ∷ appendκ↦* rs₁ refl (☐⨾ g • ☐) ++↦ ↦⃖₃ ∷ ◾ eq~ : eval h (a ⃗) ≡ (a₁ ⃖) eq~ = trans (sym (f~h (a ⃗))) (eval-toState₁ rs₁) rs₂' : ⟨ h ⨾ i ∣ a ∣ ☐ ⟩▷ ↦* ⟨ h ⨾ i ∣ a₁ ∣ ☐ ⟩◁ rs₂' = ↦⃗₃ ∷ appendκ↦* (getₜᵣ⃗ h eq~) refl (☐⨾ i • ☐) ++↦ ↦⃖₃ ∷ ◾ lem : eval (f ⨾ g) (a ⃗) ≡ eval (h ⨾ i) (a ⃗) lem rewrite eval-toState₁ rs₁' | eval-toState₁ rs₂' = refl ∘-resp-≈ (a ⃗) | inj₂ ((b₁ , rs₁) , eq₁) = sym (eval-toState₁ rs₂'') where rs : ⟨ f ⨾ g ∣ a ∣ ☐ ⟩▷ ↦* toState (f ⨾ g) (eval (f ⨾ g) (a ⃗)) rs = getₜᵣ⃗ (f ⨾ g) refl rs₁' : ⟨ f ⨾ g ∣ a ∣ ☐ ⟩▷ ↦* [ f ∣ b₁ ∣ ☐⨾ g • ☐ ]▷ rs₁' = ↦⃗₃ ∷ appendκ↦* rs₁ refl (☐⨾ g • ☐) rs₁'' : [ f ∣ b₁ ∣ ☐⨾ g • ☐ ]▷ ↦* toState (f ⨾ g) (eval (f ⨾ g) (a ⃗)) rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) eq~ : eval h (a ⃗) ≡ (b₁ ⃗) eq~ = trans (sym (f~h (a ⃗))) (eval-toState₁ rs₁) rs₂' : ⟨ h ⨾ i ∣ a ∣ ☐ ⟩▷ ↦* [ h ∣ b₁ ∣ ☐⨾ i • ☐ ]▷ rs₂' = ↦⃗₃ ∷ appendκ↦* (getₜᵣ⃗ h eq~) refl (☐⨾ i • ☐) rs₂'' : ⟨ h ⨾ i ∣ a ∣ ☐ ⟩▷ ↦* toState (h ⨾ i) (eval (f ⨾ g) (a ⃗)) rs₂'' = rs₂' ++↦ proj₁ (loop (len↦ rs₁'') b₁) rs₁'' refl ∘-resp-≈ (c ⃖) with inspect⊎ (run [ g ∣ c ∣ ☐ ]◁) (λ ()) ∘-resp-≈ (c ⃖) | inj₁ ((b₁ , rs₁) , eq₁) = sym (eval-toState₂ rs₂'') where rs : [ f ⨾ g ∣ c ∣ ☐ ]◁ ↦* toState (f ⨾ g) (eval (f ⨾ g) (c ⃖)) rs = getₜᵣ⃖ (f ⨾ g) refl rs₁' : [ f ⨾ g ∣ c ∣ ☐ ]◁ ↦* ⟨ g ∣ b₁ ∣ f ⨾☐• ☐ ⟩◁ rs₁' = ↦⃖₁₀ ∷ appendκ↦* rs₁ refl (f ⨾☐• ☐) rs₁'' : ⟨ g ∣ b₁ ∣ f ⨾☐• ☐ ⟩◁ ↦* toState (f ⨾ g) (eval (f ⨾ g) (c ⃖)) rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) eq~ : eval i (c ⃖) ≡ (b₁ ⃖) eq~ = trans (sym (g~i (c ⃖))) (eval-toState₂ rs₁) rs₂' : [ h ⨾ i ∣ c ∣ ☐ ]◁ ↦* ⟨ i ∣ b₁ ∣ h ⨾☐• ☐ ⟩◁ rs₂' = ↦⃖₁₀ ∷ appendκ↦* (getₜᵣ⃖ i eq~) refl (h ⨾☐• ☐) rs₂'' : [ h ⨾ i ∣ c ∣ ☐ ]◁ ↦* toState (h ⨾ i) (eval (f ⨾ g) (c ⃖)) rs₂'' = rs₂' ++↦ proj₂ (loop (len↦ rs₁'') b₁) rs₁'' refl ∘-resp-≈ (c ⃖) | inj₂ ((c₁ , rs₁) , eq₁) = lem where rs₁' : [ f ⨾ g ∣ c ∣ ☐ ]◁ ↦* [ f ⨾ g ∣ c₁ ∣ ☐ ]▷ rs₁' = ↦⃖₁₀ ∷ appendκ↦* rs₁ refl (f ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ eq~ : eval i (c ⃖) ≡ (c₁ ⃗) eq~ = trans (sym (g~i (c ⃖))) (eval-toState₂ rs₁) rs₂' : [ h ⨾ i ∣ c ∣ ☐ ]◁ ↦* [ h ⨾ i ∣ c₁ ∣ ☐ ]▷ rs₂' = ↦⃖₁₀ ∷ appendκ↦* (getₜᵣ⃖ i eq~) refl (h ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ lem : eval (f ⨾ g) (c ⃖) ≡ eval (h ⨾ i) (c ⃖) lem rewrite eval-toState₂ rs₁' | eval-toState₂ rs₂' = refl open ∘-resp-≈ public module ∘-resp-≈ᵢ {A B C : 𝕌} {g i : B ↔ C} {f h : A ↔ B} (g~i : interp g ∼ interp i) (f~h : interp f ∼ interp h) where ∘-resp-≈ᵢ : interp (f ⨾ g) ∼ interp (h ⨾ i) ∘-resp-≈ᵢ x = trans (sym (eval≡interp (f ⨾ g) x)) (trans (∘-resp-≈ (λ z → trans (eval≡interp g z) (trans (g~i z) (sym (eval≡interp i z)))) (λ z → trans (eval≡interp f z) (trans (f~h z) (sym (eval≡interp h z)))) x) (eval≡interp (h ⨾ i) x)) open ∘-resp-≈ᵢ public module assoc {A B C D : 𝕌} {f : A ↔ B} {g : B ↔ C} {h : C ↔ D} where private loop : ∀ {x} (n : ℕ) → (∀ b → ((rs : [ f ∣ b ∣ ☐⨾ g ⨾ h • ☐ ]▷ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → [ f ∣ b ∣ ☐⨾ g • ☐⨾ h • ☐ ]▷ ↦* toState ((f ⨾ g) ⨾ h) x) × ((rs : ⟨ g ∣ b ∣ ☐⨾ h • (f ⨾☐• ☐) ⟩◁ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → ⟨ g ∣ b ∣ f ⨾☐• (☐⨾ h • ☐) ⟩◁ ↦* toState ((f ⨾ g) ⨾ h) x)) × (∀ c → ((rs : [ g ∣ c ∣ ☐⨾ h • (f ⨾☐• ☐) ]▷ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → [ g ∣ c ∣ f ⨾☐• (☐⨾ h • ☐) ]▷ ↦* toState ((f ⨾ g) ⨾ h) x) × ((rs : ⟨ h ∣ c ∣ g ⨾☐• (f ⨾☐• ☐) ⟩◁ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → ⟨ h ∣ c ∣ f ⨾ g ⨾☐• ☐ ⟩◁ ↦* toState ((f ⨾ g) ⨾ h) x)) loop {x} = <′-rec (λ n → _) loop-rec where loop-rec : (n : ℕ) → (∀ m → m <′ n → _) → _ loop-rec n R = loop₁ , loop₂ where loop₁ : ∀ b → ((rs : [ f ∣ b ∣ ☐⨾ g ⨾ h • ☐ ]▷ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → [ f ∣ b ∣ ☐⨾ g • ☐⨾ h • ☐ ]▷ ↦* toState ((f ⨾ g) ⨾ h) x) × ((rs : ⟨ g ∣ b ∣ ☐⨾ h • (f ⨾☐• ☐) ⟩◁ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → ⟨ g ∣ b ∣ f ⨾☐• (☐⨾ h • ☐) ⟩◁ ↦* toState ((f ⨾ g) ⨾ h) x) loop₁ b = loop⃗ , loop⃖ where loop⃗ : (rs : [ f ∣ b ∣ ☐⨾ g ⨾ h • ☐ ]▷ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → [ f ∣ b ∣ ☐⨾ g • ☐⨾ h • ☐ ]▷ ↦* toState ((f ⨾ g) ⨾ h) x loop⃗ rs refl with inspect⊎ (run ⟨ g ∣ b ∣ ☐ ⟩▷) (λ ()) loop⃗ rs refl | inj₁ ((b' , rsb) , _) = rs₂' ++↦ proj₂ (proj₁ (R (len↦ rs₁'') le) b') rs₁'' refl where rs₁' : [ f ∣ b ∣ ☐⨾ g ⨾ h • ☐ ]▷ ↦* ⟨ g ∣ b' ∣ ☐⨾ h • (f ⨾☐• ☐) ⟩◁ rs₁' = (↦⃗₇ ∷ ↦⃗₃ ∷ ◾) ++↦ appendκ↦* rsb refl (☐⨾ h • (f ⨾☐• ☐)) rs₁'' : ⟨ g ∣ b' ∣ ☐⨾ h • (f ⨾☐• ☐) ⟩◁ ↦* toState (f ⨾ (g ⨾ h)) x rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : [ f ∣ b ∣ ☐⨾ g • ☐⨾ h • ☐ ]▷ ↦* ⟨ g ∣ b' ∣ f ⨾☐• (☐⨾ h • ☐) ⟩◁ rs₂' = ↦⃗₇ ∷ appendκ↦* rsb refl (f ⨾☐• (☐⨾ h • ☐)) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) loop⃗ rs refl | inj₂ ((c , rsb) , _) = rs₂' ++↦ proj₁ (proj₂ (R (len↦ rs₁'') le) c) rs₁'' refl where rs₁' : [ f ∣ b ∣ ☐⨾ g ⨾ h • ☐ ]▷ ↦* [ g ∣ c ∣ ☐⨾ h • (f ⨾☐• ☐) ]▷ rs₁' = (↦⃗₇ ∷ ↦⃗₃ ∷ ◾) ++↦ appendκ↦* rsb refl (☐⨾ h • (f ⨾☐• ☐)) rs₁'' : [ g ∣ c ∣ ☐⨾ h • (f ⨾☐• ☐) ]▷ ↦* toState (f ⨾ (g ⨾ h)) x rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : [ f ∣ b ∣ ☐⨾ g • ☐⨾ h • ☐ ]▷ ↦* [ g ∣ c ∣ f ⨾☐• (☐⨾ h • ☐) ]▷ rs₂' = ↦⃗₇ ∷ appendκ↦* rsb refl (f ⨾☐• (☐⨾ h • ☐)) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) loop⃖ : (rs : ⟨ g ∣ b ∣ ☐⨾ h • (f ⨾☐• ☐) ⟩◁ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → ⟨ g ∣ b ∣ f ⨾☐• (☐⨾ h • ☐) ⟩◁ ↦* toState ((f ⨾ g) ⨾ h) x loop⃖ rs refl with inspect⊎ (run [ f ∣ b ∣ ☐ ]◁) (λ ()) loop⃖ rs refl | inj₁ ((a , rsb) , eq) = lem where rs₁' : ⟨ g ∣ b ∣ ☐⨾ h • (f ⨾☐• ☐) ⟩◁ ↦* ⟨ f ⨾ (g ⨾ h) ∣ a ∣ ☐ ⟩◁ rs₁' = (↦⃖₃ ∷ ↦⃖₇ ∷ ◾) ++↦ appendκ↦* rsb refl (☐⨾ g ⨾ h • ☐) ++↦ ↦⃖₃ ∷ ◾ xeq : x ≡ a ⃖ xeq = toState≡₂ (sym (deterministic* rs₁' rs (λ ()) (is-stuck-toState _ _))) lem : ⟨ g ∣ b ∣ f ⨾☐• (☐⨾ h • ☐) ⟩◁ ↦* toState ((f ⨾ g) ⨾ h) x lem rewrite xeq = (↦⃖₇ ∷ ◾) ++↦ appendκ↦* rsb refl (☐⨾ g • ☐⨾ h • ☐) ++↦ ↦⃖₃ ∷ ↦⃖₃ ∷ ◾ loop⃖ rs refl | inj₂ ((b' , rsb) , eq) = ↦⃖₇ ∷ rs₂' ++↦ proj₁ (proj₁ (R (len↦ rs₁'') le) b') rs₁'' refl where rs₁' : ⟨ g ∣ b ∣ ☐⨾ h • (f ⨾☐• ☐) ⟩◁ ↦* [ f ∣ b' ∣ ☐⨾ g ⨾ h • ☐ ]▷ rs₁' = (↦⃖₃ ∷ ↦⃖₇ ∷ ◾) ++↦ appendκ↦* rsb refl (☐⨾ g ⨾ h • ☐) rs₁'' : [ f ∣ b' ∣ ☐⨾ g ⨾ h • ☐ ]▷ ↦* (toState (f ⨾ g ⨾ h) x) rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : [ f ∣ b ∣ ☐⨾ g • ☐⨾ h • ☐ ]◁ ↦* [ f ∣ b' ∣ ☐⨾ g • (☐⨾ h • ☐) ]▷ rs₂' = appendκ↦* rsb refl (☐⨾ g • ☐⨾ h • ☐) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) loop₂ : ∀ c → ((rs : [ g ∣ c ∣ ☐⨾ h • (f ⨾☐• ☐) ]▷ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → [ g ∣ c ∣ f ⨾☐• (☐⨾ h • ☐) ]▷ ↦* toState ((f ⨾ g) ⨾ h) x) × ((rs : ⟨ h ∣ c ∣ g ⨾☐• (f ⨾☐• ☐) ⟩◁ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → ⟨ h ∣ c ∣ f ⨾ g ⨾☐• ☐ ⟩◁ ↦* toState ((f ⨾ g) ⨾ h) x) loop₂ c = loop⃗ , loop⃖ where loop⃗ : (rs : [ g ∣ c ∣ ☐⨾ h • (f ⨾☐• ☐) ]▷ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → [ g ∣ c ∣ f ⨾☐• (☐⨾ h • ☐) ]▷ ↦* toState ((f ⨾ g) ⨾ h) x loop⃗ rs refl with inspect⊎ (run ⟨ h ∣ c ∣ ☐ ⟩▷) (λ ()) loop⃗ rs refl | inj₁ ((c' , rsc) , eq) = rs₂' ++↦ proj₂ (proj₂ (R (len↦ rs₁'') le) c') rs₁'' refl where rs₁' : [ g ∣ c ∣ ☐⨾ h • (f ⨾☐• ☐) ]▷ ↦* ⟨ h ∣ c' ∣ g ⨾☐• (f ⨾☐• ☐) ⟩◁ rs₁' = ↦⃗₇ ∷ appendκ↦* rsc refl (g ⨾☐• (f ⨾☐• ☐)) rs₁'' : ⟨ h ∣ c' ∣ g ⨾☐• (f ⨾☐• ☐) ⟩◁ ↦* (toState (f ⨾ g ⨾ h) x) rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : [ g ∣ c ∣ f ⨾☐• (☐⨾ h • ☐) ]▷ ↦* ⟨ h ∣ c' ∣ f ⨾ g ⨾☐• ☐ ⟩◁ rs₂' = (↦⃗₁₀ ∷ ↦⃗₇ ∷ ◾) ++↦ appendκ↦* rsc refl (f ⨾ g ⨾☐• ☐) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) loop⃗ rs refl | inj₂ ((d , rsc) , eq) = lem where rs₁' : [ g ∣ c ∣ ☐⨾ h • (f ⨾☐• ☐) ]▷ ↦* [ f ⨾ g ⨾ h ∣ d ∣ ☐ ]▷ rs₁' = ↦⃗₇ ∷ appendκ↦* rsc refl (g ⨾☐• (f ⨾☐• ☐)) ++↦ ↦⃗₁₀ ∷ ↦⃗₁₀ ∷ ◾ xeq : x ≡ d ⃗ xeq = toState≡₁ (sym (deterministic* rs₁' rs (λ ()) (is-stuck-toState _ _))) lem : [ g ∣ c ∣ f ⨾☐• (☐⨾ h • ☐) ]▷ ↦* toState ((f ⨾ g) ⨾ h) x lem rewrite xeq = (↦⃗₁₀ ∷ ↦⃗₇ ∷ ◾) ++↦ appendκ↦* rsc refl (f ⨾ g ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ loop⃖ : (rs : ⟨ h ∣ c ∣ g ⨾☐• (f ⨾☐• ☐) ⟩◁ ↦* toState (f ⨾ (g ⨾ h)) x) → len↦ rs ≡ n → ⟨ h ∣ c ∣ f ⨾ g ⨾☐• ☐ ⟩◁ ↦* toState ((f ⨾ g) ⨾ h) x loop⃖ rs refl with inspect⊎ (run [ g ∣ c ∣ ☐ ]◁) (λ ()) loop⃖ rs refl | inj₁ ((b , rsc) , eq) = rs₂' ++↦ proj₂ (proj₁ (R (len↦ rs₁'') le) b) rs₁'' refl where rs₁' : ⟨ h ∣ c ∣ g ⨾☐• (f ⨾☐• ☐) ⟩◁ ↦* ⟨ g ∣ b ∣ ☐⨾ h • (f ⨾☐• ☐) ⟩◁ rs₁' = ↦⃖₇ ∷ appendκ↦* rsc refl (☐⨾ h • (f ⨾☐• ☐)) rs₁'' : ⟨ g ∣ b ∣ ☐⨾ h • (f ⨾☐• ☐) ⟩◁ ↦* (toState (f ⨾ g ⨾ h) x) rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : ⟨ h ∣ c ∣ f ⨾ g ⨾☐• ☐ ⟩◁ ↦* ⟨ g ∣ b ∣ f ⨾☐• (☐⨾ h • ☐) ⟩◁ rs₂' = (↦⃖₇ ∷ ↦⃖₁₀ ∷ ◾) ++↦ appendκ↦* rsc refl (f ⨾☐• (☐⨾ h • ☐)) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) loop⃖ rs refl | inj₂ ((c' , rsc) , eq) = rs₂' ++↦ proj₁ (proj₂ (R (len↦ rs₁'') le) c') rs₁'' refl where rs₁' : ⟨ h ∣ c ∣ g ⨾☐• (f ⨾☐• ☐) ⟩◁ ↦* [ g ∣ c' ∣ ☐⨾ h • (f ⨾☐• ☐) ]▷ rs₁' = ↦⃖₇ ∷ appendκ↦* rsc refl (☐⨾ h • (f ⨾☐• ☐)) rs₁'' : [ g ∣ c' ∣ ☐⨾ h • (f ⨾☐• ☐) ]▷ ↦* (toState (f ⨾ g ⨾ h) x) rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : ⟨ h ∣ c ∣ f ⨾ g ⨾☐• ☐ ⟩◁ ↦* [ g ∣ c' ∣ f ⨾☐• (☐⨾ h • ☐) ]▷ rs₂' = (↦⃖₇ ∷ ↦⃖₁₀ ∷ ◾) ++↦ appendκ↦* rsc refl (f ⨾☐• (☐⨾ h • ☐)) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) assoc : eval (f ⨾ g ⨾ h) ∼ eval ((f ⨾ g) ⨾ h) assoc (a ⃗) with inspect⊎ (run ⟨ f ∣ a ∣ ☐ ⟩▷) (λ ()) assoc (a ⃗) | inj₁ ((a₁ , rs₁) , eq₁) = lem where rs₁' : ⟨ f ⨾ (g ⨾ h) ∣ a ∣ ☐ ⟩▷ ↦* ⟨ f ⨾ (g ⨾ h) ∣ a₁ ∣ ☐ ⟩◁ rs₁' = ↦⃗₃ ∷ appendκ↦* rs₁ refl (☐⨾ g ⨾ h • ☐) ++↦ ↦⃖₃ ∷ ◾ rs₂' : ⟨ (f ⨾ g) ⨾ h ∣ a ∣ ☐ ⟩▷ ↦* ⟨ (f ⨾ g) ⨾ h ∣ a₁ ∣ ☐ ⟩◁ rs₂' = (↦⃗₃ ∷ ↦⃗₃ ∷ ◾) ++↦ appendκ↦* rs₁ refl (☐⨾ g • ☐⨾ h • ☐) ++↦ ↦⃖₃ ∷ ↦⃖₃ ∷ ◾ lem : eval (f ⨾ g ⨾ h) (a ⃗) ≡ eval ((f ⨾ g) ⨾ h) (a ⃗) lem rewrite eval-toState₁ rs₁' | eval-toState₁ rs₂' = refl assoc (a ⃗) | inj₂ ((b₁ , rs₁) , eq₁) = sym (eval-toState₁ rs₂'') where rs : ⟨ f ⨾ (g ⨾ h) ∣ a ∣ ☐ ⟩▷ ↦* toState (f ⨾ g ⨾ h) (eval (f ⨾ g ⨾ h) (a ⃗)) rs = getₜᵣ⃗ (f ⨾ g ⨾ h) refl rs₁' : ⟨ f ⨾ (g ⨾ h) ∣ a ∣ ☐ ⟩▷ ↦* [ f ∣ b₁ ∣ ☐⨾ g ⨾ h • ☐ ]▷ rs₁' = ↦⃗₃ ∷ appendκ↦* rs₁ refl (☐⨾ g ⨾ h • ☐) rs₁'' : [ f ∣ b₁ ∣ ☐⨾ g ⨾ h • ☐ ]▷ ↦* toState (f ⨾ g ⨾ h) (eval (f ⨾ g ⨾ h) (a ⃗)) rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : ⟨ (f ⨾ g) ⨾ h ∣ a ∣ ☐ ⟩▷ ↦* [ f ∣ b₁ ∣ ☐⨾ g • ☐⨾ h • ☐ ]▷ rs₂' = (↦⃗₃ ∷ ↦⃗₃ ∷ ◾) ++↦ appendκ↦* rs₁ refl (☐⨾ g • ☐⨾ h • ☐) rs₂'' : ⟨ (f ⨾ g) ⨾ h ∣ a ∣ ☐ ⟩▷ ↦* toState ((f ⨾ g) ⨾ h) (eval (f ⨾ g ⨾ h) (a ⃗)) rs₂'' = rs₂' ++↦ proj₁ ((proj₁ (loop (len↦ rs₁''))) b₁) rs₁'' refl assoc (d ⃖) with inspect⊎ (run [ h ∣ d ∣ ☐ ]◁) (λ ()) assoc (d ⃖) | inj₁ ((c₁ , rs₁) , eq₁) = sym (eval-toState₂ rs₂'') where rs : [ f ⨾ (g ⨾ h) ∣ d ∣ ☐ ]◁ ↦* toState (f ⨾ g ⨾ h) (eval (f ⨾ g ⨾ h) (d ⃖)) rs = getₜᵣ⃖ (f ⨾ g ⨾ h) refl rs₁' : [ f ⨾ (g ⨾ h) ∣ d ∣ ☐ ]◁ ↦* ⟨ h ∣ c₁ ∣ g ⨾☐• (f ⨾☐• ☐) ⟩◁ rs₁' = (↦⃖₁₀ ∷ ↦⃖₁₀ ∷ ◾) ++↦ appendκ↦* rs₁ refl (g ⨾☐• (f ⨾☐• ☐)) rs₁'' : ⟨ h ∣ c₁ ∣ g ⨾☐• (f ⨾☐• ☐) ⟩◁ ↦* toState (f ⨾ g ⨾ h) (eval (f ⨾ g ⨾ h) (d ⃖)) rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : [ (f ⨾ g) ⨾ h ∣ d ∣ ☐ ]◁ ↦* ⟨ h ∣ c₁ ∣ f ⨾ g ⨾☐• ☐ ⟩◁ rs₂' = (↦⃖₁₀ ∷ ◾) ++↦ appendκ↦* rs₁ refl ((f ⨾ g) ⨾☐• ☐) rs₂'' : [ (f ⨾ g) ⨾ h ∣ d ∣ ☐ ]◁ ↦* toState ((f ⨾ g) ⨾ h) (eval (f ⨾ g ⨾ h) (d ⃖)) rs₂'' = rs₂' ++↦ proj₂ ((proj₂ (loop (len↦ rs₁''))) c₁) rs₁'' refl assoc (d ⃖) | inj₂ ((d₁ , rs₁) , eq₁) = lem where rs₁' : [ f ⨾ (g ⨾ h) ∣ d ∣ ☐ ]◁ ↦* [ f ⨾ (g ⨾ h) ∣ d₁ ∣ ☐ ]▷ rs₁' = (↦⃖₁₀ ∷ ↦⃖₁₀ ∷ ◾) ++↦ appendκ↦* rs₁ refl (g ⨾☐• (f ⨾☐• ☐)) ++↦ ↦⃗₁₀ ∷ ↦⃗₁₀ ∷ ◾ rs₂' : [ (f ⨾ g) ⨾ h ∣ d ∣ ☐ ]◁ ↦* [ (f ⨾ g) ⨾ h ∣ d₁ ∣ ☐ ]▷ rs₂' = (↦⃖₁₀ ∷ ◾) ++↦ appendκ↦* rs₁ refl ((f ⨾ g) ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ lem : eval (f ⨾ g ⨾ h) (d ⃖) ≡ eval ((f ⨾ g) ⨾ h) (d ⃖) lem rewrite eval-toState₂ rs₁' | eval-toState₂ rs₂' = refl open assoc public module homomorphism {A₁ B₁ A₂ B₂ A₃ B₃} {f : A₁ ↔ A₂} {g : B₁ ↔ B₂} {h : A₂ ↔ A₃} {i : B₂ ↔ B₃} where private P₁ : ∀ {x} ℕ → Set _ P₁ {x} n = ∀ a₂ → ((rs : [ f ∣ a₂ ∣ ☐⨾ h • (☐⊕ g ⨾ i • ☐) ]▷ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x) → len↦ rs ≡ n → [ f ∣ a₂ ∣ ☐⊕ g • ☐⨾ h ⊕ i • ☐ ]▷ ↦* toState (f ⊕ g ⨾ h ⊕ i) x) × ((rs : ⟨ h ∣ a₂ ∣ f ⨾☐• (☐⊕ (g ⨾ i) • ☐) ⟩◁ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x) → len↦ rs ≡ n → ⟨ h ∣ a₂ ∣ ☐⊕ i • (f ⊕ g ⨾☐• ☐) ⟩◁ ↦* toState (f ⊕ g ⨾ h ⊕ i) x) P₂ : ∀ {x} ℕ → Set _ P₂ {x} n = ∀ b₂ → ((rs : [ g ∣ b₂ ∣ ☐⨾ i • (f ⨾ h ⊕☐• ☐) ]▷ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x) → len↦ rs ≡ n → [ g ∣ b₂ ∣ f ⊕☐• (☐⨾ h ⊕ i • ☐) ]▷ ↦* toState (f ⊕ g ⨾ h ⊕ i) x) × ((rs : ⟨ i ∣ b₂ ∣ g ⨾☐• (f ⨾ h ⊕☐• ☐) ⟩◁ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x) → len↦ rs ≡ n → ⟨ i ∣ b₂ ∣ h ⊕☐• (f ⊕ g ⨾☐• ☐) ⟩◁ ↦* toState (f ⊕ g ⨾ h ⊕ i) x) P : ∀ {x} ℕ → Set _ P {x} n = P₁ {x} n × P₂ {x} n loop : ∀ {x} (n : ℕ) → P {x} n loop {x} = <′-rec (λ n → P n) loop-rec where loop-rec : (n : ℕ) → (∀ m → m <′ n → P m) → P n loop-rec n R = loop₁ , loop₂ where loop₁ : P₁ n loop₁ a₂ = loop⃗ , loop⃖ where loop⃗ : (rs : [ f ∣ a₂ ∣ ☐⨾ h • (☐⊕ g ⨾ i • ☐) ]▷ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x) → len↦ rs ≡ n → [ f ∣ a₂ ∣ ☐⊕ g • ☐⨾ h ⊕ i • ☐ ]▷ ↦* toState (f ⊕ g ⨾ h ⊕ i) x loop⃗ rs refl with inspect⊎ (run ⟨ h ∣ a₂ ∣ ☐ ⟩▷) (λ ()) loop⃗ rs refl | inj₁ ((a₂' , rsa) , _) = rs₂' ++↦ proj₂ (proj₁ (R (len↦ rs₁'') le) a₂') rs₁'' refl where rs₁' : [ f ∣ a₂ ∣ ☐⨾ h • (☐⊕ g ⨾ i • ☐) ]▷ ↦* ⟨ h ∣ a₂' ∣ f ⨾☐• (☐⊕ (g ⨾ i) • ☐) ⟩◁ rs₁' = ↦⃗₇ ∷ appendκ↦* rsa refl (f ⨾☐• (☐⊕ g ⨾ i • ☐)) rs₁'' : ⟨ h ∣ a₂' ∣ f ⨾☐• (☐⊕ (g ⨾ i) • ☐) ⟩◁ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : [ f ∣ a₂ ∣ ☐⊕ g • ☐⨾ h ⊕ i • ☐ ]▷ ↦* ⟨ h ∣ a₂' ∣ ☐⊕ i • (f ⊕ g ⨾☐• ☐) ⟩◁ rs₂' = (↦⃗₁₁ ∷ ↦⃗₇ ∷ ↦⃗₄ ∷ ◾) ++↦ appendκ↦* rsa refl (☐⊕ i • (f ⊕ g ⨾☐• ☐)) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) loop⃗ rs refl | inj₂ ((a₃ , rsa) , _) = lem where rs₁' : [ f ∣ a₂ ∣ ☐⨾ h • (☐⊕ g ⨾ i • ☐) ]▷ ↦* [ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₁ a₃ ∣ ☐ ]▷ rs₁' = ↦⃗₇ ∷ appendκ↦* rsa refl (f ⨾☐• (☐⊕ g ⨾ i • ☐)) ++↦ ↦⃗₁₀ ∷ ↦⃗₁₁ ∷ ◾ xeq : x ≡ inj₁ a₃ ⃗ xeq = toState≡₁ (deterministic* rs rs₁' (is-stuck-toState _ _) (λ ())) lem : [ f ∣ a₂ ∣ ☐⊕ g • (☐⨾ h ⊕ i • ☐) ]▷ ↦* toState (f ⊕ g ⨾ h ⊕ i) x lem rewrite xeq = (↦⃗₁₁ ∷ ↦⃗₇ ∷ ↦⃗₄ ∷ ◾) ++↦ appendκ↦* rsa refl (☐⊕ i • (f ⊕ g ⨾☐• ☐)) ++↦ ↦⃗₁₁ ∷ ↦⃗₁₀ ∷ ◾ loop⃖ : (rs : ⟨ h ∣ a₂ ∣ f ⨾☐• (☐⊕ (g ⨾ i) • ☐) ⟩◁ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x) → len↦ rs ≡ n → ⟨ h ∣ a₂ ∣ ☐⊕ i • (f ⊕ g ⨾☐• ☐) ⟩◁ ↦* toState (f ⊕ g ⨾ h ⊕ i) x loop⃖ rs refl with inspect⊎ (run [ f ∣ a₂ ∣ ☐ ]◁) (λ ()) loop⃖ rs refl | inj₁ ((a₁ , rsa) , _) = lem where rs₁' : ⟨ h ∣ a₂ ∣ f ⨾☐• (☐⊕ (g ⨾ i) • ☐) ⟩◁ ↦* ⟨ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₁ a₁ ∣ ☐ ⟩◁ rs₁' = ↦⃖₇ ∷ appendκ↦* rsa refl (☐⨾ h • (☐⊕ g ⨾ i • ☐)) ++↦ ↦⃖₃ ∷ ↦⃖₄ ∷ ◾ xeq : x ≡ inj₁ a₁ ⃖ xeq = toState≡₂ (deterministic* rs rs₁' (is-stuck-toState _ _) (λ ())) lem : ⟨ h ∣ a₂ ∣ ☐⊕ i • ((f ⊕ g) ⨾☐• ☐) ⟩◁ ↦* toState (f ⊕ g ⨾ h ⊕ i) x lem rewrite xeq = (↦⃖₄ ∷ ↦⃖₇ ∷ ↦⃖₁₁ ∷ ◾) ++↦ appendκ↦* rsa refl (☐⊕ g • (☐⨾ h ⊕ i • ☐)) ++↦ ↦⃖₄ ∷ ↦⃖₃ ∷ ◾ loop⃖ rs refl | inj₂ ((a₂' , rsa) , _) = rs₂' ++↦ proj₁ (proj₁ (R (len↦ rs₁'') le) a₂') rs₁'' refl where rs₁' : ⟨ h ∣ a₂ ∣ f ⨾☐• (☐⊕ (g ⨾ i) • ☐) ⟩◁ ↦* [ f ∣ a₂' ∣ ☐⨾ h • (☐⊕ g ⨾ i • ☐) ]▷ rs₁' = ↦⃖₇ ∷ appendκ↦* rsa refl (☐⨾ h • (☐⊕ g ⨾ i • ☐)) rs₁'' : [ f ∣ a₂' ∣ ☐⨾ h • (☐⊕ g ⨾ i • ☐) ]▷ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : ⟨ h ∣ a₂ ∣ ☐⊕ i • ((f ⊕ g) ⨾☐• ☐) ⟩◁ ↦* [ f ∣ a₂' ∣ ☐⊕ g • ☐⨾ h ⊕ i • ☐ ]▷ rs₂' = (↦⃖₄ ∷ ↦⃖₇ ∷ ↦⃖₁₁ ∷ ◾) ++↦ appendκ↦* rsa refl (☐⊕ g • (☐⨾ h ⊕ i • ☐)) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) loop₂ : P₂ n loop₂ b₂ = loop⃗ , loop⃖ where loop⃗ : (rs : [ g ∣ b₂ ∣ ☐⨾ i • (f ⨾ h ⊕☐• ☐) ]▷ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x) → len↦ rs ≡ n → [ g ∣ b₂ ∣ f ⊕☐• (☐⨾ h ⊕ i • ☐) ]▷ ↦* toState (f ⊕ g ⨾ h ⊕ i) x loop⃗ rs refl with inspect⊎ (run ⟨ i ∣ b₂ ∣ ☐ ⟩▷) (λ ()) loop⃗ rs refl | inj₁ ((b₂' , rsb) , _) = rs₂' ++↦ proj₂ (proj₂ (R (len↦ rs₁'') le) b₂') rs₁'' refl where rs₁' : [ g ∣ b₂ ∣ ☐⨾ i • (f ⨾ h ⊕☐• ☐) ]▷ ↦* ⟨ i ∣ b₂' ∣ g ⨾☐• (f ⨾ h ⊕☐• ☐) ⟩◁ rs₁' = ↦⃗₇ ∷ appendκ↦* rsb refl (g ⨾☐• (f ⨾ h ⊕☐• ☐)) rs₁'' : ⟨ i ∣ b₂' ∣ g ⨾☐• (f ⨾ h ⊕☐• ☐) ⟩◁ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : [ g ∣ b₂ ∣ f ⊕☐• (☐⨾ h ⊕ i • ☐) ]▷ ↦* ⟨ i ∣ b₂' ∣ h ⊕☐• (f ⊕ g ⨾☐• ☐) ⟩◁ rs₂' = (↦⃗₁₂ ∷ ↦⃗₇ ∷ ↦⃗₅ ∷ ◾) ++↦ appendκ↦* rsb refl (h ⊕☐• (f ⊕ g ⨾☐• ☐)) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) loop⃗ rs refl | inj₂ ((b₃ , rsb) , _) = lem where rs₁' : [ g ∣ b₂ ∣ ☐⨾ i • (f ⨾ h ⊕☐• ☐) ]▷ ↦* [ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₂ b₃ ∣ ☐ ]▷ rs₁' = ↦⃗₇ ∷ appendκ↦* rsb refl (g ⨾☐• (f ⨾ h ⊕☐• ☐)) ++↦ ↦⃗₁₀ ∷ ↦⃗₁₂ ∷ ◾ xeq : x ≡ inj₂ b₃ ⃗ xeq = toState≡₁ (deterministic* rs rs₁' (is-stuck-toState _ _) (λ ())) lem : [ g ∣ b₂ ∣ f ⊕☐• (☐⨾ h ⊕ i • ☐) ]▷ ↦* toState (f ⊕ g ⨾ h ⊕ i) x lem rewrite xeq = (↦⃗₁₂ ∷ ↦⃗₇ ∷ ↦⃗₅ ∷ ◾) ++↦ appendκ↦* rsb refl (h ⊕☐• (f ⊕ g ⨾☐• ☐)) ++↦ ↦⃗₁₂ ∷ ↦⃗₁₀ ∷ ◾ loop⃖ : (rs : ⟨ i ∣ b₂ ∣ g ⨾☐• (f ⨾ h ⊕☐• ☐) ⟩◁ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x) → len↦ rs ≡ n → ⟨ i ∣ b₂ ∣ h ⊕☐• (f ⊕ g ⨾☐• ☐) ⟩◁ ↦* toState (f ⊕ g ⨾ h ⊕ i) x loop⃖ rs refl with inspect⊎ (run [ g ∣ b₂ ∣ ☐ ]◁) (λ ()) loop⃖ rs refl | inj₁ ((b₁ , rsb) , _) = lem where rs₁' : ⟨ i ∣ b₂ ∣ g ⨾☐• (f ⨾ h ⊕☐• ☐) ⟩◁ ↦* ⟨ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₂ b₁ ∣ ☐ ⟩◁ rs₁' = ↦⃖₇ ∷ appendκ↦* rsb refl (☐⨾ i • (f ⨾ h ⊕☐• ☐)) ++↦ ↦⃖₃ ∷ ↦⃖₅ ∷ ◾ xeq : x ≡ inj₂ b₁ ⃖ xeq = toState≡₂ (deterministic* rs rs₁' (is-stuck-toState _ _) (λ ())) lem : ⟨ i ∣ b₂ ∣ h ⊕☐• ((f ⊕ g) ⨾☐• ☐) ⟩◁ ↦* toState (f ⊕ g ⨾ h ⊕ i) x lem rewrite xeq = (↦⃖₅ ∷ ↦⃖₇ ∷ ↦⃖₁₂ ∷ ◾) ++↦ appendκ↦* rsb refl (f ⊕☐• (☐⨾ h ⊕ i • ☐)) ++↦ ↦⃖₅ ∷ ↦⃖₃ ∷ ◾ loop⃖ rs refl | inj₂ ((b₂' , rsb) , _) = rs₂' ++↦ proj₁ (proj₂ (R (len↦ rs₁'') le) b₂') rs₁'' refl where rs₁' : ⟨ i ∣ b₂ ∣ g ⨾☐• (f ⨾ h ⊕☐• ☐) ⟩◁ ↦* [ g ∣ b₂' ∣ ☐⨾ i • ((f ⨾ h) ⊕☐• ☐) ]▷ rs₁' = ↦⃖₇ ∷ appendκ↦* rsb refl (☐⨾ i • (f ⨾ h ⊕☐• ☐)) rs₁'' : [ g ∣ b₂' ∣ ☐⨾ i • ((f ⨾ h) ⊕☐• ☐) ]▷ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) x rs₁'' = proj₁ (deterministic*' rs₁' rs (is-stuck-toState _ _)) rs₂' : ⟨ i ∣ b₂ ∣ h ⊕☐• ((f ⊕ g) ⨾☐• ☐) ⟩◁ ↦* [ g ∣ b₂' ∣ f ⊕☐• (☐⨾ h ⊕ i • ☐) ]▷ rs₂' = (↦⃖₅ ∷ ↦⃖₇ ∷ ↦⃖₁₂ ∷ ◾) ++↦ appendκ↦* rsb refl (f ⊕☐• (☐⨾ h ⊕ i • ☐)) req : len↦ rs ≡ len↦ rs₁' + len↦ rs₁'' req = proj₂ (deterministic*' rs₁' rs (is-stuck-toState _ _)) le : len↦ rs₁'' <′ len↦ rs le = subst (λ x → len↦ rs₁'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) homomorphism : eval ((f ⨾ h) ⊕ (g ⨾ i)) ∼ eval (f ⊕ g ⨾ h ⊕ i) homomorphism (inj₁ a ⃗) with inspect⊎ (run ⟨ f ∣ a ∣ ☐ ⟩▷) (λ ()) homomorphism (inj₁ a ⃗) | inj₁ ((a₁ , rs) , eq) = lem where rs₁' : ⟨ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₁ a ∣ ☐ ⟩▷ ↦* ⟨ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₁ a₁ ∣ ☐ ⟩◁ rs₁' = (↦⃗₄ ∷ ↦⃗₃ ∷ ◾) ++↦ appendκ↦* rs refl (☐⨾ h • (☐⊕ g ⨾ i • ☐)) ++↦ ↦⃖₃ ∷ ↦⃖₄ ∷ ◾ rs₂' : ⟨ f ⊕ g ⨾ h ⊕ i ∣ inj₁ a ∣ ☐ ⟩▷ ↦* ⟨ f ⊕ g ⨾ h ⊕ i ∣ inj₁ a₁ ∣ ☐ ⟩◁ rs₂' = (↦⃗₃ ∷ ↦⃗₄ ∷ ◾) ++↦ appendκ↦* rs refl (☐⊕ g • (☐⨾ h ⊕ i • ☐)) ++↦ ↦⃖₄ ∷ ↦⃖₃ ∷ ◾ lem : eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₁ a ⃗) ≡ eval (f ⊕ g ⨾ h ⊕ i) (inj₁ a ⃗) lem rewrite eval-toState₁ rs₁' | eval-toState₁ rs₂' = refl homomorphism (inj₁ a ⃗) | inj₂ ((a₂ , rs) , eq) = lem where rs₁' : ⟨ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₁ a ∣ ☐ ⟩▷ ↦* [ f ∣ a₂ ∣ ☐⨾ h • (☐⊕ g ⨾ i • ☐) ]▷ rs₁' = (↦⃗₄ ∷ ↦⃗₃ ∷ ◾) ++↦ appendκ↦* rs refl (☐⨾ h • (☐⊕ g ⨾ i • ☐)) rs₁'' : [ f ∣ a₂ ∣ ☐⨾ h • (☐⊕ g ⨾ i • ☐) ]▷ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) (eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₁ a ⃗)) rs₁'' = proj₁ (deterministic*' rs₁' (getₜᵣ⃗ ((f ⨾ h) ⊕ (g ⨾ i)) refl) (is-stuck-toState _ _)) rs₂' : ⟨ f ⊕ g ⨾ h ⊕ i ∣ inj₁ a ∣ ☐ ⟩▷ ↦* [ f ∣ a₂ ∣ ☐⊕ g • (☐⨾ h ⊕ i • ☐) ]▷ rs₂' = (↦⃗₃ ∷ ↦⃗₄ ∷ ◾) ++↦ appendκ↦* rs refl (☐⊕ g • (☐⨾ h ⊕ i • ☐)) rs₂'' : [ f ∣ a₂ ∣ ☐⊕ g • (☐⨾ h ⊕ i • ☐) ]▷ ↦* toState (f ⊕ g ⨾ h ⊕ i) (eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₁ a ⃗)) rs₂'' = proj₁ (proj₁ (loop (len↦ rs₁'')) a₂) rs₁'' refl lem : eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₁ a ⃗) ≡ eval (f ⊕ g ⨾ h ⊕ i) (inj₁ a ⃗) lem rewrite eval-toState₁ (rs₂' ++↦ rs₂'') = refl homomorphism (inj₂ b ⃗) with inspect⊎ (run ⟨ g ∣ b ∣ ☐ ⟩▷) (λ ()) homomorphism (inj₂ b ⃗) | inj₁ ((b₁ , rs) , eq) = lem where rs₁' : ⟨ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₂ b ∣ ☐ ⟩▷ ↦* ⟨ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₂ b₁ ∣ ☐ ⟩◁ rs₁' = (↦⃗₅ ∷ ↦⃗₃ ∷ ◾) ++↦ appendκ↦* rs refl (☐⨾ i • (f ⨾ h ⊕☐• ☐)) ++↦ ↦⃖₃ ∷ ↦⃖₅ ∷ ◾ rs₂' : ⟨ f ⊕ g ⨾ h ⊕ i ∣ inj₂ b ∣ ☐ ⟩▷ ↦* ⟨ f ⊕ g ⨾ h ⊕ i ∣ inj₂ b₁ ∣ ☐ ⟩◁ rs₂' = (↦⃗₃ ∷ ↦⃗₅ ∷ ◾) ++↦ appendκ↦* rs refl (f ⊕☐• (☐⨾ h ⊕ i • ☐)) ++↦ ↦⃖₅ ∷ ↦⃖₃ ∷ ◾ lem : eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₂ b ⃗) ≡ eval (f ⊕ g ⨾ h ⊕ i) (inj₂ b ⃗) lem rewrite eval-toState₁ rs₁' | eval-toState₁ rs₂' = refl homomorphism (inj₂ b ⃗) | inj₂ ((b₂ , rs) , eq) = lem where rs₁' : ⟨ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₂ b ∣ ☐ ⟩▷ ↦* [ g ∣ b₂ ∣ ☐⨾ i • (f ⨾ h ⊕☐• ☐) ]▷ rs₁' = (↦⃗₅ ∷ ↦⃗₃ ∷ ◾) ++↦ appendκ↦* rs refl (☐⨾ i • (f ⨾ h ⊕☐• ☐)) rs₁'' : [ g ∣ b₂ ∣ ☐⨾ i • (f ⨾ h ⊕☐• ☐) ]▷ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) (eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₂ b ⃗)) rs₁'' = proj₁ (deterministic*' rs₁' (getₜᵣ⃗ ((f ⨾ h) ⊕ (g ⨾ i)) refl) (is-stuck-toState _ _)) rs₂' : ⟨ f ⊕ g ⨾ h ⊕ i ∣ inj₂ b ∣ ☐ ⟩▷ ↦* [ g ∣ b₂ ∣ f ⊕☐• (☐⨾ h ⊕ i • ☐) ]▷ rs₂' = (↦⃗₃ ∷ ↦⃗₅ ∷ ◾) ++↦ appendκ↦* rs refl (f ⊕☐• (☐⨾ h ⊕ i • ☐)) rs₂'' : [ g ∣ b₂ ∣ f ⊕☐• (☐⨾ h ⊕ i • ☐) ]▷ ↦* toState (f ⊕ g ⨾ h ⊕ i) (eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₂ b ⃗)) rs₂'' = proj₁ (proj₂ (loop (len↦ rs₁'')) b₂) rs₁'' refl lem : eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₂ b ⃗) ≡ eval (f ⊕ g ⨾ h ⊕ i) (inj₂ b ⃗) lem rewrite eval-toState₁ (rs₂' ++↦ rs₂'') = refl homomorphism (inj₁ a ⃖) with inspect⊎ (run [ h ∣ a ∣ ☐ ]◁) (λ ()) homomorphism (inj₁ a ⃖) | inj₁ ((a₂ , rs) , eq) = lem where rs₁' : [ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₁ a ∣ ☐ ]◁ ↦* ⟨ h ∣ a₂ ∣ f ⨾☐• (☐⊕ (g ⨾ i) • ☐) ⟩◁ rs₁' = (↦⃖₁₁ ∷ ↦⃖₁₀ ∷ ◾) ++↦ appendκ↦* rs refl (f ⨾☐• (☐⊕ g ⨾ i • ☐)) rs₁'' : ⟨ h ∣ a₂ ∣ f ⨾☐• (☐⊕ (g ⨾ i) • ☐) ⟩◁ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) (eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₁ a ⃖)) rs₁'' = proj₁ (deterministic*' rs₁' (getₜᵣ⃖ ((f ⨾ h) ⊕ (g ⨾ i)) refl) (is-stuck-toState _ _)) rs₂' : [ f ⊕ g ⨾ h ⊕ i ∣ inj₁ a ∣ ☐ ]◁ ↦* ⟨ h ∣ a₂ ∣ ☐⊕ i • (f ⊕ g ⨾☐• ☐) ⟩◁ rs₂' = (↦⃖₁₀ ∷ ↦⃖₁₁ ∷ ◾) ++↦ appendκ↦* rs refl (☐⊕ i • (f ⊕ g ⨾☐• ☐)) rs₂'' : ⟨ h ∣ a₂ ∣ ☐⊕ i • (f ⊕ g ⨾☐• ☐) ⟩◁ ↦* toState (f ⊕ g ⨾ h ⊕ i) (eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₁ a ⃖)) rs₂'' = proj₂ (proj₁ (loop (len↦ rs₁'')) a₂) rs₁'' refl lem : eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₁ a ⃖) ≡ eval (f ⊕ g ⨾ h ⊕ i) (inj₁ a ⃖) lem rewrite eval-toState₂ (rs₂' ++↦ rs₂'') = refl homomorphism (inj₁ a ⃖) | inj₂ ((a₃ , rs) , eq) = lem where rs₁' : [ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₁ a ∣ ☐ ]◁ ↦* [ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₁ a₃ ∣ ☐ ]▷ rs₁' = (↦⃖₁₁ ∷ ↦⃖₁₀ ∷ ◾) ++↦ appendκ↦* rs refl (f ⨾☐• (☐⊕ g ⨾ i • ☐)) ++↦ ↦⃗₁₀ ∷ ↦⃗₁₁ ∷ ◾ rs₂' : [ f ⊕ g ⨾ h ⊕ i ∣ inj₁ a ∣ ☐ ]◁ ↦* [ f ⊕ g ⨾ h ⊕ i ∣ inj₁ a₃ ∣ ☐ ]▷ rs₂' = (↦⃖₁₀ ∷ ↦⃖₁₁ ∷ ◾) ++↦ appendκ↦* rs refl (☐⊕ i • (f ⊕ g ⨾☐• ☐)) ++↦ ↦⃗₁₁ ∷ ↦⃗₁₀ ∷ ◾ lem : eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₁ a ⃖) ≡ eval (f ⊕ g ⨾ h ⊕ i) (inj₁ a ⃖) lem rewrite eval-toState₂ rs₁' | eval-toState₂ rs₂' = refl homomorphism (inj₂ b ⃖) with inspect⊎ (run [ i ∣ b ∣ ☐ ]◁) (λ ()) homomorphism (inj₂ b ⃖) | inj₁ ((b₂ , rs) , eq) = lem where rs₁' : [ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₂ b ∣ ☐ ]◁ ↦* ⟨ i ∣ b₂ ∣ g ⨾☐• (f ⨾ h ⊕☐• ☐) ⟩◁ rs₁' = (↦⃖₁₂ ∷ ↦⃖₁₀ ∷ ◾) ++↦ appendκ↦* rs refl (g ⨾☐• (f ⨾ h ⊕☐• ☐)) rs₁'' : ⟨ i ∣ b₂ ∣ g ⨾☐• (f ⨾ h ⊕☐• ☐) ⟩◁ ↦* toState ((f ⨾ h) ⊕ (g ⨾ i)) (eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₂ b ⃖)) rs₁'' = proj₁ (deterministic*' rs₁' (getₜᵣ⃖ ((f ⨾ h) ⊕ (g ⨾ i)) refl) (is-stuck-toState _ _)) rs₂' : [ f ⊕ g ⨾ h ⊕ i ∣ inj₂ b ∣ ☐ ]◁ ↦* ⟨ i ∣ b₂ ∣ h ⊕☐• (f ⊕ g ⨾☐• ☐) ⟩◁ rs₂' = (↦⃖₁₀ ∷ ↦⃖₁₂ ∷ ◾) ++↦ appendκ↦* rs refl (h ⊕☐• (f ⊕ g ⨾☐• ☐)) rs₂'' : ⟨ i ∣ b₂ ∣ h ⊕☐• (f ⊕ g ⨾☐• ☐) ⟩◁ ↦* toState (f ⊕ g ⨾ h ⊕ i) (eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₂ b ⃖)) rs₂'' = proj₂ (proj₂ (loop (len↦ rs₁'')) b₂) rs₁'' refl lem : eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₂ b ⃖) ≡ eval (f ⊕ g ⨾ h ⊕ i) (inj₂ b ⃖) lem rewrite eval-toState₂ (rs₂' ++↦ rs₂'') = refl homomorphism (inj₂ b ⃖) | inj₂ ((b₃ , rs) , eq) = lem where rs₁' : [ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₂ b ∣ ☐ ]◁ ↦* [ (f ⨾ h) ⊕ (g ⨾ i) ∣ inj₂ b₃ ∣ ☐ ]▷ rs₁' = (↦⃖₁₂ ∷ ↦⃖₁₀ ∷ ◾) ++↦ appendκ↦* rs refl (g ⨾☐• (f ⨾ h ⊕☐• ☐)) ++↦ ↦⃗₁₀ ∷ ↦⃗₁₂ ∷ ◾ rs₂' : [ f ⊕ g ⨾ h ⊕ i ∣ inj₂ b ∣ ☐ ]◁ ↦* [ f ⊕ g ⨾ h ⊕ i ∣ inj₂ b₃ ∣ ☐ ]▷ rs₂' = (↦⃖₁₀ ∷ ↦⃖₁₂ ∷ ◾) ++↦ appendκ↦* rs refl (h ⊕☐• (f ⊕ g ⨾☐• ☐)) ++↦ ↦⃗₁₂ ∷ ↦⃗₁₀ ∷ ◾ lem : eval ((f ⨾ h) ⊕ (g ⨾ i)) (inj₂ b ⃖) ≡ eval (f ⊕ g ⨾ h ⊕ i) (inj₂ b ⃖) lem rewrite eval-toState₂ rs₁' | eval-toState₂ rs₂' = refl open homomorphism public module Inverse where !invᵢ : ∀ {A B} → (c : A ↔ B) → interp c ∼ interp (! (! c)) !invᵢ unite₊l x = refl !invᵢ uniti₊l x = refl !invᵢ swap₊ x = refl !invᵢ assocl₊ x = refl !invᵢ assocr₊ x = refl !invᵢ unite⋆l x = refl !invᵢ uniti⋆l x = refl !invᵢ swap⋆ x = refl !invᵢ assocl⋆ x = refl !invᵢ assocr⋆ x = refl !invᵢ absorbr x = refl !invᵢ factorzl x = refl !invᵢ dist x = refl !invᵢ factor x = refl !invᵢ id↔ x = refl !invᵢ (c₁ ⨾ c₂) x = ∘-resp-≈ᵢ (!invᵢ c₂) (!invᵢ c₁) x !invᵢ (c₁ ⊕ c₂) (inj₁ x ⃗) rewrite sym (!invᵢ c₁ (x ⃗)) with interp c₁ (x ⃗) ... | x' ⃗ = refl ... | x' ⃖ = refl !invᵢ (c₁ ⊕ c₂) (inj₂ y ⃗) rewrite sym (!invᵢ c₂ (y ⃗)) with interp c₂ (y ⃗) ... | y' ⃗ = refl ... | y' ⃖ = refl !invᵢ (c₁ ⊕ c₂) (inj₁ x ⃖) rewrite sym (!invᵢ c₁ (x ⃖)) with interp c₁ (x ⃖) ... | x' ⃗ = refl ... | x' ⃖ = refl !invᵢ (c₁ ⊕ c₂) (inj₂ y ⃖) rewrite sym (!invᵢ c₂ (y ⃖)) with interp c₂ (y ⃖) ... | y' ⃗ = refl ... | y' ⃖ = refl !invᵢ (c₁ ⊗ c₂) ((x , y) ⃗) rewrite sym (!invᵢ c₁ (x ⃗)) with interp c₁ (x ⃗) !invᵢ (c₁ ⊗ c₂) ((x , y) ⃗) | x' ⃗ rewrite sym (!invᵢ c₂ (y ⃗)) with interp c₂ (y ⃗) !invᵢ (c₁ ⊗ c₂) ((x , y) ⃗) | x' ⃗ | y' ⃗ = refl !invᵢ (c₁ ⊗ c₂) ((x , y) ⃗) | x' ⃗ | y' ⃖ = refl !invᵢ (c₁ ⊗ c₂) ((x , y) ⃗) | x' ⃖ = refl !invᵢ (c₁ ⊗ c₂) ((x , y) ⃖) rewrite sym (!invᵢ c₂ (y ⃖)) with interp c₂ (y ⃖) !invᵢ (c₁ ⊗ c₂) ((x , y) ⃖) | y' ⃗ = refl !invᵢ (c₁ ⊗ c₂) ((x , y) ⃖) | y' ⃖ rewrite sym (!invᵢ c₁ (x ⃖)) with interp c₁ (x ⃖) !invᵢ (c₁ ⊗ c₂) ((x , y) ⃖) | y' ⃖ | x' ⃗ = refl !invᵢ (c₁ ⊗ c₂) ((x , y) ⃖) | y' ⃖ | x' ⃖ = refl !invᵢ η₊ x = refl !invᵢ ε₊ x = refl !inv : ∀ {A B} → (c : A ↔ B) → eval c ∼ eval (! (! c)) !inv c x = trans (eval≡interp c x) (trans (!invᵢ c x) (sym (eval≡interp (! (! c)) x))) private toState! : ∀ {A B} → (c : A ↔ B) → Val B A → State toState! c (b ⃗) = ⟨ ! c ∣ b ∣ ☐ ⟩◁ toState! c (a ⃖) = [ ! c ∣ a ∣ ☐ ]▷ mutual !rev : ∀ {A B} → (c : A ↔ B) → ∀ x {y} → eval c x ≡ y → eval (! c) y ≡ x !rev unite₊l (inj₂ y ⃗) refl = refl !rev unite₊l (x ⃖) refl = refl !rev uniti₊l (x ⃗) refl = refl !rev uniti₊l (inj₂ y ⃖) refl = refl !rev swap₊ (inj₁ x ⃗) refl = refl !rev swap₊ (inj₂ y ⃗) refl = refl !rev swap₊ (inj₁ x ⃖) refl = refl !rev swap₊ (inj₂ y ⃖) refl = refl !rev assocl₊ (inj₁ x ⃗) refl = refl !rev assocl₊ (inj₂ (inj₁ y) ⃗) refl = refl !rev assocl₊ (inj₂ (inj₂ z) ⃗) refl = refl !rev assocl₊ (inj₁ (inj₁ x) ⃖) refl = refl !rev assocl₊ (inj₁ (inj₂ y) ⃖) refl = refl !rev assocl₊ (inj₂ z ⃖) refl = refl !rev assocr₊ (inj₁ (inj₁ x) ⃗) refl = refl !rev assocr₊ (inj₁ (inj₂ y) ⃗) refl = refl !rev assocr₊ (inj₂ z ⃗) refl = refl !rev assocr₊ (inj₁ x ⃖) refl = refl !rev assocr₊ (inj₂ (inj₁ y) ⃖) refl = refl !rev assocr₊ (inj₂ (inj₂ z) ⃖) refl = refl !rev unite⋆l ((tt , x) ⃗) refl = refl !rev unite⋆l (x ⃖) refl = refl !rev uniti⋆l (x ⃗) refl = refl !rev uniti⋆l ((tt , x) ⃖) refl = refl !rev swap⋆ ((x , y) ⃗) refl = refl !rev swap⋆ ((y , x) ⃖) refl = refl !rev assocl⋆ ((x , (y , z)) ⃗) refl = refl !rev assocl⋆ (((x , y) , z) ⃖) refl = refl !rev assocr⋆ (((x , y) , z) ⃗) refl = refl !rev assocr⋆ ((x , (y , z)) ⃖) refl = refl !rev absorbr (() ⃗) !rev absorbr (() ⃖) !rev factorzl (() ⃗) !rev factorzl (() ⃖) !rev dist ((inj₁ x , z) ⃗) refl = refl !rev dist ((inj₂ y , z) ⃗) refl = refl !rev dist (inj₁ (x , z) ⃖) refl = refl !rev dist (inj₂ (y , z) ⃖) refl = refl !rev factor (inj₁ (x , z) ⃗) refl = refl !rev factor (inj₂ (y , z) ⃗) refl = refl !rev factor ((inj₁ x , z) ⃖) refl = refl !rev factor ((inj₂ y , z) ⃖) refl = refl !rev id↔ (x ⃗) refl = refl !rev id↔ (x ⃖) refl = refl !rev (c₁ ⨾ c₂) (x ⃗) refl with inspect⊎ (run ⟨ c₁ ∣ x ∣ ☐ ⟩▷) (λ ()) !rev (c₁ ⨾ c₂) (x ⃗) refl | inj₁ ((x' , rs) , eq) = lem where rs' : ⟨ c₁ ⨾ c₂ ∣ x ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⨾ c₂ ∣ x' ∣ ☐ ⟩◁ rs' = ↦⃗₃ ∷ appendκ↦* rs refl (☐⨾ c₂ • ☐) ++↦ ↦⃖₃ ∷ ◾ rs! : [ ! c₂ ⨾ ! c₁ ∣ x' ∣ ☐ ]◁ ↦* [ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ]▷ rs! = ↦⃖₁₀ ∷ appendκ↦* (getₜᵣ⃖ (! c₁) (!rev c₁ (x ⃗) (eval-toState₁ rs))) refl (! c₂ ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ lem : eval (! (c₁ ⨾ c₂)) (eval (c₁ ⨾ c₂) (x ⃗)) ≡ x ⃗ lem rewrite eval-toState₁ rs' = eval-toState₂ rs! !rev (c₁ ⨾ c₂) (x ⃗) refl | inj₂ ((x' , rs) , eq) = lem where rs' : [ c₁ ∣ x' ∣ ☐⨾ c₂ • ☐ ]▷ ↦* toState (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (x ⃗)) rs' = proj₁ (deterministic*' (↦⃗₃ ∷ appendκ↦* rs refl (☐⨾ c₂ • ☐)) (getₜᵣ⃗ (c₁ ⨾ c₂) refl) (is-stuck-toState _ _)) rs! : [ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ]◁ ↦* ⟨ ! c₁ ∣ x' ∣ ! c₂ ⨾☐• ☐ ⟩◁ rs! = ↦⃖₁₀ ∷ Rev* (appendκ↦* (getₜᵣ⃗ (! c₁) (!rev c₁ (x ⃗) (eval-toState₁ rs))) refl (! c₂ ⨾☐• ☐)) rs!' : ⟨ ! c₁ ∣ x' ∣ ! c₂ ⨾☐• ☐ ⟩◁ ↦* toState! (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (x ⃗)) rs!' = proj₁ (loop (len↦ rs') x') rs' refl lem : eval (! (c₁ ⨾ c₂)) (eval (c₁ ⨾ c₂) (x ⃗)) ≡ x ⃗ lem with eval (c₁ ⨾ c₂) (x ⃗) | inspect (eval (c₁ ⨾ c₂)) (x ⃗) ... | (x'' ⃗) | [ eq ] = eval-toState₁ (Rev* rs!'') where seq : toState! (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (x ⃗)) ≡ ⟨ ! c₂ ⨾ ! c₁ ∣ x'' ∣ ☐ ⟩◁ seq rewrite eq = refl rs!'' : [ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ]◁ ↦* ⟨ ! c₂ ⨾ ! c₁ ∣ x'' ∣ ☐ ⟩◁ rs!'' = subst (λ st → [ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ]◁ ↦* st) seq (rs! ++↦ rs!') ... | (x'' ⃖) | [ eq ] = eval-toState₂ (Rev* rs!'') where seq : toState! (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (x ⃗)) ≡ [ ! c₂ ⨾ ! c₁ ∣ x'' ∣ ☐ ]▷ seq rewrite eq = refl rs!'' : [ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ]◁ ↦* [ ! c₂ ⨾ ! c₁ ∣ x'' ∣ ☐ ]▷ rs!'' = subst (λ st → [ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ]◁ ↦* st) seq (rs! ++↦ rs!') !rev (c₁ ⨾ c₂) (x ⃖) refl with inspect⊎ (run [ c₂ ∣ x ∣ ☐ ]◁) (λ ()) !rev (c₁ ⨾ c₂) (x ⃖) refl | inj₁ ((x' , rs) , eq) = lem where rs' : ⟨ c₂ ∣ x' ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* toState (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (x ⃖)) rs' = proj₁ (deterministic*' (↦⃖₁₀ ∷ appendκ↦* rs refl (c₁ ⨾☐• ☐)) (getₜᵣ⃖ (c₁ ⨾ c₂) refl) (is-stuck-toState _ _)) rs! : ⟨ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ⟩▷ ↦* ⟨ ! c₁ ∣ x' ∣ ! c₂ ⨾☐• ☐ ⟩▷ rs! = (↦⃗₃ ∷ ◾) ++↦ Rev* (appendκ↦* (getₜᵣ⃖ (! c₂) (!rev c₂ (x ⃖) (eval-toState₂ rs))) refl (☐⨾ ! c₁ • ☐)) ++↦ ↦⃗₇ ∷ ◾ rs!' : ⟨ ! c₁ ∣ x' ∣ ! c₂ ⨾☐• ☐ ⟩▷ ↦* toState! (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (x ⃖)) rs!' = proj₂ (loop (len↦ rs') x') rs' refl lem : eval (! (c₁ ⨾ c₂)) (eval (c₁ ⨾ c₂) (x ⃖)) ≡ x ⃖ lem with eval (c₁ ⨾ c₂) (x ⃖) | inspect (eval (c₁ ⨾ c₂)) (x ⃖) ... | (x'' ⃗) | [ eq ] = eval-toState₁ (Rev* rs!'') where seq : toState! (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (x ⃖)) ≡ ⟨ ! c₂ ⨾ ! c₁ ∣ x'' ∣ ☐ ⟩◁ seq rewrite eq = refl rs!'' : ⟨ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ⟩▷ ↦* ⟨ ! c₂ ⨾ ! c₁ ∣ x'' ∣ ☐ ⟩◁ rs!'' = subst (λ st → ⟨ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ⟩▷ ↦* st) seq (rs! ++↦ rs!') ... | (x'' ⃖) | [ eq ] = eval-toState₂ (Rev* rs!'') where seq : toState! (c₁ ⨾ c₂) (eval (c₁ ⨾ c₂) (x ⃖)) ≡ [ ! c₂ ⨾ ! c₁ ∣ x'' ∣ ☐ ]▷ seq rewrite eq = refl rs!'' : ⟨ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ⟩▷ ↦* [ ! c₂ ⨾ ! c₁ ∣ x'' ∣ ☐ ]▷ rs!'' = subst (λ st → ⟨ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ⟩▷ ↦* st) seq (rs! ++↦ rs!') !rev (c₁ ⨾ c₂) (x ⃖) refl | inj₂ ((x' , rs) , eq) = lem where rs' : [ c₁ ⨾ c₂ ∣ x ∣ ☐ ]◁ ↦* [ c₁ ⨾ c₂ ∣ x' ∣ ☐ ]▷ rs' = ↦⃖₁₀ ∷ appendκ↦* rs refl (c₁ ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ rs! : ⟨ ! c₂ ⨾ ! c₁ ∣ x' ∣ ☐ ⟩▷ ↦* ⟨ ! c₂ ⨾ ! c₁ ∣ x ∣ ☐ ⟩◁ rs! = ↦⃗₃ ∷ appendκ↦* (getₜᵣ⃗ (! c₂) (!rev c₂ (x ⃖) (eval-toState₂ rs))) refl (☐⨾ ! c₁ • ☐) ++↦ ↦⃖₃ ∷ ◾ lem : eval (! (c₁ ⨾ c₂)) (eval (c₁ ⨾ c₂) (x ⃖)) ≡ x ⃖ lem rewrite eval-toState₂ rs' = eval-toState₁ rs! !rev (c₁ ⊕ c₂) (inj₁ x ⃗) refl with inspect⊎ (run ⟨ c₁ ∣ x ∣ ☐ ⟩▷) (λ ()) !rev (c₁ ⊕ c₂) (inj₁ x ⃗) refl | inj₁ ((x' , rs) , eq) = lem where rs' : ⟨ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₁ x' ∣ ☐ ⟩◁ rs' = ↦⃗₄ ∷ appendκ↦* rs refl (☐⊕ c₂ • ☐) ++↦ ↦⃖₄ ∷ ◾ rs! : [ ! (c₁ ⊕ c₂) ∣ inj₁ x' ∣ ☐ ]◁ ↦* [ ! (c₁ ⊕ c₂) ∣ inj₁ x ∣ ☐ ]▷ rs! = ↦⃖₁₁ ∷ appendκ↦* (getₜᵣ⃖ (! c₁) (!rev c₁ (x ⃗) (eval-toState₁ rs))) refl (☐⊕ ! c₂ • ☐) ++↦ ↦⃗₁₁ ∷ ◾ lem : eval (! (c₁ ⊕ c₂)) (eval (c₁ ⊕ c₂) (inj₁ x ⃗)) ≡ inj₁ x ⃗ lem rewrite eval-toState₁ rs' = eval-toState₂ rs! !rev (c₁ ⊕ c₂) (inj₁ x ⃗) refl | inj₂ ((x' , rs) , eq) = lem where rs' : ⟨ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ⟩▷ ↦* [ c₁ ⊕ c₂ ∣ inj₁ x' ∣ ☐ ]▷ rs' = ↦⃗₄ ∷ appendκ↦* rs refl (☐⊕ c₂ • ☐) ++↦ ↦⃗₁₁ ∷ ◾ rs! : ⟨ ! (c₁ ⊕ c₂) ∣ inj₁ x' ∣ ☐ ⟩▷ ↦* [ ! (c₁ ⊕ c₂) ∣ inj₁ x ∣ ☐ ]▷ rs! = ↦⃗₄ ∷ appendκ↦* (getₜᵣ⃗ (! c₁) (!rev c₁ (x ⃗) (eval-toState₁ rs))) refl (☐⊕ ! c₂ • ☐) ++↦ ↦⃗₁₁ ∷ ◾ lem : eval (! (c₁ ⊕ c₂)) (eval (c₁ ⊕ c₂) (inj₁ x ⃗)) ≡ inj₁ x ⃗ lem rewrite eval-toState₁ rs' = eval-toState₁ rs! !rev (c₁ ⊕ c₂) (inj₂ y ⃗) refl with inspect⊎ (run ⟨ c₂ ∣ y ∣ ☐ ⟩▷) (λ ()) !rev (c₁ ⊕ c₂) (inj₂ y ⃗) refl | inj₁ ((y' , rs) , eq) = lem where rs' : ⟨ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₂ y' ∣ ☐ ⟩◁ rs' = ↦⃗₅ ∷ appendκ↦* rs refl (c₁ ⊕☐• ☐) ++↦ ↦⃖₅ ∷ ◾ rs! : [ ! (c₁ ⊕ c₂) ∣ inj₂ y' ∣ ☐ ]◁ ↦* [ ! (c₁ ⊕ c₂) ∣ inj₂ y ∣ ☐ ]▷ rs! = ↦⃖₁₂ ∷ appendκ↦* (getₜᵣ⃖ (! c₂) (!rev c₂ (y ⃗) (eval-toState₁ rs))) refl (! c₁ ⊕☐• ☐) ++↦ ↦⃗₁₂ ∷ ◾ lem : eval (! (c₁ ⊕ c₂)) (eval (c₁ ⊕ c₂) (inj₂ y ⃗)) ≡ inj₂ y ⃗ lem rewrite eval-toState₁ rs' = eval-toState₂ rs! !rev (c₁ ⊕ c₂) (inj₂ y ⃗) refl | inj₂ ((y' , rs) , eq) = lem where rs' : ⟨ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ⟩▷ ↦* [ c₁ ⊕ c₂ ∣ inj₂ y' ∣ ☐ ]▷ rs' = ↦⃗₅ ∷ appendκ↦* rs refl (c₁ ⊕☐• ☐) ++↦ ↦⃗₁₂ ∷ ◾ rs! : ⟨ ! (c₁ ⊕ c₂) ∣ inj₂ y' ∣ ☐ ⟩▷ ↦* [ ! (c₁ ⊕ c₂) ∣ inj₂ y ∣ ☐ ]▷ rs! = ↦⃗₅ ∷ appendκ↦* (getₜᵣ⃗ (! c₂) (!rev c₂ (y ⃗) (eval-toState₁ rs))) refl (! c₁ ⊕☐• ☐) ++↦ ↦⃗₁₂ ∷ ◾ lem : eval (! (c₁ ⊕ c₂)) (eval (c₁ ⊕ c₂) (inj₂ y ⃗)) ≡ inj₂ y ⃗ lem rewrite eval-toState₁ rs' = eval-toState₁ rs! !rev (c₁ ⊕ c₂) (inj₁ x ⃖) refl with inspect⊎ (run [ c₁ ∣ x ∣ ☐ ]◁) (λ ()) !rev (c₁ ⊕ c₂) (inj₁ x ⃖) refl | inj₁ ((x' , rs) , eq) = lem where rs' : [ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ]◁ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₁ x' ∣ ☐ ⟩◁ rs' = ↦⃖₁₁ ∷ appendκ↦* rs refl (☐⊕ c₂ • ☐) ++↦ ↦⃖₄ ∷ ◾ rs! : [ ! (c₁ ⊕ c₂) ∣ inj₁ x' ∣ ☐ ]◁ ↦* ⟨ ! (c₁ ⊕ c₂) ∣ inj₁ x ∣ ☐ ⟩◁ rs! = ↦⃖₁₁ ∷ appendκ↦* (getₜᵣ⃖ (! c₁) (!rev c₁ (x ⃖) (eval-toState₂ rs))) refl (☐⊕ ! c₂ • ☐) ++↦ ↦⃖₄ ∷ ◾ lem : eval (! (c₁ ⊕ c₂)) (eval (c₁ ⊕ c₂) (inj₁ x ⃖)) ≡ inj₁ x ⃖ lem rewrite eval-toState₂ rs' = eval-toState₂ rs! !rev (c₁ ⊕ c₂) (inj₁ x ⃖) refl | inj₂ ((x' , rs) , eq) = lem where rs' : [ c₁ ⊕ c₂ ∣ inj₁ x ∣ ☐ ]◁ ↦* [ c₁ ⊕ c₂ ∣ inj₁ x' ∣ ☐ ]▷ rs' = ↦⃖₁₁ ∷ appendκ↦* rs refl (☐⊕ c₂ • ☐) ++↦ ↦⃗₁₁ ∷ ◾ rs! : ⟨ ! (c₁ ⊕ c₂) ∣ inj₁ x' ∣ ☐ ⟩▷ ↦* ⟨ ! (c₁ ⊕ c₂) ∣ inj₁ x ∣ ☐ ⟩◁ rs! = ↦⃗₄ ∷ appendκ↦* (getₜᵣ⃗ (! c₁) (!rev c₁ (x ⃖) (eval-toState₂ rs))) refl (☐⊕ ! c₂ • ☐) ++↦ ↦⃖₄ ∷ ◾ lem : eval (! (c₁ ⊕ c₂)) (eval (c₁ ⊕ c₂) (inj₁ x ⃖)) ≡ inj₁ x ⃖ lem rewrite eval-toState₂ rs' = eval-toState₁ rs! !rev (c₁ ⊕ c₂) (inj₂ y ⃖) refl with inspect⊎ (run [ c₂ ∣ y ∣ ☐ ]◁) (λ ()) !rev (c₁ ⊕ c₂) (inj₂ y ⃖) refl | inj₁ ((y' , rs) , eq) = lem where rs' : [ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ]◁ ↦* ⟨ c₁ ⊕ c₂ ∣ inj₂ y' ∣ ☐ ⟩◁ rs' = ↦⃖₁₂ ∷ appendκ↦* rs refl (c₁ ⊕☐• ☐) ++↦ ↦⃖₅ ∷ ◾ rs! : [ ! (c₁ ⊕ c₂) ∣ inj₂ y' ∣ ☐ ]◁ ↦* ⟨ ! (c₁ ⊕ c₂) ∣ inj₂ y ∣ ☐ ⟩◁ rs! = ↦⃖₁₂ ∷ appendκ↦* (getₜᵣ⃖ (! c₂) (!rev c₂ (y ⃖) (eval-toState₂ rs))) refl (! c₁ ⊕☐• ☐) ++↦ ↦⃖₅ ∷ ◾ lem : eval (! (c₁ ⊕ c₂)) (eval (c₁ ⊕ c₂) (inj₂ y ⃖)) ≡ inj₂ y ⃖ lem rewrite eval-toState₂ rs' = eval-toState₂ rs! !rev (c₁ ⊕ c₂) (inj₂ y ⃖) refl | inj₂ ((y' , rs) , eq) = lem where rs' : [ c₁ ⊕ c₂ ∣ inj₂ y ∣ ☐ ]◁ ↦* [ c₁ ⊕ c₂ ∣ inj₂ y' ∣ ☐ ]▷ rs' = ↦⃖₁₂ ∷ appendκ↦* rs refl (c₁ ⊕☐• ☐) ++↦ ↦⃗₁₂ ∷ ◾ rs! : ⟨ ! (c₁ ⊕ c₂) ∣ inj₂ y' ∣ ☐ ⟩▷ ↦* ⟨ ! (c₁ ⊕ c₂) ∣ inj₂ y ∣ ☐ ⟩◁ rs! = ↦⃗₅ ∷ appendκ↦* (getₜᵣ⃗ (! c₂) (!rev c₂ (y ⃖) (eval-toState₂ rs))) refl (! c₁ ⊕☐• ☐) ++↦ ↦⃖₅ ∷ ◾ lem : eval (! (c₁ ⊕ c₂)) (eval (c₁ ⊕ c₂) (inj₂ y ⃖)) ≡ inj₂ y ⃖ lem rewrite eval-toState₂ rs' = eval-toState₁ rs! !rev (c₁ ⊗ c₂) ((x , y) ⃗) refl with inspect⊎ (run ⟨ c₁ ∣ x ∣ ☐ ⟩▷) (λ ()) !rev (c₁ ⊗ c₂) ((x , y) ⃗) refl | inj₁ ((x' , rsx) , _) = lem where rsx' : ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊗ c₂ ∣ (x' , y) ∣ ☐ ⟩◁ rsx' = ↦⃗₆ ∷ appendκ↦* rsx refl (☐⊗[ c₂ , y ]• ☐) ++↦ ↦⃖₆ ∷ ◾ rs! : [ ! (c₁ ⊗ c₂) ∣ (x' , y) ∣ ☐ ]◁ ↦* [ ! (c₁ ⊗ c₂) ∣ (x , y) ∣ ☐ ]▷ rs! = (↦⃖₁₀ ∷ ↦⃖₁₀ ∷ ↦⃖₁ ∷ ↦⃖₇ ∷ ↦⃖₉ ∷ ◾) ++↦ appendκ↦* (getₜᵣ⃖ (! c₁) (!rev c₁ (x ⃗) (eval-toState₁ rsx))) refl ([ ! c₂ , y ]⊗☐• ☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐)) ++↦ ↦⃗₉ ∷ ↦⃗₇ ∷ ↦⃗₁ ∷ ↦⃗₁₀ ∷ ↦⃗₁₀ ∷ ◾ lem : eval (! (c₁ ⊗ c₂)) (eval (c₁ ⊗ c₂) ((x , y) ⃗)) ≡ (x , y) ⃗ lem rewrite eval-toState₁ rsx' = eval-toState₂ rs! !rev (c₁ ⊗ c₂) ((x , y) ⃗) refl | inj₂ ((x' , rsx) , _) with inspect⊎ (run ⟨ c₂ ∣ y ∣ ☐ ⟩▷) (λ ()) !rev (c₁ ⊗ c₂) ((x , y) ⃗) refl | inj₂ ((x' , rsx) , _) | inj₁ ((y' , rsy) , _) = lem where rs' : ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ⟩▷ ↦* ⟨ c₁ ⊗ c₂ ∣ (x , y') ∣ ☐ ⟩◁ rs' = ↦⃗₆ ∷ appendκ↦* rsx refl (☐⊗[ c₂ , y ]• ☐) ++↦ ↦⃗₈ ∷ appendκ↦* rsy refl ([ c₁ , x' ]⊗☐• ☐) ++↦ ↦⃖₈ ∷ Rev* (appendκ↦* rsx refl (☐⊗[ c₂ , y' ]• ☐)) ++↦ ↦⃖₆ ∷ ◾ rs! : [ ! (c₁ ⊗ c₂) ∣ (x , y') ∣ ☐ ]◁ ↦* [ ! (c₁ ⊗ c₂) ∣ (x , y) ∣ ☐ ]▷ rs! = (↦⃖₁₀ ∷ ↦⃖₁₀ ∷ ↦⃖₁ ∷ ↦⃖₇ ∷ ↦⃖₉ ∷ ◾) ++↦ appendκ↦* (Rev* (getₜᵣ⃗ (! c₁) (!rev c₁ (x ⃗) (eval-toState₁ rsx)))) refl ([ ! c₂ , y' ]⊗☐• (☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐))) ++↦ ↦⃖₈ ∷ appendκ↦* (getₜᵣ⃖ (! c₂) (!rev c₂ (y ⃗) (eval-toState₁ rsy))) refl (☐⊗[ ! c₁ , x' ]• (☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐))) ++↦ ↦⃗₈ ∷ appendκ↦* (getₜᵣ⃗ (! c₁) (!rev c₁ (x ⃗) (eval-toState₁ rsx))) refl ([ ! c₂ , y ]⊗☐• (☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐))) ++↦ ↦⃗₉ ∷ ↦⃗₇ ∷ ↦⃗₁ ∷ ↦⃗₁₀ ∷ ↦⃗₁₀ ∷ ◾ lem : eval (! (c₁ ⊗ c₂)) (eval (c₁ ⊗ c₂) ((x , y) ⃗)) ≡ (x , y) ⃗ lem rewrite eval-toState₁ rs' = eval-toState₂ rs! !rev (c₁ ⊗ c₂) ((x , y) ⃗) refl | inj₂ ((x' , rsx) , _) | inj₂ ((y' , rsy) , _) = lem where rs' : ⟨ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ⟩▷ ↦* [ c₁ ⊗ c₂ ∣ (x' , y') ∣ ☐ ]▷ rs' = ↦⃗₆ ∷ appendκ↦* rsx refl (☐⊗[ c₂ , y ]• ☐) ++↦ ↦⃗₈ ∷ appendκ↦* rsy refl ([ c₁ , x' ]⊗☐• ☐) ++↦ ↦⃗₉ ∷ ◾ rs! : ⟨ ! (c₁ ⊗ c₂) ∣ (x' , y') ∣ ☐ ⟩▷ ↦* [ ! (c₁ ⊗ c₂) ∣ (x , y) ∣ ☐ ]▷ rs! = (↦⃗₃ ∷ ↦⃗₁ ∷ ↦⃗₇ ∷ ↦⃗₃ ∷ ↦⃗₆ ∷ ◾) ++↦ appendκ↦* (getₜᵣ⃗ (! c₂) (!rev c₂ (y ⃗) (eval-toState₁ rsy))) refl (☐⊗[ ! c₁ , x' ]• (☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐))) ++↦ ↦⃗₈ ∷ appendκ↦* (getₜᵣ⃗ (! c₁) (!rev c₁ (x ⃗) (eval-toState₁ rsx))) refl ([ ! c₂ , y ]⊗☐• (☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐))) ++↦ ↦⃗₉ ∷ ↦⃗₇ ∷ ↦⃗₁ ∷ ↦⃗₁₀ ∷ ↦⃗₁₀ ∷ ◾ lem : eval (! (c₁ ⊗ c₂)) (eval (c₁ ⊗ c₂) ((x , y) ⃗)) ≡ (x , y) ⃗ lem rewrite eval-toState₁ rs' = eval-toState₁ rs! !rev (c₁ ⊗ c₂) ((x , y) ⃖) refl with inspect⊎ (run [ c₂ ∣ y ∣ ☐ ]◁) (λ ()) !rev (c₁ ⊗ c₂) ((x , y) ⃖) refl | inj₁ ((y' , rsy) , _) with inspect⊎ (run [ c₁ ∣ x ∣ ☐ ]◁) (λ ()) !rev (c₁ ⊗ c₂) ((x , y) ⃖) refl | inj₁ ((y' , rsy) , _) | inj₁ ((x' , rsx) , _) = lem where rs' : [ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ]◁ ↦* ⟨ c₁ ⊗ c₂ ∣ (x' , y') ∣ ☐ ⟩◁ rs' = ↦⃖₉ ∷ appendκ↦* rsy refl ([ c₁ , x ]⊗☐• ☐) ++↦ ↦⃖₈ ∷ appendκ↦* rsx refl (☐⊗[ c₂ , y' ]• ☐) ++↦ ↦⃖₆ ∷ ◾ rs! : [ ! (c₁ ⊗ c₂) ∣ (x' , y') ∣ ☐ ]◁ ↦* ⟨ ! (c₁ ⊗ c₂) ∣ (x , y) ∣ ☐ ⟩◁ rs! = ↦⃖₁₀ ∷ ↦⃖₁₀ ∷ ↦⃖₁ ∷ ↦⃖₇ ∷ ↦⃖₉ ∷ ◾ ++↦ appendκ↦* (getₜᵣ⃖ (! c₁) (!rev c₁ (x ⃖) (eval-toState₂ rsx))) refl ([ ! c₂ , y' ]⊗☐• (☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐))) ++↦ ↦⃖₈ ∷ appendκ↦* (getₜᵣ⃖ (! c₂) (!rev c₂ (y ⃖) (eval-toState₂ rsy))) refl (☐⊗[ ! c₁ , x ]• (☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐))) ++↦ ↦⃖₆ ∷ ↦⃖₃ ∷ ↦⃖₇ ∷ ↦⃖₁ ∷ ↦⃖₃ ∷ ◾ lem : eval (! (c₁ ⊗ c₂)) (eval (c₁ ⊗ c₂) ((x , y) ⃖)) ≡ (x , y) ⃖ lem rewrite eval-toState₂ rs' = eval-toState₂ rs! !rev (c₁ ⊗ c₂) ((x , y) ⃖) refl | inj₁ ((y' , rsy) , _) | inj₂ ((x' , rsx) , _) = lem where rs' : [ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ]◁ ↦* [ c₁ ⊗ c₂ ∣ (x' , y) ∣ ☐ ]▷ rs' = ↦⃖₉ ∷ appendκ↦* rsy refl ([ c₁ , x ]⊗☐• ☐) ++↦ ↦⃖₈ ∷ appendκ↦* rsx refl (☐⊗[ c₂ , y' ]• ☐) ++↦ ↦⃗₈ ∷ Rev* (appendκ↦* rsy refl ([ c₁ , x' ]⊗☐• ☐)) ++↦ ↦⃗₉ ∷ ◾ rs! : ⟨ ! (c₁ ⊗ c₂) ∣ (x' , y) ∣ ☐ ⟩▷ ↦* ⟨ ! (c₁ ⊗ c₂) ∣ (x , y) ∣ ☐ ⟩◁ rs! = (↦⃗₃ ∷ ↦⃗₁ ∷ ↦⃗₇ ∷ ↦⃗₃ ∷ ↦⃗₆ ∷ ◾) ++↦ Rev* (appendκ↦* (getₜᵣ⃖ (! c₂) (!rev c₂ (y ⃖) (eval-toState₂ rsy))) refl (☐⊗[ ! c₁ , x' ]• (☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐)))) ++↦ ↦⃗₈ ∷ appendκ↦* (getₜᵣ⃗ (! c₁) (!rev c₁ (x ⃖) (eval-toState₂ rsx))) refl ([ ! c₂ , y' ]⊗☐• (☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐))) ++↦ ↦⃖₈ ∷ appendκ↦* (getₜᵣ⃖ (! c₂) (!rev c₂ (y ⃖) (eval-toState₂ rsy))) refl (☐⊗[ ! c₁ , x ]• (☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐))) ++↦ ↦⃖₆ ∷ ↦⃖₃ ∷ ↦⃖₇ ∷ ↦⃖₁ ∷ ↦⃖₃ ∷ ◾ lem : eval (! (c₁ ⊗ c₂)) (eval (c₁ ⊗ c₂) ((x , y) ⃖)) ≡ (x , y) ⃖ lem rewrite eval-toState₂ rs' = eval-toState₁ rs! !rev (c₁ ⊗ c₂) ((x , y) ⃖) refl | inj₂ ((y' , rsy) , _) = lem where rs' : [ c₁ ⊗ c₂ ∣ (x , y) ∣ ☐ ]◁ ↦* [ c₁ ⊗ c₂ ∣ (x , y') ∣ ☐ ]▷ rs' = ↦⃖₉ ∷ appendκ↦* rsy refl ([ c₁ , x ]⊗☐• ☐) ++↦ ↦⃗₉ ∷ ◾ rs! : ⟨ ! (c₁ ⊗ c₂) ∣ (x , y') ∣ ☐ ⟩▷ ↦* ⟨ ! (c₁ ⊗ c₂) ∣ (x , y) ∣ ☐ ⟩◁ rs! = (↦⃗₃ ∷ ↦⃗₁ ∷ ↦⃗₇ ∷ ↦⃗₃ ∷ ↦⃗₆ ∷ ◾) ++↦ appendκ↦* (getₜᵣ⃗ (! c₂) (!rev c₂ (y ⃖) (eval-toState₂ rsy))) refl (☐⊗[ ! c₁ , x ]• (☐⨾ swap⋆ • (swap⋆ ⨾☐• ☐))) ++↦ ↦⃖₆ ∷ ↦⃖₃ ∷ ↦⃖₇ ∷ ↦⃖₁ ∷ ↦⃖₃ ∷ ◾ lem : eval (! (c₁ ⊗ c₂)) (eval (c₁ ⊗ c₂) ((x , y) ⃖)) ≡ (x , y) ⃖ lem rewrite eval-toState₂ rs' = eval-toState₁ rs! !rev η₊ (inj₁ x ⃖) refl = refl !rev η₊ (inj₂ (- x) ⃖) refl = refl !rev ε₊ (inj₁ x ⃗) refl = refl !rev ε₊ (inj₂ (- x) ⃗) refl = refl private loop : ∀ {A B C x} {c₁ : A ↔ B} {c₂ : B ↔ C} (n : ℕ) → ∀ b → ((rs : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → ⟨ ! c₁ ∣ b ∣ ! c₂ ⨾☐• ☐ ⟩◁ ↦* (toState! (c₁ ⨾ c₂) x)) × ((rs : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → ⟨ ! c₁ ∣ b ∣ ! c₂ ⨾☐• ☐ ⟩▷ ↦* (toState! (c₁ ⨾ c₂) x)) loop {x = x} {c₁} {c₂} = <′-rec (λ n → _) loop-rec where loop-rec : (n : ℕ) → (∀ m → m <′ n → _) → _ loop-rec n R b = loop₁ , loop₂ where loop₁ : (rs : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → ⟨ ! c₁ ∣ b ∣ ! c₂ ⨾☐• ☐ ⟩◁ ↦* (toState! (c₁ ⨾ c₂) x) loop₁ rs refl with inspect⊎ (run ⟨ c₂ ∣ b ∣ ☐ ⟩▷) (λ ()) loop₁ rs refl | inj₁ ((b' , rsb) , eq) = rs!' ++↦ proj₂ (R (len↦ rs'') le b') rs'' refl where rs' : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* ⟨ c₂ ∣ b' ∣ c₁ ⨾☐• ☐ ⟩◁ rs' = ↦⃗₇ ∷ appendκ↦* rsb refl (c₁ ⨾☐• ☐) rs'' : ⟨ c₂ ∣ b' ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* toState (c₁ ⨾ c₂) x rs'' = proj₁ (deterministic*' rs' rs (is-stuck-toState _ _)) req : len↦ rs ≡ len↦ rs' + len↦ rs'' req = proj₂ (deterministic*' rs' rs (is-stuck-toState _ _)) le : len↦ rs'' <′ len↦ rs le = subst (λ x → len↦ rs'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) rs!' : ⟨ ! c₁ ∣ b ∣ ! c₂ ⨾☐• ☐ ⟩◁ ↦* ⟨ ! c₁ ∣ b' ∣ ! c₂ ⨾☐• ☐ ⟩▷ rs!' = ↦⃖₇ ∷ Rev* (appendκ↦* (getₜᵣ⃖ (! c₂) (!rev c₂ (b ⃗) (eval-toState₁ rsb))) refl (☐⨾ ! c₁ • ☐)) ++↦ ↦⃗₇ ∷ ◾ loop₁ rs refl | inj₂ ((c , rsb) , eq) = lem where rs' : [ c₁ ∣ b ∣ ☐⨾ c₂ • ☐ ]▷ ↦* [ c₁ ⨾ c₂ ∣ c ∣ ☐ ]▷ rs' = ↦⃗₇ ∷ appendκ↦* rsb refl (c₁ ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ rs!' : ⟨ ! c₁ ∣ b ∣ (! c₂) ⨾☐• ☐ ⟩◁ ↦* ⟨ ! c₂ ⨾ ! c₁ ∣ c ∣ ☐ ⟩◁ rs!' = ↦⃖₇ ∷ Rev* (appendκ↦* (getₜᵣ⃗ (! c₂) (!rev c₂ (b ⃗) (eval-toState₁ rsb))) refl (☐⨾ ! c₁ • ☐)) ++↦ ↦⃖₃ ∷ ◾ xeq : x ≡ c ⃗ xeq = toState≡₁ (deterministic* rs rs' (is-stuck-toState _ _) (λ ())) lem : ⟨ ! c₁ ∣ b ∣ (! c₂) ⨾☐• ☐ ⟩◁ ↦* (toState! (c₁ ⨾ c₂) x) lem rewrite xeq = rs!' loop₂ : (rs : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* toState (c₁ ⨾ c₂) x) → len↦ rs ≡ n → ⟨ ! c₁ ∣ b ∣ (! c₂) ⨾☐• ☐ ⟩▷ ↦* toState! (c₁ ⨾ c₂) x loop₂ rs refl with inspect⊎ (run [ c₁ ∣ b ∣ ☐ ]◁) (λ ()) loop₂ rs refl | inj₁ ((a , rsb) , eq) = lem where rs' : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* ⟨ c₁ ⨾ c₂ ∣ a ∣ ☐ ⟩◁ rs' = ↦⃖₇ ∷ appendκ↦* rsb refl (☐⨾ c₂ • ☐) ++↦ ↦⃖₃ ∷ ◾ rs!' : ⟨ ! c₁ ∣ b ∣ (! c₂) ⨾☐• ☐ ⟩▷ ↦* [ ! c₂ ⨾ ! c₁ ∣ a ∣ ☐ ]▷ rs!' = Rev* (appendκ↦* (getₜᵣ⃖ (! c₁) (!rev c₁ (b ⃖) (eval-toState₂ rsb))) refl (! c₂ ⨾☐• ☐)) ++↦ ↦⃗₁₀ ∷ ◾ xeq : x ≡ a ⃖ xeq = toState≡₂ (deterministic* rs rs' (is-stuck-toState _ _) (λ ())) lem : ⟨ ! c₁ ∣ b ∣ (! c₂) ⨾☐• ☐ ⟩▷ ↦* (toState! (c₁ ⨾ c₂) x) lem rewrite xeq = rs!' loop₂ rs refl | inj₂ ((b' , rsb) , eq) = rs!' ++↦ proj₁ (R (len↦ rs'') le b') rs'' refl where rs' : ⟨ c₂ ∣ b ∣ c₁ ⨾☐• ☐ ⟩◁ ↦* [ c₁ ∣ b' ∣ ☐⨾ c₂ • ☐ ]▷ rs' = ↦⃖₇ ∷ appendκ↦* rsb refl (☐⨾ c₂ • ☐) rs'' : [ c₁ ∣ b' ∣ ☐⨾ c₂ • ☐ ]▷ ↦* toState (c₁ ⨾ c₂) x rs'' = proj₁ (deterministic*' rs' rs (is-stuck-toState _ _)) req : len↦ rs ≡ len↦ rs' + len↦ rs'' req = proj₂ (deterministic*' rs' rs (is-stuck-toState _ _)) le : len↦ rs'' <′ len↦ rs le = subst (λ x → len↦ rs'' <′ x) (sym req) (s≤′s (n≤′m+n _ _)) rs!' : ⟨ ! c₁ ∣ b ∣ (! c₂) ⨾☐• ☐ ⟩▷ ↦* ⟨ ! c₁ ∣ b' ∣ ! c₂ ⨾☐• ☐ ⟩◁ rs!' = Rev* (appendκ↦* (getₜᵣ⃗ (! c₁) (!rev c₁ (b ⃖) (eval-toState₂ rsb))) refl (! c₂ ⨾☐• ☐)) pinv₁ : ∀ {A B} → (c : A ↔ B) → eval ((c ⨾ ! c) ⨾ c) ∼ eval c pinv₁ c (x ⃗) with inspect⊎ (run ⟨ c ∣ x ∣ ☐ ⟩▷) (λ ()) pinv₁ c (x ⃗) | inj₁ ((x' , rs) , eq) = trans (eval-toState₁ rs') (sym (eval-toState₁ rs)) where rs' : ⟨ (c ⨾ ! c) ⨾ c ∣ x ∣ ☐ ⟩▷ ↦* ⟨ (c ⨾ ! c) ⨾ c ∣ x' ∣ ☐ ⟩◁ rs' = (↦⃗₃ ∷ ↦⃗₃ ∷ ◾) ++↦ appendκ↦* rs refl (☐⨾(! c) • ☐⨾ c • ☐) ++↦ ↦⃖₃ ∷ ↦⃖₃ ∷ ◾ pinv₁ c (x ⃗) | inj₂ ((x' , rs) , eq) = trans (eval-toState₁ rs') (sym (eval-toState₁ rs)) where rs! : ⟨ ! c ∣ x' ∣ ☐ ⟩▷ ↦* [ ! c ∣ x ∣ ☐ ]▷ rs! = getₜᵣ⃗ _ (!rev c (x ⃗) (eval-toState₁ rs)) rs' : ⟨ (c ⨾ ! c) ⨾ c ∣ x ∣ ☐ ⟩▷ ↦* [ (c ⨾ ! c) ⨾ c ∣ x' ∣ ☐ ]▷ rs' = (↦⃗₃ ∷ ↦⃗₃ ∷ ◾) ++↦ appendκ↦* rs refl (☐⨾(! c) • ☐⨾ c • ☐) ++↦ (↦⃗₇ ∷ ◾) ++↦ appendκ↦* rs! refl (c ⨾☐• (☐⨾ c • ☐)) ++↦ (↦⃗₁₀ ∷ ↦⃗₇ ∷ ◾) ++↦ appendκ↦* rs refl ((c ⨾ ! c) ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ pinv₁ c (x ⃖) with inspect⊎ (run [ c ∣ x ∣ ☐ ]◁) (λ ()) pinv₁ c (x ⃖) | inj₁ ((x' , rs) , eq) = trans (eval-toState₂ rs') (sym (eval-toState₂ rs)) where rs! : [ ! c ∣ x' ∣ ☐ ]◁ ↦* ⟨ ! c ∣ x ∣ ☐ ⟩◁ rs! = getₜᵣ⃖ _ (!rev c (x ⃖) (eval-toState₂ rs)) rs' : [ (c ⨾ ! c) ⨾ c ∣ x ∣ ☐ ]◁ ↦* ⟨ (c ⨾ ! c) ⨾ c ∣ x' ∣ ☐ ⟩◁ rs' = ↦⃖₁₀ ∷ appendκ↦* rs refl ((c ⨾ ! c) ⨾☐• ☐) ++↦ (↦⃖₇ ∷ ↦⃖₁₀ ∷ ◾) ++↦ appendκ↦* rs! refl (c ⨾☐• (☐⨾ c • ☐)) ++↦ (↦⃖₇ ∷ ◾) ++↦ appendκ↦* rs refl (☐⨾(! c) • ☐⨾ c • ☐) ++↦ ↦⃖₃ ∷ ↦⃖₃ ∷ ◾ pinv₁ c (x ⃖) | inj₂ ((x' , rs) , eq) = trans (eval-toState₂ rs') (sym (eval-toState₂ rs)) where rs' : [ (c ⨾ ! c) ⨾ c ∣ x ∣ ☐ ]◁ ↦* [ (c ⨾ ! c) ⨾ c ∣ x' ∣ ☐ ]▷ rs' = ↦⃖₁₀ ∷ appendκ↦* rs refl ((c ⨾ ! c) ⨾☐• ☐) ++↦ ↦⃗₁₀ ∷ ◾ pinv₂ : ∀ {A B} → (c : A ↔ B) → eval ((! c ⨾ c) ⨾ ! c) ∼ eval (! c) pinv₂ c x = trans (∘-resp-≈ (λ z → refl) (∘-resp-≈ (!inv c) (λ z → refl)) x) (pinv₁ (! c) x) open Inverse public
{ "alphanum_fraction": 0.3830433546, "avg_line_length": 52.9876712329, "ext": "agda", "hexsha": "c381648ed330134a5f5eaa63f423b4477074b5b3", "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": "Pi-/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "Pi-/Properties.agda", "max_line_length": 180, "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": "Pi-/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 46270, "size": 77362 }
-- Andreas, 2020-11-16, issue #5055, reported by nad -- Internal error caused by record pattern on pattern synonym lhs -- (unreleased regression in 2.6.2). open import Agda.Builtin.Sigma data Shape : Set where c : Shape → Shape pattern p (s , v) = c s , v -- Should give some parse error or other controlled error. -- Illegal pattern synonym argument _ @ (s , v) -- (Arguments to pattern synonyms cannot be patterns themselves.) -- =<ERROR> -- c s , v
{ "alphanum_fraction": 0.694143167, "avg_line_length": 25.6111111111, "ext": "agda", "hexsha": "e2bab0fd5e54455ff1cd498a58e6fd1845586b3a", "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": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/Issue5055.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "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-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/Issue5055.agda", "max_line_length": 65, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/Issue5055.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": 127, "size": 461 }
{-# OPTIONS --cubical --safe #-} module Cubical.Relation.Nullary.DecidableEq where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Data.Empty open import Cubical.Relation.Nullary -- Proof of Hedberg's theorem: a type with decidable equality is an h-set Dec→Stable : ∀ {ℓ} (A : Type ℓ) → Dec A → Stable A Dec→Stable A (yes x) = λ _ → x Dec→Stable A (no x) = λ f → ⊥-elim (f x) Stable≡→isSet : ∀ {ℓ} {A : Type ℓ} → (st : ∀ (a b : A) → Stable (a ≡ b)) → isSet A Stable≡→isSet {A = A} st a b p q j i = let f : (x : A) → a ≡ x → a ≡ x f x p = st a x (λ h → h p) fIsConst : (x : A) → (p q : a ≡ x) → f x p ≡ f x q fIsConst = λ x p q i → st a x (isProp¬ _ (λ h → h p) (λ h → h q) i) rem : (p : a ≡ b) → PathP (λ i → a ≡ p i) (f a refl) (f b p) rem p j = f (p j) (λ i → p (i ∧ j)) in hcomp (λ k → λ { (i = i0) → f a refl k ; (i = i1) → fIsConst b p q j k ; (j = i0) → rem p i k ; (j = i1) → rem q i k }) a -- Hedberg's theorem Discrete→isSet : ∀ {ℓ} {A : Type ℓ} → Discrete A → isSet A Discrete→isSet d = Stable≡→isSet (λ x y → Dec→Stable (x ≡ y) (d x y))
{ "alphanum_fraction": 0.5208681135, "avg_line_length": 35.2352941176, "ext": "agda", "hexsha": "3e3778e7b18c0c607e9156e755df9180fac556b8", "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/Relation/Nullary/DecidableEq.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/Relation/Nullary/DecidableEq.agda", "max_line_length": 82, "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/Relation/Nullary/DecidableEq.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 489, "size": 1198 }
------------------------------------------------------------------------ -- A large(r) class of algebraic structures satisfies the property -- that isomorphic instances of a structure are equal (assuming -- univalence) ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} -- Note that this module uses ordinary propositional equality, with a -- computing J rule. -- This module has been developed in collaboration with Thierry -- Coquand. module Univalence-axiom.Isomorphism-is-equality.More where open import Equality.Propositional hiding (refl) renaming (equality-with-J to eq) open import Equality open Derived-definitions-and-properties eq using (refl) open import Bijection eq hiding (id; _∘_; inverse; step-↔; finally-↔) open import Equivalence eq as Eq hiding (id; _∘_; inverse) open import Function-universe eq hiding (id; _∘_) open import H-level eq as H-level hiding (Proposition) open import H-level.Closure eq open import Logical-equivalence using (_⇔_) open import Preimage eq open import Prelude as P hiding (Type) open import Univalence-axiom eq ------------------------------------------------------------------------ -- A record packing up certain assumptions -- Use of these or similar assumptions is usually not documented in -- comments below (with remarks like "assuming univalence"). record Assumptions : P.Type₂ where field ext₁ : Extensionality (# 1) (# 1) univ : Univalence (# 0) univ₁ : Univalence (# 1) abstract ext : Extensionality (# 0) (# 0) ext = lower-extensionality (# 1) (# 1) ext₁ ------------------------------------------------------------------------ -- A class of algebraic structures -- An algebraic structure universe. mutual -- Codes for structures. infixl 5 _▻_ data Code : P.Type₂ where ε : Code _▻_ : (c : Code) → Extension c → Code -- Structures can contain arbitrary "extensions". record Extension (c : Code) : P.Type₂ where field -- An instance-indexed type. Ext : ⟦ c ⟧ → P.Type₁ -- A predicate specifying when two elements are isomorphic with -- respect to an isomorphism. Iso : (ass : Assumptions) → {I J : ⟦ c ⟧} → Isomorphic ass c I J → Ext I → Ext J → P.Type₁ -- An alternative definition of Iso. Iso′ : (ass : Assumptions) → ∀ {I J} → Isomorphic ass c I J → Ext I → Ext J → P.Type₁ Iso′ ass I≅J x y = subst Ext (_≃_.to (isomorphism≃equality ass c) I≅J) x ≡ y field -- Iso and Iso′ are equivalent. Iso≃Iso′ : (ass : Assumptions) → ∀ {I J} (I≅J : Isomorphic ass c I J) {x y} → Iso ass I≅J x y ≃ Iso′ ass I≅J x y -- Interpretation of the codes. The elements of ⟦ c ⟧ are instances -- of the structure encoded by c. ⟦_⟧ : Code → P.Type₁ ⟦ ε ⟧ = ↑ _ ⊤ ⟦ c ▻ e ⟧ = Σ ⟦ c ⟧ (Extension.Ext e) -- Isomorphisms. Isomorphic : Assumptions → (c : Code) → ⟦ c ⟧ → ⟦ c ⟧ → P.Type₁ Isomorphic _ ε _ _ = ↑ _ ⊤ Isomorphic ass (c ▻ e) (I , x) (J , y) = Σ (Isomorphic ass c I J) λ I≅J → Extension.Iso e ass I≅J x y -- Isomorphism is equivalent to equality. isomorphism≃equality : (ass : Assumptions) → (c : Code) {I J : ⟦ c ⟧} → Isomorphic ass c I J ≃ (I ≡ J) isomorphism≃equality _ ε = ↑ _ ⊤ ↔⟨ contractible-isomorphic (↑-closure 0 ⊤-contractible) (⇒≡ 0 $ ↑-closure 0 ⊤-contractible) ⟩□ lift tt ≡ lift tt □ isomorphism≃equality ass (c ▻ e) {I , x} {J , y} = (Σ (Isomorphic ass c I J) λ I≅J → Iso e ass I≅J x y) ↝⟨ Σ-cong (isomorphism≃equality ass c) (λ I≅J → Iso≃Iso′ e ass I≅J) ⟩ (Σ (I ≡ J) λ I≡J → subst (Ext e) I≡J x ≡ y) ↔⟨ Σ-≡,≡↔≡ ⟩□ ((I , x) ≡ (J , y)) □ where open Extension -- Isomorphism is equal to equality (assuming /only/ univalence). isomorphism≡equality : (univ : Univalence (# 0)) (univ₁ : Univalence (# 1)) (univ₂ : Univalence (# 2)) → let ass = record { ext₁ = dependent-extensionality univ₂ univ₁ ; univ = univ ; univ₁ = univ₁ } in (c : Code) {I J : ⟦ c ⟧} → Isomorphic ass c I J ≡ (I ≡ J) isomorphism≡equality univ univ₁ univ₂ c = ≃⇒≡ univ₁ $ isomorphism≃equality _ c ------------------------------------------------------------------------ -- Reflexivity -- The isomorphism relation is reflexive. reflexivity : (ass : Assumptions) → ∀ c I → Isomorphic ass c I I reflexivity ass c I = _≃_.from (isomorphism≃equality ass c) (refl I) -- Reflexivity relates an element to itself. reflexivityE : (ass : Assumptions) → ∀ c e I x → Extension.Iso e ass (reflexivity ass c I) x x reflexivityE ass c e I x = _≃_.from (Iso≃Iso′ ass (reflexivity ass c I)) ( subst Ext (to (from (refl I))) x ≡⟨ subst (λ eq → subst Ext eq x ≡ x) (sym $ right-inverse-of (refl I)) (refl x) ⟩∎ x ∎) where open Extension e open _≃_ (isomorphism≃equality ass c) -- Unfolding lemma (definitional) for reflexivity. reflexivity-▻ : ∀ {ass c e I x} → reflexivity ass (c ▻ e) (I , x) ≡ (reflexivity ass c I , reflexivityE ass c e I x) reflexivity-▻ = refl _ ------------------------------------------------------------------------ -- Recipe for defining extensions -- Another kind of extension. record Extension-with-resp (c : Code) : P.Type₂ where field -- An instance-indexed type. Ext : ⟦ c ⟧ → P.Type₁ -- A predicate specifying when two elements are isomorphic with -- respect to an isomorphism. Iso : (ass : Assumptions) → {I J : ⟦ c ⟧} → Isomorphic ass c I J → Ext I → Ext J → P.Type₁ -- Ext, seen as a predicate, respects isomorphisms. resp : (ass : Assumptions) → ∀ {I J} → Isomorphic ass c I J → Ext I → Ext J -- The resp function respects reflexivity. resp-refl : (ass : Assumptions) → ∀ {I} (x : Ext I) → resp ass (reflexivity ass c I) x ≡ x -- An alternative definition of Iso. Iso″ : (ass : Assumptions) → {I J : ⟦ c ⟧} → Isomorphic ass c I J → Ext I → Ext J → P.Type₁ Iso″ ass I≅J x y = resp ass I≅J x ≡ y field -- Iso and Iso″ are equivalent. Iso≃Iso″ : (ass : Assumptions) → ∀ {I J} (I≅J : Isomorphic ass c I J) {x y} → Iso ass I≅J x y ≃ Iso″ ass I≅J x y -- Another alternative definition of Iso. Iso′ : (ass : Assumptions) → ∀ {I J} → Isomorphic ass c I J → Ext I → Ext J → P.Type₁ Iso′ ass I≅J x y = subst Ext (_≃_.to (isomorphism≃equality ass c) I≅J) x ≡ y abstract -- Every element is isomorphic to itself, transported along the -- "outer" isomorphism. isomorphic-to-itself″ : (ass : Assumptions) → ∀ {I J} (I≅J : Isomorphic ass c I J) {x} → Iso″ ass I≅J x (subst Ext (_≃_.to (isomorphism≃equality ass c) I≅J) x) isomorphic-to-itself″ ass I≅J {x} = transport-theorem′ Ext (Isomorphic ass c) (_≃_.surjection $ inverse $ isomorphism≃equality ass c) (resp ass) (λ _ → resp-refl ass) I≅J x -- Iso and Iso′ are equivalent. Iso≃Iso′ : (ass : Assumptions) → ∀ {I J} (I≅J : Isomorphic ass c I J) {x y} → Iso ass I≅J x y ≃ Iso′ ass I≅J x y Iso≃Iso′ ass I≅J {x} {y} = record { to = to ; is-equivalence = _⇔_.from (Is-equivalence≃Is-equivalence-CP _) λ y → (from y , right-inverse-of y) , irrelevance y } where -- This is the core of the definition. I could have defined -- Iso≃Iso′ ... = I≃I′. The rest is only included in order to -- control how much Agda unfolds the code. I≃I′ = Iso ass I≅J x y ↝⟨ Iso≃Iso″ ass I≅J ⟩ Iso″ ass I≅J x y ↝⟨ ≡⇒≃ $ cong (λ z → z ≡ y) $ isomorphic-to-itself″ ass I≅J ⟩□ Iso′ ass I≅J x y □ to = _≃_.to I≃I′ from = _≃_.from I≃I′ abstract right-inverse-of : ∀ x → to (from x) ≡ x right-inverse-of = _≃_.right-inverse-of I≃I′ irrelevance : ∀ y (p : to ⁻¹ y) → (from y , right-inverse-of y) ≡ p irrelevance = _≃_.irrelevance I≃I′ -- An extension constructed from the fields above. extension : Extension c extension = record { Ext = Ext; Iso = Iso; Iso≃Iso′ = Iso≃Iso′ } -- Every element is isomorphic to itself, transported (in another -- way) along the "outer" isomorphism. isomorphic-to-itself : (ass : Assumptions) → ∀ {I J} (I≅J : Isomorphic ass c I J) x → Iso ass I≅J x (resp ass I≅J x) isomorphic-to-itself ass I≅J x = _≃_.from (Iso≃Iso″ ass I≅J) (refl (resp ass I≅J x)) abstract -- Simplification lemmas. resp-refl-lemma : (ass : Assumptions) → ∀ I x → resp-refl ass x ≡ _≃_.from (≡⇒≃ $ cong (λ z → z ≡ x) $ isomorphic-to-itself″ ass (reflexivity ass c I)) (subst (λ eq → subst Ext eq x ≡ x) (sym $ _≃_.right-inverse-of (isomorphism≃equality ass c) (refl I)) (refl x)) resp-refl-lemma ass I x = let rfl = reflexivity ass c I iso≃eq = λ {I J} → isomorphism≃equality ass c {I = I} {J = J} rio = right-inverse-of iso≃eq (refl I) lio = left-inverse-of (inverse iso≃eq) (refl I) sx≡x = subst (λ eq → subst Ext eq x ≡ x) (sym rio) (refl x) sx≡x-lemma = cong (λ eq → subst Ext eq x) rio ≡⟨ sym $ trans-reflʳ _ ⟩ trans (cong (λ eq → subst Ext eq x) rio) (refl x) ≡⟨ sym $ subst-trans (cong (λ eq → subst Ext eq x) rio) ⟩ subst (λ z → z ≡ x) (sym $ cong (λ eq → subst Ext eq x) rio) (refl x) ≡⟨ cong (λ eq → subst (λ z → z ≡ x) eq (refl x)) $ sym $ cong-sym (λ eq → subst Ext eq x) rio ⟩ subst (λ z → z ≡ x) (cong (λ eq → subst Ext eq x) $ sym rio) (refl x) ≡⟨ sym $ subst-∘ (λ z → z ≡ x) (λ eq → subst Ext eq x) (sym rio) ⟩∎ subst (λ eq → subst Ext eq x ≡ x) (sym rio) (refl x) ∎ lemma₁ = trans (sym lio) rio ≡⟨ cong (λ eq → trans (sym eq) rio) $ left-inverse-of∘inverse iso≃eq ⟩ trans (sym rio) rio ≡⟨ trans-symˡ rio ⟩∎ refl (refl I) ∎ lemma₂ = elim-refl (λ {I J} _ → Ext I → Ext J) (λ _ e → e) ≡⟨⟩ cong (subst Ext) (refl (refl I)) ≡⟨ cong (cong (subst Ext)) $ sym lemma₁ ⟩∎ cong (subst Ext) (trans (sym lio) rio) ∎ lemma₃ = cong (λ r → r x) (elim-refl (λ {I J} _ → Ext I → Ext J) (λ _ e → e)) ≡⟨ cong (cong (λ r → r x)) lemma₂ ⟩ cong (λ r → r x) (cong (subst Ext) (trans (sym lio) rio)) ≡⟨ cong-∘ (λ r → r x) (subst Ext) (trans (sym lio) rio) ⟩ cong (λ eq → subst Ext eq x) (trans (sym lio) rio) ≡⟨ cong-trans (λ eq → subst Ext eq x) (sym lio) rio ⟩ trans (cong (λ eq → subst Ext eq x) (sym lio)) (cong (λ eq → subst Ext eq x) rio) ≡⟨ cong (λ eq → trans eq (cong (λ eq → subst Ext eq x) rio)) $ cong-sym (λ eq → subst Ext eq x) lio ⟩∎ trans (sym (cong (λ eq → subst Ext eq x) lio)) (cong (λ eq → subst Ext eq x) rio) ∎ in resp-refl ass x ≡⟨ sym $ trans-reflʳ _ ⟩ trans (resp-refl ass x) (refl x) ≡⟨ cong (trans (resp-refl ass x)) $ trans-symˡ (subst-refl Ext x) ⟩ trans (resp-refl ass x) (trans (sym $ subst-refl Ext x) (subst-refl Ext x)) ≡⟨ sym $ trans-assoc _ (sym $ subst-refl Ext x) (subst-refl Ext x) ⟩ trans (trans (resp-refl ass x) (sym $ subst-refl Ext x)) (subst-refl Ext x) ≡⟨ cong (trans (trans (resp-refl ass x) (sym $ subst-refl Ext x))) lemma₃ ⟩ trans (trans (resp-refl ass x) (sym $ subst-refl Ext x)) (trans (sym (cong (λ eq → subst Ext eq x) lio)) (cong (λ eq → subst Ext eq x) rio)) ≡⟨ sym $ trans-assoc _ _ (cong (λ eq → subst Ext eq x) rio) ⟩ trans (trans (trans (resp-refl ass x) (sym $ subst-refl Ext x)) (sym (cong (λ eq → subst Ext eq x) lio))) (cong (λ eq → subst Ext eq x) rio) ≡⟨ cong₂ trans (sym $ transport-theorem′-refl Ext (Isomorphic ass c) (inverse iso≃eq) (resp ass) (λ _ → resp-refl ass) x) sx≡x-lemma ⟩ trans (isomorphic-to-itself″ ass rfl) sx≡x ≡⟨ sym $ subst-trans (isomorphic-to-itself″ ass rfl) ⟩ subst (λ z → z ≡ x) (sym $ isomorphic-to-itself″ ass rfl) sx≡x ≡⟨ subst-in-terms-of-inverse∘≡⇒↝ equivalence (isomorphic-to-itself″ ass rfl) (λ z → z ≡ x) _ ⟩∎ from (≡⇒≃ $ cong (λ z → z ≡ x) $ isomorphic-to-itself″ ass rfl) sx≡x ∎ where open _≃_ isomorphic-to-itself-reflexivity : (ass : Assumptions) → ∀ I x → isomorphic-to-itself ass (reflexivity ass c I) x ≡ subst (Iso ass (reflexivity ass c I) x) (sym $ resp-refl ass x) (reflexivityE ass c extension I x) isomorphic-to-itself-reflexivity ass I x = let rfl = reflexivity ass c I r-r = resp-refl ass x in from (Iso≃Iso″ ass rfl) (refl (resp ass rfl x)) ≡⟨ elim¹ (λ {y} resp-x≡y → from (Iso≃Iso″ ass rfl) (refl (resp ass rfl x)) ≡ subst (Iso ass rfl x) (sym resp-x≡y) (from (Iso≃Iso″ ass rfl) resp-x≡y)) (refl _) r-r ⟩ subst (Iso ass rfl x) (sym r-r) (from (Iso≃Iso″ ass rfl) r-r) ≡⟨ cong (subst (Iso ass rfl x) (sym r-r) ∘ from (Iso≃Iso″ ass rfl)) (resp-refl-lemma ass I x) ⟩∎ subst (Iso ass rfl x) (sym r-r) (from (Iso≃Iso″ ass rfl) (from (≡⇒≃ $ cong (λ z → z ≡ x) (isomorphic-to-itself″ ass rfl)) (subst (λ eq → subst Ext eq x ≡ x) (sym $ right-inverse-of (isomorphism≃equality ass c) (refl I)) (refl x)))) ∎ where open _≃_ ------------------------------------------------------------------------ -- Type extractors record Extractor (c : Code) : P.Type₂ where field -- Extracts a type from an instance. Type : ⟦ c ⟧ → P.Type₁ -- Extracts an equivalence relating types extracted from -- isomorphic instances. -- -- Perhaps one could have a variant of Type-cong that is not based -- on any "Assumptions", and produces logical equivalences (_⇔_) -- instead of equivalences (_≃_). Then one could (hopefully) -- define isomorphism without using any assumptions. Type-cong : (ass : Assumptions) → ∀ {I J} → Isomorphic ass c I J → Type I ≃ Type J -- Reflexivity is mapped to the identity equivalence. Type-cong-reflexivity : (ass : Assumptions) → ∀ I → Type-cong ass (reflexivity ass c I) ≡ Eq.id -- Constant type extractor. [_] : ∀ {c} → P.Type₁ → Extractor c [_] {c} A = record { Type = λ _ → A ; Type-cong = λ _ _ → Eq.id ; Type-cong-reflexivity = λ _ _ → refl _ } -- Successor type extractor. infix 6 1+_ 1+_ : ∀ {c e} → Extractor c → Extractor (c ▻ e) 1+_ {c} {e} extractor = record { Type = Type ∘ proj₁ ; Type-cong = λ ass → Type-cong ass ∘ proj₁ ; Type-cong-reflexivity = λ { ass (I , x) → Type-cong ass (reflexivity ass c I) ≡⟨ Type-cong-reflexivity ass I ⟩∎ Eq.id ∎ } } where open Extractor extractor ------------------------------------------------------------------------ -- An extension: types -- Extends a structure with a type. A-type : ∀ {c} → Extension c A-type {c} = record { Ext = λ _ → P.Type ; Iso = λ _ _ A B → ↑ _ (A ≃ B) ; Iso≃Iso′ = λ ass I≅J {A B} → let I≡J = _≃_.to (isomorphism≃equality ass c) I≅J in ↑ _ (A ≃ B) ↔⟨ ↑↔ ⟩ (A ≃ B) ↝⟨ inverse $ ≡≃≃ (Assumptions.univ ass) ⟩ (A ≡ B) ↝⟨ ≡⇒≃ $ cong (λ C → C ≡ B) $ sym (subst-const I≡J) ⟩ (subst (λ _ → P.Type) I≡J A ≡ B) □ } -- A corresponding type extractor. [0] : ∀ {c} → Extractor (c ▻ A-type) [0] {c} = record { Type = λ { (_ , A) → ↑ _ A } ; Type-cong = λ { _ (_ , lift A≃B) → ↑-cong A≃B } ; Type-cong-reflexivity = λ { ass (I , A) → elim₁ (λ {p} q → ↑-cong (≡⇒≃ (from (≡⇒≃ (cong (λ C → C ≡ A) (sym (subst-const p)))) (subst (λ eq → subst Ext eq A ≡ A) (sym q) (refl A)))) ≡ Eq.id) (lift-equality (Assumptions.ext₁ ass) (refl _)) (right-inverse-of (isomorphism≃equality ass c) (refl I)) } } where open Extension A-type open _≃_ ------------------------------------------------------------------------ -- An extension: propositions -- Extends a structure with a proposition. Proposition : ∀ {c} → -- The proposition. (P : ⟦ c ⟧ → P.Type₁) → -- The proposition must be propositional (given some -- assumptions). (Assumptions → ∀ I → Is-proposition (P I)) → Extension c Proposition {c} P prop = record { Ext = P ; Iso = λ _ _ _ _ → ↑ _ ⊤ ; Iso≃Iso′ = λ ass I≅J {_ p} → ↑ _ ⊤ ↔⟨ contractible-isomorphic (↑-closure 0 ⊤-contractible) (⇒≡ 0 $ propositional⇒inhabited⇒contractible (prop ass _) p) ⟩□ (_ ≡ _) □ } -- The proposition stating that a given type is a set. Is-a-set : ∀ {c} → Extractor c → Extension c Is-a-set extractor = Proposition (Is-set ∘ Type) (λ ass _ → H-level-propositional (Assumptions.ext₁ ass) 2) where open Extractor extractor ------------------------------------------------------------------------ -- An extension: n-ary functions -- N-ary functions. _^_⟶_ : P.Type₁ → ℕ → P.Type₁ → P.Type₁ A ^ zero ⟶ B = B A ^ suc n ⟶ B = A → A ^ n ⟶ B -- N-ary function morphisms. Is-_-ary-morphism : ∀ (n : ℕ) {A B} → (A ^ n ⟶ A) → (B ^ n ⟶ B) → (A → B) → P.Type₁ Is- zero -ary-morphism x y m = m x ≡ y Is- suc n -ary-morphism f g m = ∀ x → Is- n -ary-morphism (f x) (g (m x)) m -- An n-ary function extension. N-ary : ∀ {c} → -- Extracts the underlying type. Extractor c → -- The function's arity. ℕ → Extension c N-ary {c} extractor n = Extension-with-resp.extension record { Ext = λ I → Type I ^ n ⟶ Type I ; Iso = λ ass I≅J f g → Is- n -ary-morphism f g (_≃_.to (Type-cong ass I≅J)) ; resp = λ ass I≅J → cast n (Type-cong ass I≅J) ; resp-refl = λ ass f → cast n (Type-cong ass (reflexivity ass c _)) f ≡⟨ cong (λ eq → cast n eq f) $ Type-cong-reflexivity ass _ ⟩ cast n Eq.id f ≡⟨ cast-id (Assumptions.ext₁ ass) n f ⟩∎ f ∎ ; Iso≃Iso″ = λ ass I≅J {f g} → Iso≃Iso″ (Assumptions.ext₁ ass) (Type-cong ass I≅J) n f g } where open Extractor extractor -- Changes the type of an n-ary function. cast : ∀ n {A B} → A ≃ B → A ^ n ⟶ A → B ^ n ⟶ B cast zero A≃B = _≃_.to A≃B cast (suc n) A≃B = λ f x → cast n A≃B (f (_≃_.from A≃B x)) -- Cast simplification lemma. cast-id : Extensionality (# 1) (# 1) → ∀ {A} n (f : A ^ n ⟶ A) → cast n Eq.id f ≡ f cast-id ext zero x = refl x cast-id ext (suc n) f = apply-ext ext λ x → cast-id ext n (f x) -- Two definitions of isomorphism are equivalent. Iso≃Iso″ : Extensionality (# 1) (# 1) → ∀ {A B} (A≃B : A ≃ B) (n : ℕ) (f : A ^ n ⟶ A) (g : B ^ n ⟶ B) → Is- n -ary-morphism f g (_≃_.to A≃B) ≃ (cast n A≃B f ≡ g) Iso≃Iso″ ext A≃B zero x y = (_≃_.to A≃B x ≡ y) □ Iso≃Iso″ ext A≃B (suc n) f g = (∀ x → Is- n -ary-morphism (f x) (g (_≃_.to A≃B x)) (_≃_.to A≃B)) ↝⟨ ∀-cong ext (λ x → Iso≃Iso″ ext A≃B n (f x) (g (_≃_.to A≃B x))) ⟩ (∀ x → cast n A≃B (f x) ≡ g (_≃_.to A≃B x)) ↝⟨ Eq.extensionality-isomorphism ext ⟩ (cast n A≃B ∘ f ≡ g ∘ _≃_.to A≃B) ↔⟨ inverse $ ∘from≡↔≡∘to ext A≃B ⟩□ (cast n A≃B ∘ f ∘ _≃_.from A≃B ≡ g) □ ------------------------------------------------------------------------ -- An extension: simply typed functions -- This section contains a generalisation of the development for n-ary -- functions above. -- Simple types. data Simple-type (c : Code) : P.Type₂ where base : Extractor c → Simple-type c _⟶_ : Simple-type c → Simple-type c → Simple-type c -- Interpretation of a simple type. ⟦_⟧⟶ : ∀ {c} → Simple-type c → ⟦ c ⟧ → P.Type₁ ⟦ base A ⟧⟶ I = Extractor.Type A I ⟦ σ ⟶ τ ⟧⟶ I = ⟦ σ ⟧⟶ I → ⟦ τ ⟧⟶ I -- A simply typed function extension. Simple : ∀ {c} → Simple-type c → Extension c Simple {c} σ = Extension-with-resp.extension record { Ext = ⟦ σ ⟧⟶ ; Iso = λ ass → Iso ass σ ; resp = λ ass I≅J → _≃_.to (cast ass σ I≅J) ; resp-refl = λ ass f → cong (λ eq → _≃_.to eq f) $ cast-refl ass σ ; Iso≃Iso″ = λ ass → Iso≃Iso″ ass σ } where open Extractor -- Isomorphisms between simply typed values. Iso : (ass : Assumptions) → (σ : Simple-type c) → ∀ {I J} → Isomorphic ass c I J → ⟦ σ ⟧⟶ I → ⟦ σ ⟧⟶ J → P.Type₁ Iso ass (base A) I≅J x y = _≃_.to (Type-cong A ass I≅J) x ≡ y Iso ass (σ ⟶ τ) I≅J f g = ∀ x y → Iso ass σ I≅J x y → Iso ass τ I≅J (f x) (g y) -- Cast. cast : (ass : Assumptions) → (σ : Simple-type c) → ∀ {I J} → Isomorphic ass c I J → ⟦ σ ⟧⟶ I ≃ ⟦ σ ⟧⟶ J cast ass (base A) I≅J = Type-cong A ass I≅J cast ass (σ ⟶ τ) I≅J = →-cong ext₁ (cast ass σ I≅J) (cast ass τ I≅J) where open Assumptions ass -- Cast simplification lemma. cast-refl : (ass : Assumptions) → ∀ σ {I} → cast ass σ (reflexivity ass c I) ≡ Eq.id cast-refl ass (base A) {I} = Type-cong A ass (reflexivity ass c I) ≡⟨ Type-cong-reflexivity A ass I ⟩∎ Eq.id ∎ cast-refl ass (σ ⟶ τ) {I} = cast ass (σ ⟶ τ) (reflexivity ass c I) ≡⟨ lift-equality ext₁ $ cong _≃_.to $ cong₂ (→-cong ext₁) (cast-refl ass σ) (cast-refl ass τ) ⟩∎ Eq.id ∎ where open Assumptions ass -- Two definitions of isomorphism are equivalent. Iso≃Iso″ : (ass : Assumptions) → (σ : Simple-type c) → ∀ {I J} (I≅J : Isomorphic ass c I J) {f g} → Iso ass σ I≅J f g ≃ (_≃_.to (cast ass σ I≅J) f ≡ g) Iso≃Iso″ ass (base A) I≅J {x} {y} = (_≃_.to (Type-cong A ass I≅J) x ≡ y) □ Iso≃Iso″ ass (σ ⟶ τ) I≅J {f} {g} = (∀ x y → Iso ass σ I≅J x y → Iso ass τ I≅J (f x) (g y)) ↝⟨ ∀-cong ext₁ (λ _ → ∀-cong ext₁ λ _ → →-cong ext₁ (Iso≃Iso″ ass σ I≅J) (Iso≃Iso″ ass τ I≅J)) ⟩ (∀ x y → to (cast ass σ I≅J) x ≡ y → to (cast ass τ I≅J) (f x) ≡ g y) ↝⟨ inverse $ ∀-cong ext₁ (λ x → ∀-intro (λ y _ → to (cast ass τ I≅J) (f x) ≡ g y) ext₁) ⟩ (∀ x → to (cast ass τ I≅J) (f x) ≡ g (to (cast ass σ I≅J) x)) ↝⟨ extensionality-isomorphism ext₁ ⟩ (to (cast ass τ I≅J) ∘ f ≡ g ∘ to (cast ass σ I≅J)) ↔⟨ inverse $ ∘from≡↔≡∘to ext₁ (cast ass σ I≅J) ⟩□ (to (cast ass τ I≅J) ∘ f ∘ from (cast ass σ I≅J) ≡ g) □ where open _≃_ open Assumptions ass ------------------------------------------------------------------------ -- An unfinished extension: dependent types -- The extension currently supports polymorphic types. module Dependent where open Extractor ---------------------------------------------------------------------- -- The extension -- Dependent types. data Ty (c : Code) : P.Type₂ -- Extension: Dependently-typed functions. ext-with-resp : ∀ {c} → Ty c → Extension-with-resp c private open module E {c} (σ : Ty c) = Extension-with-resp (ext-with-resp σ) hiding (Iso; Iso≃Iso″; extension) open E public using () renaming (extension to Dep) data Ty c where set : Ty c base : Extractor c → Ty c Π : (σ : Ty c) → Ty (c ▻ Dep σ) → Ty c -- Interpretation of a dependent type. ⟦_⟧Π : ∀ {c} → Ty c → ⟦ c ⟧ → P.Type₁ -- Isomorphisms between dependently typed functions. Iso : (ass : Assumptions) → ∀ {c} (σ : Ty c) → ∀ {I J} → Isomorphic ass c I J → ⟦ σ ⟧Π I → ⟦ σ ⟧Π J → P.Type₁ -- A cast function. cast : (ass : Assumptions) → ∀ {c} (σ : Ty c) {I J} → Isomorphic ass c I J → ⟦ σ ⟧Π I ≃ ⟦ σ ⟧Π J -- Reflexivity is mapped to identity. cast-refl : (ass : Assumptions) → ∀ {c} (σ : Ty c) {I} → cast ass σ (reflexivity ass c I) ≡ Eq.id -- Two definitions of isomorphism are equivalent. Iso≃Iso″ : (ass : Assumptions) → ∀ {c} (σ : Ty c) {I J} (I≅J : Isomorphic ass c I J) {f g} → Iso ass σ I≅J f g ≃ (_≃_.to (cast ass σ I≅J) f ≡ g) -- Extension: Dependently-typed functions. ext-with-resp {c} σ = record { Ext = ⟦ σ ⟧Π ; Iso = λ ass → Iso ass σ ; resp = λ ass I≅J → _≃_.to (cast ass σ I≅J) ; resp-refl = λ ass f → cong (λ eq → _≃_.to eq f) $ cast-refl ass σ ; Iso≃Iso″ = λ ass → Iso≃Iso″ ass σ } -- Interpretation of a dependent type. ⟦ set ⟧Π _ = P.Type ⟦ base A ⟧Π I = Type A I ⟦ Π σ τ ⟧Π I = (x : ⟦ σ ⟧Π I) → ⟦ τ ⟧Π (I , x) -- Isomorphisms between dependently typed functions. Iso _ set _ A B = ↑ _ (A ≃ B) Iso ass (base A) I≅J x y = x ≡ _≃_.from (Type-cong A ass I≅J) y Iso ass (Π σ τ) I≅J f g = ∀ x y → (x≅y : Iso ass σ I≅J x y) → Iso ass τ (I≅J , x≅y) (f x) (g y) -- A cast function. cast ass set I≅J = Eq.id cast ass (base A) I≅J = Type-cong A ass I≅J cast ass (Π σ τ) I≅J = Π-cong ext₁ (cast ass σ I≅J) (λ x → cast ass τ (I≅J , isomorphic-to-itself σ ass I≅J x)) where open Assumptions ass abstract -- Reflexivity is mapped to identity. cast-refl ass set = refl Eq.id cast-refl ass {c} (base A) {I} = Type-cong A ass (reflexivity ass c I) ≡⟨ Type-cong-reflexivity A ass I ⟩∎ Eq.id ∎ cast-refl ass {c} (Π σ τ) {I} = let rfl = reflexivity ass c I rflE = reflexivityE ass c (Dep σ) I in lift-equality-inverse ext₁ $ apply-ext ext₁ λ f → apply-ext ext₁ λ x → from (cast ass τ (rfl , isomorphic-to-itself σ ass rfl x)) (f (resp σ ass rfl x)) ≡⟨ cong (λ iso → from (cast ass τ (rfl , iso)) (f (resp σ ass rfl x))) $ isomorphic-to-itself-reflexivity σ ass I x ⟩ from (cast ass τ (rfl , subst (Iso ass σ rfl x) (sym $ resp-refl σ ass x) (rflE x))) (f (resp σ ass rfl x)) ≡⟨ elim¹ (λ {y} x≡y → from (cast ass τ (rfl , subst (Iso ass σ rfl x) x≡y (rflE x))) (f y) ≡ f x) (cong (λ h → _≃_.from h (f x)) $ cast-refl ass τ) (sym $ resp-refl σ ass x) ⟩∎ f x ∎ where open _≃_ open Assumptions ass -- Two definitions of isomorphism are equivalent. Iso≃Iso‴ : (ass : Assumptions) → ∀ {c} (σ : Ty c) {I J} (I≅J : Isomorphic ass c I J) {f g} → Iso ass σ I≅J f g ≃ (f ≡ _≃_.from (cast ass σ I≅J) g) Iso≃Iso‴ ass set I≅J {A} {B} = ↑ _ (A ≃ B) ↔⟨ ↑↔ ⟩ (A ≃ B) ↝⟨ inverse $ ≡≃≃ (Assumptions.univ ass) ⟩□ (A ≡ B) □ Iso≃Iso‴ ass (base A) I≅J {x} {y} = (x ≡ _≃_.from (Type-cong A ass I≅J) y) □ Iso≃Iso‴ ass (Π σ τ) I≅J {f} {g} = let iso-to-itself = isomorphic-to-itself σ ass I≅J in (∀ x y (x≅y : Iso ass σ I≅J x y) → Iso ass τ (I≅J , x≅y) (f x) (g y)) ↝⟨ ∀-cong ext₁ (λ x → ∀-cong ext₁ λ y → Π-cong ext₁ (Iso≃Iso″ ass σ I≅J) (λ x≅y → Iso ass τ (I≅J , x≅y) (f x) (g y) ↝⟨ Iso≃Iso″ ass τ (I≅J , x≅y) ⟩ (resp τ ass (I≅J , x≅y) (f x) ≡ g y) ↝⟨ ≡⇒≃ $ cong (λ x≅y → resp τ ass (I≅J , x≅y) (f x) ≡ g y) $ sym $ left-inverse-of (Iso≃Iso″ ass σ I≅J) _ ⟩□ (resp τ ass (I≅J , from (Iso≃Iso″ ass σ I≅J) (to (Iso≃Iso″ ass σ I≅J) x≅y)) (f x) ≡ g y) □)) ⟩ (∀ x y (x≡y : to (cast ass σ I≅J) x ≡ y) → resp τ ass (I≅J , from (Iso≃Iso″ ass σ I≅J) x≡y) (f x) ≡ g y) ↝⟨ ∀-cong ext₁ (λ x → inverse $ ∀-intro (λ y x≡y → _ ≡ _) ext₁) ⟩ (∀ x → resp τ ass (I≅J , iso-to-itself x) (f x) ≡ g (resp σ ass I≅J x)) ↔⟨ extensionality-isomorphism ext₁ ⟩ (resp τ ass (I≅J , iso-to-itself _) ∘ f ≡ g ∘ resp σ ass I≅J) ↔⟨ to∘≡↔≡from∘ ext₁ (cast ass τ (I≅J , iso-to-itself _)) ⟩ (f ≡ from (cast ass τ (I≅J , iso-to-itself _)) ∘ g ∘ resp σ ass I≅J) □ where open _≃_ open Assumptions ass abstract -- Two definitions of isomorphism are equivalent. Iso≃Iso″ ass σ I≅J {f} {g} = Iso ass σ I≅J f g ↝⟨ Iso≃Iso‴ ass σ I≅J ⟩ (f ≡ _≃_.from (cast ass σ I≅J) g) ↔⟨ inverse $ from≡↔≡to (inverse $ cast ass σ I≅J) ⟩□ (_≃_.to (cast ass σ I≅J) f ≡ g) □ ---------------------------------------------------------------------- -- An instantiation of the type extractor mechanism that gives us -- support for polymorphic types abstract reflexivityE-set : (ass : Assumptions) → ∀ {c} {I : ⟦ c ⟧} {A} → reflexivityE ass c (Dep set) I A ≡ lift Eq.id reflexivityE-set ass {c} {I} {A} = let ≡⇒→′ = _↔_.to ∘ ≡⇒↝ _ in reflexivityE ass c (Dep set) I A ≡⟨⟩ lift (≡⇒≃ (to (from≡↔≡to (inverse Eq.id)) (from (≡⇒≃ $ cong (λ B → B ≡ A) $ isomorphic-to-itself″ set ass (reflexivity ass c I)) (subst (λ eq → subst (λ _ → P.Type) eq A ≡ A) (sym $ right-inverse-of (isomorphism≃equality ass c) (refl I)) (refl A))))) ≡⟨ cong (λ eq → lift (≡⇒≃ (to (from≡↔≡to (inverse Eq.id)) eq))) $ sym $ resp-refl-lemma set ass I A ⟩ lift (≡⇒≃ (to (from≡↔≡to (inverse Eq.id)) (resp-refl set ass {I = I} A))) ≡⟨⟩ lift (≡⇒≃ (to (from≡↔≡to (inverse Eq.id)) (refl A))) ≡⟨⟩ lift (≡⇒≃ (≡⇒→′ (cong (λ B → B ≡ A) (right-inverse-of (inverse Eq.id) A)) (cong id (refl A)))) ≡⟨⟩ lift (≡⇒≃ (≡⇒→′ (cong (λ B → B ≡ A) (left-inverse-of Eq.id A)) (cong id (refl A)))) ≡⟨ cong (λ eq → lift (≡⇒≃ (≡⇒→′ (cong (λ B → B ≡ A) eq) (refl A)))) left-inverse-of-id ⟩ lift (≡⇒≃ (≡⇒→′ (cong (λ B → B ≡ A) (refl A)) (refl A))) ≡⟨⟩ lift (≡⇒≃ (≡⇒→′ (refl (A ≡ A)) (refl A))) ≡⟨⟩ lift (≡⇒≃ (refl A)) ≡⟨ refl _ ⟩∎ lift Eq.id ∎ where open _↔_ using (to) open _≃_ hiding (to) ⟨0⟩ : ∀ {c} → Extractor (c ▻ Dep set) ⟨0⟩ {c} = record { Type = λ { (_ , A) → ↑ _ A } ; Type-cong = λ { _ (_ , lift A≃B) → ↑-cong A≃B } ; Type-cong-reflexivity = λ { ass (I , A) → let open Assumptions ass; open _≃_ in lift-equality ext₁ (apply-ext ext₁ λ { (lift x) → cong lift ( to (lower (reflexivityE ass c (Dep set) I A)) x ≡⟨ cong (λ eq → to (lower eq) x) $ reflexivityE-set ass ⟩∎ x ∎ )})} } ------------------------------------------------------------------------ -- Examples -- For examples, see -- Univalence-axiom.Isomorphism-is-equality.More.Examples.
{ "alphanum_fraction": 0.44720232, "avg_line_length": 36.0368852459, "ext": "agda", "hexsha": "793ac4dfd4475c38a46ccc329a1f47c968b3238b", "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/More.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/More.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/More.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": 11544, "size": 35172 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.CoHSpace open import homotopy.Cogroup module groups.FromSusp where module _ {i} (X : Ptd i) where private A = de⊙ X e = pt X module Pinch = SuspRec (winl north) (winr south) (λ a → ap winl (σloop X a) ∙ wglue ∙ ap winr (merid a)) pinch : Susp A → ⊙Susp X ∨ ⊙Susp X pinch = Pinch.f ⊙pinch : ⊙Susp X ⊙→ ⊙Susp X ⊙∨ ⊙Susp X ⊙pinch = pinch , idp private abstract unit-r : ∀ x → projl (pinch x) == x unit-r = Susp-elim idp (merid e) λ x → ↓-∘=idf-in' projl pinch $ ap projl (ap pinch (merid x)) ∙' merid e =⟨ ∙'=∙ (ap projl (ap pinch (merid x))) (merid e) ⟩ ap projl (ap pinch (merid x)) ∙ merid e =⟨ ap (_∙ merid e) $ ap projl (ap pinch (merid x)) =⟨ ap (ap projl) $ Pinch.merid-β x ⟩ ap projl (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x)) =⟨ ap-∙∙ projl (ap winl (σloop X x)) wglue (ap winr (merid x)) ⟩ ap projl (ap winl (σloop X x)) ∙ ap projl wglue ∙ ap projl (ap winr (merid x)) =⟨ ap3 (λ p q r → p ∙ q ∙ r) (∘-ap projl winl (σloop X x) ∙ ap-idf (σloop X x)) Projl.glue-β (∘-ap projl winr (merid x) ∙ ap-cst north (merid x)) ⟩ σloop X x ∙ idp =⟨ ∙-unit-r (σloop X x) ⟩ σloop X x =∎ ⟩ σloop X x ∙ merid e =⟨ ∙-assoc (merid x) (! (merid e)) (merid e) ⟩ merid x ∙ ! (merid e) ∙ merid e =⟨ ap (merid x ∙_) (!-inv-l (merid e)) ∙ ∙-unit-r (merid x) ⟩ merid x =∎ ⊙unit-r : ⊙projl ⊙∘ ⊙pinch ⊙∼ ⊙idf (⊙Susp X) ⊙unit-r = unit-r , idp unit-l : ∀ x → projr (pinch x) == x unit-l = Susp-elim idp idp λ x → ↓-∘=idf-in' projr pinch $ ap projr (ap pinch (merid x)) =⟨ ap (ap projr) $ Pinch.merid-β x ⟩ ap projr (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x)) =⟨ ap-∙∙ projr (ap winl (σloop X x)) wglue (ap winr (merid x)) ⟩ ap projr (ap winl (σloop X x)) ∙ ap projr wglue ∙ ap projr (ap winr (merid x)) =⟨ ap3 (λ p q r → p ∙ q ∙ r) (∘-ap projr winl (σloop X x) ∙ ap-cst north (σloop X x)) Projr.glue-β (∘-ap projr winr (merid x) ∙ ap-idf (merid x)) ⟩ merid x =∎ ⊙unit-l : ⊙projr ⊙∘ ⊙pinch ⊙∼ ⊙idf (⊙Susp X) ⊙unit-l = unit-l , idp Susp-co-h-space-structure : CoHSpaceStructure (⊙Susp X) Susp-co-h-space-structure = record { ⊙coμ = ⊙pinch; ⊙unit-l = ⊙unit-l; ⊙unit-r = ⊙unit-r} private ⊙inv = ⊙Susp-flip X abstract inv-l : ∀ σ → ⊙WedgeRec.f (⊙Susp-flip X) (⊙idf (⊙Susp X)) (pinch σ) == north inv-l = Susp-elim (! (merid (pt X))) (! (merid (pt X))) λ x → ↓-app=cst-in $ ! $ ap (_∙ ! (merid (pt X))) $ ap (W.f ∘ pinch) (merid x) =⟨ ap-∘ W.f pinch (merid x) ⟩ ap W.f (ap pinch (merid x)) =⟨ ap (ap W.f) (Pinch.merid-β x) ⟩ ap W.f (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x)) =⟨ ap-∙∙ W.f (ap winl (σloop X x)) wglue (ap winr (merid x)) ⟩ ap W.f (ap winl (σloop X x)) ∙ ap W.f wglue ∙ ap W.f (ap winr (merid x)) =⟨ ap3 (λ p q r → p ∙ q ∙ r) ( ∘-ap W.f winl (σloop X x) ∙ ap-∙ Susp-flip (merid x) (! (merid (pt X))) ∙ (SuspFlip.merid-β x ∙2 (ap-! Susp-flip (merid (pt X)) ∙ ap ! (SuspFlip.merid-β (pt X))))) (W.glue-β ∙ ∙-unit-r (! (merid (pt X)))) (∘-ap W.f winr (merid x) ∙ ap-idf (merid x)) ⟩ (! (merid x) ∙ ! (! (merid (pt X)))) ∙ (! (merid (pt X)) ∙ merid x) =⟨ ap (_∙ (! (merid (pt X)) ∙ merid x)) (∙-! (merid x) (! (merid (pt X)))) ⟩ ! (! (merid (pt X)) ∙ merid x) ∙ (! (merid (pt X)) ∙ merid x) =⟨ !-inv-l (! (merid (pt X)) ∙ merid x) ⟩ idp =∎ where module W = ⊙WedgeRec (⊙Susp-flip X) (⊙idf (⊙Susp X)) ⊙inv-l : ⊙Wedge-rec (⊙Susp-flip X) (⊙idf (⊙Susp X)) ⊙∘ ⊙pinch ⊙∼ ⊙cst ⊙inv-l = inv-l , ↓-idf=cst-in' idp assoc : ∀ σ → fst (⊙–> (⊙∨-assoc (⊙Susp X) (⊙Susp X) (⊙Susp X))) (∨-fmap ⊙pinch (⊙idf (⊙Susp X)) (pinch σ)) == ∨-fmap (⊙idf (⊙Susp X)) ⊙pinch (pinch σ) assoc = Susp-elim idp idp λ x → ↓-='-in' $ ! $ ap (Assoc.f ∘ FmapL.f ∘ pinch) (merid x) =⟨ ap-∘ (Assoc.f ∘ FmapL.f) pinch (merid x) ⟩ ap (Assoc.f ∘ FmapL.f) (ap pinch (merid x)) =⟨ ap (ap (Assoc.f ∘ FmapL.f)) (Pinch.merid-β x) ⟩ ap (Assoc.f ∘ FmapL.f) (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x)) =⟨ ap-∘ Assoc.f FmapL.f (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x)) ⟩ ap Assoc.f (ap FmapL.f (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x))) =⟨ ap (ap Assoc.f) $ ap FmapL.f (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x)) =⟨ ap-∙∙ FmapL.f (ap winl (σloop X x)) wglue (ap winr (merid x)) ⟩ ap FmapL.f (ap winl (σloop X x)) ∙ ap FmapL.f wglue ∙ ap FmapL.f (ap winr (merid x)) =⟨ ap3 (λ p q r → p ∙ q ∙ r) ( ∘-ap FmapL.f winl (σloop X x) ∙ ap-∘ winl pinch (σloop X x) ∙ ap (ap winl) (lemma₀ x) ∙ ap-∙∙∙ winl (ap winl (σloop X x)) wglue (ap winr (σloop X x)) (! wglue) ∙ ap3 (λ p q r → p ∙ ap winl wglue ∙ q ∙ r) (∘-ap winl winl (σloop X x)) (∘-ap winl winr (σloop X x)) (ap-! winl wglue)) FmapL.glue-β (∘-ap FmapL.f winr (merid x)) ⟩ ( ap (winl ∘ winl) (σloop X x) ∙ ap winl wglue ∙ ap (winl ∘ winr) (σloop X x) ∙ ! (ap winl wglue)) ∙ wglue ∙ ap winr (merid x) =∎ ⟩ ap Assoc.f ((ap (winl ∘ winl) (σloop X x) ∙ ap winl wglue ∙ ap (winl ∘ winr) (σloop X x) ∙ ! (ap winl wglue)) ∙ wglue ∙ ap winr (merid x)) =⟨ ap-∙∙ Assoc.f (ap (winl ∘ winl) (σloop X x) ∙ ap winl wglue ∙ ap (winl ∘ winr) (σloop X x) ∙ ! (ap winl wglue)) wglue (ap winr (merid x)) ∙ ap (λ p → p ∙ ap Assoc.f wglue ∙ ap Assoc.f (ap winr (merid x))) (ap-∙∙∙ Assoc.f (ap (winl ∘ winl) (σloop X x)) (ap winl wglue) (ap (winl ∘ winr) (σloop X x)) (! (ap winl wglue))) ⟩ ( ap Assoc.f (ap (winl ∘ winl) (σloop X x)) ∙ ap Assoc.f (ap winl wglue) ∙ ap Assoc.f (ap (winl ∘ winr) (σloop X x)) ∙ ap Assoc.f (! (ap winl wglue))) ∙ ap Assoc.f wglue ∙ ap Assoc.f (ap winr (merid x)) =⟨ ap6 (λ p₀ p₁ p₂ p₃ p₄ p₅ → (p₀ ∙ p₁ ∙ p₂ ∙ p₃) ∙ p₄ ∙ p₅) (∘-ap Assoc.f (winl ∘ winl) (σloop X x)) (∘-ap Assoc.f winl wglue ∙ AssocInl.glue-β) (∘-ap Assoc.f (winl ∘ winr) (σloop X x) ∙ ap-∘ winr winl (σloop X x)) (ap-! Assoc.f (ap winl wglue) ∙ ap ! (∘-ap Assoc.f winl wglue ∙ AssocInl.glue-β)) Assoc.glue-β (∘-ap Assoc.f winr (merid x) ∙ ap-∘ winr winr (merid x)) ⟩ (ap winl (σloop X x) ∙ wglue ∙ ap winr (ap winl (σloop X x)) ∙ ! wglue) ∙ (wglue ∙ ap winr wglue) ∙ ap winr (ap winr (merid x)) =⟨ lemma₁ (ap winl (σloop X x)) wglue (ap winr (ap winl (σloop X x))) (ap winr wglue) (ap winr (ap winr (merid x))) ⟩ ap winl (σloop X x) ∙ wglue ∙ ap winr (ap winl (σloop X x)) ∙ ap winr wglue ∙ ap winr (ap winr (merid x)) =⟨ ap3 (λ p q r → p ∙ q ∙ r) (ap-∘ FmapR.f winl (σloop X x)) (! FmapR.glue-β) ( ∙∙-ap winr (ap winl (σloop X x)) wglue (ap winr (merid x)) ∙ ap (ap winr) (! (Pinch.merid-β x)) ∙ ∘-ap winr pinch (merid x) ∙ ap-∘ FmapR.f winr (merid x)) ⟩ ap FmapR.f (ap winl (σloop X x)) ∙ ap FmapR.f wglue ∙ ap FmapR.f (ap winr (merid x)) =⟨ ∙∙-ap FmapR.f (ap winl (σloop X x)) wglue (ap winr (merid x)) ⟩ ap FmapR.f (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x)) =⟨ ! $ ap (ap FmapR.f) (Pinch.merid-β x) ⟩ ap FmapR.f (ap pinch (merid x)) =⟨ ∘-ap FmapR.f pinch (merid x) ⟩ ap (FmapR.f ∘ pinch) (merid x) =∎ where module Assoc = WedgeAssoc (⊙Susp X) (⊙Susp X) (⊙Susp X) module AssocInl = WedgeAssocInl (⊙Susp X) (⊙Susp X) (⊙Susp X) module FmapL = WedgeFmap ⊙pinch (⊙idf (⊙Susp X)) module FmapR = WedgeFmap (⊙idf (⊙Susp X)) ⊙pinch lemma₀ : ∀ x → ap pinch (σloop X x) == ap winl (σloop X x) ∙ wglue ∙ ap winr (σloop X x) ∙ ! wglue lemma₀ x = ap pinch (σloop X x) =⟨ ap-∙ pinch (merid x) (! (merid (pt X))) ⟩ ap pinch (merid x) ∙ ap pinch (! (merid (pt X))) =⟨ Pinch.merid-β x ∙2 (ap-! pinch (merid (pt X)) ∙ ap ! (Pinch.merid-β (pt X))) ⟩ (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x)) ∙ ! (ap winl (σloop X (pt X)) ∙ wglue ∙ ap winr (merid (pt X))) =⟨ ap (λ p → (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x)) ∙ ! (ap winl p ∙ wglue ∙ ap winr (merid (pt X)))) σloop-pt ⟩ (ap winl (σloop X x) ∙ wglue ∙ ap winr (merid x)) ∙ ! (wglue ∙ ap winr (merid (pt X))) =⟨ lemma₀₁ winr (ap winl (σloop X x)) wglue (merid x) (merid (pt X)) ⟩ ap winl (σloop X x) ∙ wglue ∙ ap winr (σloop X x) ∙ ! wglue =∎ where lemma₀₁ : ∀ {i j} {A : Type i} {B : Type j} {b₀ b₁ : B} {a₂ a₃ : A} → (f : A → B) → (p₀ : b₀ == b₁) (p₁ : b₁ == f a₂) (p₂ : a₂ == a₃) (p₃ : a₂ == a₃) → (p₀ ∙ p₁ ∙ ap f p₂) ∙ ! (p₁ ∙ ap f p₃) == p₀ ∙ p₁ ∙ ap f (p₂ ∙ ! p₃) ∙ ! p₁ lemma₀₁ f idp idp idp p₃ = !-ap f p₃ ∙ ! (∙-unit-r (ap f (! p₃))) lemma₁ : ∀ {i} {A : Type i} {a₀ a₁ a₂ a₃ a₄ : A} → (p₀ : a₀ == a₁) (p₁ : a₁ == a₂) (p₂ : a₂ == a₂) (p₃ : a₂ == a₃) (p₄ : a₃ == a₄) → (p₀ ∙ p₁ ∙ p₂ ∙ ! p₁) ∙ (p₁ ∙ p₃) ∙ p₄ == p₀ ∙ p₁ ∙ (p₂ ∙ p₃ ∙ p₄) lemma₁ idp idp p₂ idp idp = ∙-unit-r (p₂ ∙ idp) ⊙assoc : ⊙–> (⊙∨-assoc (⊙Susp X) (⊙Susp X) (⊙Susp X)) ⊙∘ ⊙∨-fmap ⊙pinch (⊙idf (⊙Susp X)) ⊙∘ ⊙pinch ⊙∼ ⊙∨-fmap (⊙idf (⊙Susp X)) ⊙pinch ⊙∘ ⊙pinch ⊙assoc = assoc , idp Susp-cogroup-structure : CogroupStructure (⊙Susp X) Susp-cogroup-structure = record { co-h-struct = Susp-co-h-space-structure; ⊙inv = ⊙Susp-flip X; ⊙inv-l = ⊙inv-l; ⊙assoc = ⊙assoc} Susp⊙→-group-structure : ∀ {j} (Y : Ptd j) → GroupStructure (⊙Susp X ⊙→ Y) Susp⊙→-group-structure Y = cogroup⊙→-group-structure Susp-cogroup-structure Y Trunc-Susp⊙→-group : ∀ {j} (Y : Ptd j) → Group (lmax i j) Trunc-Susp⊙→-group Y = Trunc-group (Susp⊙→-group-structure Y) {- module _ {i j} (X : Ptd i) where Lift-Susp-co-h-space-structure : CoHSpaceStructure (⊙Lift {j = j} (⊙Susp X)) Lift-Susp-co-h-space-structure = Lift-co-h-space-structure {j = j} (Susp-co-h-space-structure X) Lift-Susp-cogroup-structure : CogroupStructure (⊙Lift {j = j} (⊙Susp X)) Lift-Susp-cogroup-structure = Lift-cogroup-structure {j = j} (Susp-cogroup-structure X) LiftSusp⊙→-group-structure : ∀ {k} (Y : Ptd k) → GroupStructure (⊙Lift {j = j} (⊙Susp X) ⊙→ Y) LiftSusp⊙→-group-structure Y = cogroup⊙→-group-structure Lift-Susp-cogroup-structure Y Trunc-LiftSusp⊙→-group : ∀ {k} (Y : Ptd k) → Group (lmax (lmax i j) k) Trunc-LiftSusp⊙→-group Y = Trunc-group (LiftSusp⊙→-group-structure Y) -}
{ "alphanum_fraction": 0.4666553682, "avg_line_length": 46.8293650794, "ext": "agda", "hexsha": "f17f17b0273c441fac978b29dc17b5e5adbaafd1", "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/groups/FromSusp.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/groups/FromSusp.agda", "max_line_length": 127, "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/groups/FromSusp.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5079, "size": 11801 }
module Issue1105 where module So.Bad where
{ "alphanum_fraction": 0.8181818182, "avg_line_length": 11, "ext": "agda", "hexsha": "f886544a37257c2a2181c9ee780c00408638a9b6", "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/Issue1105.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/Issue1105.agda", "max_line_length": 22, "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/Issue1105.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": 11, "size": 44 }
open import FRP.JS.Nat using ( ℕ ; suc ; _+_ ; _≟_ ) open import FRP.JS.Maybe using ( Maybe ; just ; nothing ; _≟[_]_ ) open import FRP.JS.Bool using ( Bool ; not ) open import FRP.JS.QUnit using ( TestSuite ; ok ; ok! ; test ; _,_ ) module FRP.JS.Test.Maybe where _≟¹_ : Maybe ℕ → Maybe ℕ → Bool xs ≟¹ ys = xs ≟[ _≟_ ] ys Maybe² : Set → Set Maybe² A = Maybe (Maybe A) _≟²_ : Maybe² ℕ → Maybe² ℕ → Bool xs ≟² ys = xs ≟[ _≟¹_ ] ys just² : ∀ {A : Set} → A → Maybe² A just² a = just (just a) Maybe³ : Set → Set Maybe³ A = Maybe (Maybe² A) _≟³_ : Maybe³ ℕ → Maybe³ ℕ → Bool xs ≟³ ys = xs ≟[ _≟²_ ] ys just³ : ∀ {A} → A → Maybe³ A just³ a = just (just² a) tests : TestSuite tests = ( test "≟" ( ok "nothing ≟ nothing" (nothing ≟¹ nothing) , ok "just 0 ≟ just 0" (just 0 ≟¹ just 0) , ok "nothing ≟ just 1" (not (nothing ≟¹ just 1)) , ok "just 0 ≟ nothing" (not (just 0 ≟¹ nothing)) , ok "just 0 ≟ just 1" (not (just 0 ≟¹ just 1)) ) , test "≟²" ( ok "nothing ≟² nothing" (nothing ≟² nothing) , ok "just nothing ≟² just nothing" (just nothing ≟² just nothing) , ok "just² 0 ≟² just² 0" (just² 0 ≟² just² 0) , ok "nothing ≟² just nothing" (not (nothing ≟² just nothing)) , ok "nothing ≟² just² 1" (not (nothing ≟² just² 1)) , ok "just nothing ≟² just² 1" (not (just nothing ≟² just² 1)) , ok "just² 0 ≟² just² 1" (not (just² 0 ≟² just² 1)) ) , test "≟³" ( ok "nothing ≟³ nothing" (nothing ≟³ nothing) , ok "just nothing ≟³ just nothing" (just nothing ≟³ just nothing) , ok "just² nothing ≟³ just² nothing" (just² nothing ≟³ just² nothing) , ok "just³ 0 ≟³ just³ 0" (just³ 0 ≟³ just³ 0) , ok "nothing ≟³ just nothing" (not (nothing ≟³ just nothing)) , ok "nothing ≟³ just² nothing" (not (nothing ≟³ just² nothing)) , ok "nothing ≟³ just³ 1" (not (nothing ≟³ just³ 1)) , ok "just nothing ≟³ just² nothing" (not (just nothing ≟³ just² nothing)) , ok "just nothing ≟³ just³ 1" (not (just nothing ≟³ just³ 1)) , ok "just³ 0 ≟³ just³ 1" (not (just³ 0 ≟³ just³ 1)) ) )
{ "alphanum_fraction": 0.5611872146, "avg_line_length": 39.1071428571, "ext": "agda", "hexsha": "1ff63807de57ce005440db06283b7dcbe69e40d3", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "test/agda/FRP/JS/Test/Maybe.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "test/agda/FRP/JS/Test/Maybe.agda", "max_line_length": 79, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "test/agda/FRP/JS/Test/Maybe.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 855, "size": 2190 }
module Homogenous.Nat where import PolyDepPrelude open PolyDepPrelude using (zero; one; _::_; nil; right; left; pair; unit) import Homogenous.Base open Homogenous.Base using (Sig; T; Intro) -- The code for natural numbers is [0 1] codeNat : Sig codeNat = zero :: (one :: nil) iNat : Set iNat = T codeNat -- Short-hand notation for the normal Nat constructors izero : iNat izero = Intro (left unit) isucc : iNat -> iNat isucc = \(h : iNat) -> Intro (right (left (pair h unit))) -- the pair with the dummy unit component comes from the 1-tuple -- representation as A*() ione : iNat ione = isucc izero {- main : Set main = {!!} -}
{ "alphanum_fraction": 0.6848673947, "avg_line_length": 18.3142857143, "ext": "agda", "hexsha": "01f93932118b5cf934deb380c054d54fb00a366f", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/AIM5/PolyDep/Homogenous/Nat.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/AIM5/PolyDep/Homogenous/Nat.agda", "max_line_length": 73, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/AIM5/PolyDep/Homogenous/Nat.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": 193, "size": 641 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Magma where open import Cubical.Algebra.Base public open import Cubical.Algebra.Definitions public open import Cubical.Algebra.Structures public using (IsMagma; ismagma) open import Cubical.Algebra.Bundles public using (Magma; mkmagma; MagmaCarrier) open import Cubical.Structures.Carrier public open import Cubical.Algebra.Magma.Properties public open import Cubical.Algebra.Magma.Morphism public open import Cubical.Algebra.Magma.MorphismProperties public
{ "alphanum_fraction": 0.8261682243, "avg_line_length": 38.2142857143, "ext": "agda", "hexsha": "07136baa31e0cc500d5abee6a02dc4f8643d4ec6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Magma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Magma.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Magma.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 130, "size": 535 }
module CaseSplit1 where data ℕ : Set where Z : ℕ S : ℕ → ℕ f0 : ℕ → ℕ f0 = λ { x → {! !} ; y → {! !} } f1 : ℕ → ℕ f1 = λ { x → {! !} ; y → {! !} } g0 : ℕ → ℕ g0 = λ where x → {! !} y → {! !} g1 : ℕ → ℕ g1 = λ where x → {! !} y → {! !} issue16 : ℕ → ℕ issue16 = λ {x → {! !} }
{ "alphanum_fraction": 0.3093093093, "avg_line_length": 12.8076923077, "ext": "agda", "hexsha": "4f0d2c2aa317f437f7aa00630fab1a3231138873", "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": "7628c254e87374a924a781cf15ea3abd715fd2d3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "SNU-2D/agda-mode-vscode", "max_forks_repo_path": "test/tests/assets/CaseSplit1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7628c254e87374a924a781cf15ea3abd715fd2d3", "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": "SNU-2D/agda-mode-vscode", "max_issues_repo_path": "test/tests/assets/CaseSplit1.agda", "max_line_length": 36, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7628c254e87374a924a781cf15ea3abd715fd2d3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "EdNutting/agda-mode-vscode", "max_stars_repo_path": "test/tests/assets/CaseSplit1.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T23:37:02.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-04T23:37:02.000Z", "num_tokens": 152, "size": 333 }
------------------------------------------------------------------------------ -- ABP auxiliary lemma ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Program.ABP.StrongerInductionPrinciple.LemmaI where open import Common.FOL.Relation.Binary.EqReasoning open import FOTC.Base open import FOTC.Base.PropertiesI open import FOTC.Base.List open import FOTC.Base.Loop open import FOTC.Base.List.PropertiesI open import FOTC.Data.Bool open import FOTC.Data.Bool.PropertiesI open import FOTC.Data.List open import FOTC.Data.List.PropertiesI open import FOTC.Program.ABP.ABP open import FOTC.Program.ABP.Fair.Type open import FOTC.Program.ABP.Fair.PropertiesI open import FOTC.Program.ABP.PropertiesI open import FOTC.Program.ABP.Terms ------------------------------------------------------------------------------ -- Helper function for the auxiliary lemma module Helper where helper : ∀ {b i' is' os₁ os₂ as bs cs ds js} → Bit b → Fair os₂ → S b (i' ∷ is') os₁ os₂ as bs cs ds js → ∀ ft₁ os₁' → F*T ft₁ → Fair os₁' → os₁ ≡ ft₁ ++ os₁' → ∃[ js' ] js ≡ i' ∷ js' helper {b} {i'} {is'} {os₁} {os₂} {as} {bs} {cs} {ds} {js} Bb Fos₂ (asS , bsS , csS , dsS , jsS) .(T ∷ []) os₁' f*tnil Fos₁' os₁-eq = js' , js-eq where os₁-eq-helper : os₁ ≡ T ∷ os₁' os₁-eq-helper = os₁ ≡⟨ os₁-eq ⟩ (T ∷ []) ++ os₁' ≡⟨ ++-∷ T [] os₁' ⟩ T ∷ ([] ++ os₁') ≡⟨ ∷-rightCong (++-leftIdentity os₁') ⟩ T ∷ os₁' ∎ as' : D as' = await b i' is' ds as-eq : as ≡ < i' , b > ∷ as' as-eq = trans asS (send-eq b i' is' ds) bs' : D bs' = corrupt os₁' · as' bs-eq : bs ≡ ok < i' , b > ∷ bs' bs-eq = bs ≡⟨ bsS ⟩ corrupt os₁ · as ≡⟨ ·-rightCong as-eq ⟩ corrupt os₁ · (< i' , b > ∷ as') ≡⟨ ·-leftCong (corruptCong os₁-eq-helper) ⟩ corrupt (T ∷ os₁') · (< i' , b > ∷ as') ≡⟨ corrupt-T os₁' < i' , b > as' ⟩ ok < i' , b > ∷ corrupt os₁' · as' ≡⟨ refl ⟩ ok < i' , b > ∷ bs' ∎ cs' : D cs' = ack (not b) · bs' js' : D js' = out (not b) · bs' js-eq : js ≡ i' ∷ js' js-eq = js ≡⟨ jsS ⟩ out b · bs ≡⟨ ·-rightCong bs-eq ⟩ out b · (ok < i' , b > ∷ bs') ≡⟨ out-ok≡ b b i' bs' refl ⟩ i' ∷ out (not b) · bs' ≡⟨ refl ⟩ i' ∷ js' ∎ ds' : D ds' = ds helper {b} {i'} {is'} {os₁} {os₂} {as} {bs} {cs} {ds} {js} Bb Fos₂ (asS , bsS , csS , dsS , jsS) .(F ∷ ft₁^) os₁' (f*tcons {ft₁^} FTft₁^) Fos₁' os₁-eq = helper Bb (tail-Fair Fos₂) ihS ft₁^ os₁' FTft₁^ Fos₁' refl where os₁^ : D os₁^ = ft₁^ ++ os₁' os₂^ : D os₂^ = tail₁ os₂ os₁-eq-helper : os₁ ≡ F ∷ os₁^ os₁-eq-helper = os₁ ≡⟨ os₁-eq ⟩ (F ∷ ft₁^) ++ os₁' ≡⟨ ++-∷ F ft₁^ os₁' ⟩ F ∷ ft₁^ ++ os₁' ≡⟨ refl ⟩ F ∷ os₁^ ∎ as^ : D as^ = await b i' is' ds as-eq : as ≡ < i' , b > ∷ as^ as-eq = trans asS (send-eq b i' is' ds) bs^ : D bs^ = corrupt os₁^ · as^ bs-eq : bs ≡ error ∷ bs^ bs-eq = bs ≡⟨ bsS ⟩ corrupt os₁ · as ≡⟨ ·-rightCong as-eq ⟩ corrupt os₁ · (< i' , b > ∷ as^) ≡⟨ ·-leftCong (corruptCong os₁-eq-helper) ⟩ corrupt (F ∷ os₁^) · (< i' , b > ∷ as^) ≡⟨ corrupt-F os₁^ < i' , b > as^ ⟩ error ∷ corrupt os₁^ · as^ ≡⟨ refl ⟩ error ∷ bs^ ∎ cs^ : D cs^ = ack b · bs^ cs-eq : cs ≡ not b ∷ cs^ cs-eq = cs ≡⟨ csS ⟩ ack b · bs ≡⟨ ·-rightCong bs-eq ⟩ ack b · (error ∷ bs^) ≡⟨ ack-error b bs^ ⟩ not b ∷ ack b · bs^ ≡⟨ refl ⟩ not b ∷ cs^ ∎ ds^ : D ds^ = corrupt os₂^ · cs^ ds-eq-helper₁ : os₂ ≡ T ∷ tail₁ os₂ → ds ≡ ok (not b) ∷ ds^ ds-eq-helper₁ h = ds ≡⟨ dsS ⟩ corrupt os₂ · cs ≡⟨ ·-rightCong cs-eq ⟩ corrupt os₂ · (not b ∷ cs^) ≡⟨ ·-leftCong (corruptCong h) ⟩ corrupt (T ∷ os₂^) · (not b ∷ cs^) ≡⟨ corrupt-T os₂^ (not b) cs^ ⟩ ok (not b) ∷ corrupt os₂^ · cs^ ≡⟨ refl ⟩ ok (not b) ∷ ds^ ∎ ds-eq-helper₂ : os₂ ≡ F ∷ tail₁ os₂ → ds ≡ error ∷ ds^ ds-eq-helper₂ h = ds ≡⟨ dsS ⟩ corrupt os₂ · cs ≡⟨ ·-rightCong cs-eq ⟩ corrupt os₂ · (not b ∷ cs^) ≡⟨ ·-leftCong (corruptCong h) ⟩ corrupt (F ∷ os₂^) · (not b ∷ cs^) ≡⟨ corrupt-F os₂^ (not b) cs^ ⟩ error ∷ corrupt os₂^ · cs^ ≡⟨ refl ⟩ error ∷ ds^ ∎ ds-eq : ds ≡ ok (not b) ∷ ds^ ∨ ds ≡ error ∷ ds^ ds-eq = case (λ h → inj₁ (ds-eq-helper₁ h)) (λ h → inj₂ (ds-eq-helper₂ h)) (head-tail-Fair Fos₂) as^-eq-helper₁ : ds ≡ ok (not b) ∷ ds^ → as^ ≡ send b · (i' ∷ is') · ds^ as^-eq-helper₁ h = await b i' is' ds ≡⟨ awaitCong₄ h ⟩ await b i' is' (ok (not b) ∷ ds^) ≡⟨ await-ok≢ b (not b) i' is' ds^ (x≢not-x Bb) ⟩ < i' , b > ∷ await b i' is' ds^ ≡⟨ sym (send-eq b i' is' ds^) ⟩ send b · (i' ∷ is') · ds^ ∎ as^-eq-helper₂ : ds ≡ error ∷ ds^ → as^ ≡ send b · (i' ∷ is') · ds^ as^-eq-helper₂ h = await b i' is' ds ≡⟨ awaitCong₄ h ⟩ await b i' is' (error ∷ ds^) ≡⟨ await-error b i' is' ds^ ⟩ < i' , b > ∷ await b i' is' ds^ ≡⟨ sym (send-eq b i' is' ds^) ⟩ send b · (i' ∷ is') · ds^ ∎ as^-eq : as^ ≡ send b · (i' ∷ is') · ds^ as^-eq = case as^-eq-helper₁ as^-eq-helper₂ ds-eq js-eq : js ≡ out b · bs^ js-eq = js ≡⟨ jsS ⟩ out b · bs ≡⟨ ·-rightCong bs-eq ⟩ out b · (error ∷ bs^) ≡⟨ out-error b bs^ ⟩ out b · bs^ ∎ ihS : S b (i' ∷ is') os₁^ os₂^ as^ bs^ cs^ ds^ js ihS = as^-eq , refl , refl , refl , js-eq ------------------------------------------------------------------------------ -- From Dybjer and Sander's paper: From the assumption that os₁ ∈ Fair -- and hence by unfolding Fair, we conclude that there are ft₁ :  F*T -- and os₁' : Fair, such that os₁ = ft₁ ++ os₁'. -- -- We proceed by induction on ft₁ : F*T using helper. open Helper lemma : ∀ {b i' is' os₁ os₂ as bs cs ds js} → Bit b → Fair os₁ → Fair os₂ → S b (i' ∷ is') os₁ os₂ as bs cs ds js → ∃[ js' ] js ≡ i' ∷ js' lemma Bb Fos₁ Fos₂ s with Fair-out Fos₁ ... | ft , os₁' , FTft , prf , Fos₁' = helper Bb Fos₂ s ft os₁' FTft Fos₁' prf
{ "alphanum_fraction": 0.4242987979, "avg_line_length": 33.2761904762, "ext": "agda", "hexsha": "8018c0d654a9b038b3a93183ad2a3f0fc42a9cf7", "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/ABP/StrongerInductionPrinciple/LemmaI.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/ABP/StrongerInductionPrinciple/LemmaI.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/ABP/StrongerInductionPrinciple/LemmaI.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": 2709, "size": 6988 }
-- simply-typed labelled λ-calculus w/ DeBruijn indices -- {-# OPTIONS --show-implicit #-} module LLC where open import Agda.Primitive open import Agda.Builtin.Bool open import Data.Bool.Properties hiding (≤-trans ; <-trans ; ≤-refl ; <-irrefl) open import Data.Empty open import Data.Nat renaming (_+_ to _+ᴺ_ ; _≤_ to _≤ᴺ_ ; _≥_ to _≥ᴺ_ ; _<_ to _<ᴺ_ ; _>_ to _>ᴺ_ ; _≟_ to _≟ᴺ_) open import Data.Nat.Properties renaming (_<?_ to _<ᴺ?_) open import Data.Integer renaming (_+_ to _+ᶻ_ ; _≤_ to _≤ᶻ_ ; _≥_ to _≥ᶻ_ ; _<_ to _<ᶻ_ ; _>_ to _>ᶻ_) open import Data.Integer.Properties using (⊖-≥ ; 0≤n⇒+∣n∣≡n ; +-monoˡ-≤) open import Data.List open import Data.List.Relation.Unary.All open import Relation.Unary using (Decidable) open import Data.Vec.Relation.Unary.Any open import Data.Vec.Base hiding (length ; _++_ ; foldr) open import Relation.Binary.PropositionalEquality renaming (trans to ≡-trans) open import Relation.Nullary open import Relation.Nullary.Decidable open import Relation.Nullary.Negation open import Data.Fin open import Data.Fin.Subset renaming (∣_∣ to ∣_∣ˢ) open import Data.Fin.Subset.Properties using (anySubset?) open import Data.Fin.Properties using (any?) open import Data.Product open import Data.Sum open import Function open import Extensionality open import Auxiliary module defs where data Exp {n : ℕ} : Set where Var : ℕ → Exp {n} Abs : Exp {n} → Exp {n} App : Exp {n} → Exp {n} → Exp {n} LabI : Fin n → Exp {n} LabE : {s : Subset n} → (f : ∀ l → l ∈ s → Exp {n}) → Exp {n} → Exp {n} data Ty {n : ℕ} : Set where Fun : Ty {n} → Ty {n} → Ty Label : Subset n → Ty -- shifting and substitution -- shifting, required to avoid variable-capturing in substitution -- see Pierce 2002, pg. 78/79 ↑ᴺ_,_[_] : ℤ → ℕ → ℕ → ℕ ↑ᴺ d , c [ x ] with (x <ᴺ? c) ... | yes p = x ... | no ¬p = ∣ ℤ.pos x +ᶻ d ∣ ↑_,_[_] : ∀ {n} → ℤ → ℕ → Exp {n} → Exp ↑ d , c [ Var x ] = Var (↑ᴺ d , c [ x ]) ↑ d , c [ Abs t ] = Abs (↑ d , (ℕ.suc c) [ t ]) ↑ d , c [ App t t₁ ] = App (↑ d , c [ t ]) (↑ d , c [ t₁ ]) ↑ d , c [ LabI x ] = LabI x ↑ d , c [ LabE f e ] = LabE (λ l x → ↑ d , c [ (f l x) ]) (↑ d , c [ e ]) -- shorthands ↑¹[_] : ∀ {n} → Exp {n} → Exp ↑¹[ e ] = ↑ (ℤ.pos 1) , 0 [ e ] ↑⁻¹[_] : ∀ {n} → Exp {n} → Exp ↑⁻¹[ e ] = ↑ (ℤ.negsuc 0) , 0 [ e ] -- substitution -- see Pierce 2002, pg. 80 [_↦_]_ : ∀ {n} → ℕ → Exp {n} → Exp → Exp [ k ↦ s ] Var x with (_≟ᴺ_ x k) ... | yes p = s ... | no ¬p = Var x [ k ↦ s ] Abs t = Abs ([ ℕ.suc k ↦ ↑¹[ s ] ] t) [ k ↦ s ] App t t₁ = App ([ k ↦ s ] t) ([ k ↦ s ] t₁) [ k ↦ s ] LabI ins = LabI ins [ k ↦ s ] LabE f e = LabE (λ l x → [ k ↦ s ] (f l x)) ([ k ↦ s ] e) -- variable in expression data _∈`_ {N : ℕ} : ℕ → Exp {N} → Set where in-Var : {n : ℕ} → n ∈` Var n in-Abs : {n : ℕ} {e : Exp} → (ℕ.suc n) ∈` e → n ∈` Abs e in-App : {n : ℕ} {e e' : Exp} → n ∈` e ⊎ n ∈` e' → n ∈` App e e' in-LabE : {n : ℕ} {s : Subset N} {f : (∀ l → l ∈ s → Exp {N})} {e : Exp {N}} → (∃₂ λ l i → n ∈` (f l i)) ⊎ n ∈` e → n ∈` LabE {N} {s} f e -- typing Env : {ℕ} → Set Env {n} = List (Ty {n}) data _∶_∈_ {n : ℕ} : ℕ → Ty {n} → Env {n} → Set where here : {T : Ty} {Γ : Env} → 0 ∶ T ∈ (T ∷ Γ) there : {n : ℕ} {T₁ T₂ : Ty} {Γ : Env} → n ∶ T₁ ∈ Γ → (ℕ.suc n) ∶ T₁ ∈ (T₂ ∷ Γ) data _⊢_∶_ {n : ℕ} : Env {n} → Exp {n} → Ty {n} → Set where TVar : {m : ℕ} {Γ : Env} {T : Ty} → m ∶ T ∈ Γ → Γ ⊢ (Var m) ∶ T TAbs : {Γ : Env} {T₁ T₂ : Ty} {e : Exp} → (T₁ ∷ Γ) ⊢ e ∶ T₂ → Γ ⊢ (Abs e) ∶ (Fun T₁ T₂) TApp : {Γ : Env} {T₁ T₂ : Ty} {e₁ e₂ : Exp} → Γ ⊢ e₁ ∶ (Fun T₁ T₂) → Γ ⊢ e₂ ∶ T₁ → Γ ⊢ (App e₁ e₂) ∶ T₂ TLabI : {Γ : Env} {x : Fin n} {s : Subset n} → (ins : x ∈ s) → Γ ⊢ LabI x ∶ Label {n} s TLabEl : {Γ : Env} {T : Ty} {s : Subset n} {x : Fin n} {ins : x ∈ s} {f : ∀ l → l ∈ s → Exp} {scopecheck : ∀ l i n → n ∈` (f l i) → n <ᴺ length Γ} → Γ ⊢ f x ins ∶ T → Γ ⊢ LabI {n} x ∶ Label {n} s → Γ ⊢ LabE {n} {s} f (LabI {n} x) ∶ T TLabEx : {Γ : Env} {T : Ty} {m : ℕ} {s : Subset n} {f : ∀ l → l ∈ s → Exp} → (f' : ∀ l i → (Γ ⊢ [ m ↦ (LabI l) ] (f l i) ∶ T)) → Γ ⊢ Var m ∶ Label {n} s → Γ ⊢ LabE {n} {s} f (Var m) ∶ T -- denotational semantics module denotational where open defs Val : {n : ℕ} → Ty {n} → Set Val (Fun Ty₁ Ty₂) = (Val Ty₁) → (Val Ty₂) Val {n} (Label s) = Σ (Fin n) (λ x → x ∈ s) access : {n m : ℕ} {Γ : Env {n}} {T : Ty {n}} → m ∶ T ∈ Γ → All Val Γ → Val T access here (V ∷ Γ) = V access (there J) (V ∷ Γ) = access J Γ eval : {n : ℕ} {Γ : Env {n}} {T : Ty {n}} {e : Exp {n}} → Γ ⊢ e ∶ T → All Val Γ → Val T eval (TVar c) Val-Γ = access c Val-Γ eval (TAbs TJ) Val-Γ = λ V → eval TJ (V ∷ Val-Γ) eval (TApp TJ TJ₁) Val-Γ = (eval TJ Val-Γ) (eval TJ₁ Val-Γ) eval (TLabI {x = x} ins) Val-Γ = x , ins eval (TLabEl {x = x}{ins = ins}{f = f} j j') Val-Γ = eval j Val-Γ eval (TLabEx {m = m}{s}{f} f' j) Val-Γ with eval j Val-Γ -- evaluate variable ... | x , ins = eval (f' x ins) Val-Γ -- operational semantics (call-by-value) module operational where open defs data Val {n : ℕ} : Exp {n} → Set where VFun : {e : Exp} → Val (Abs e) VLab : {x : Fin n} → Val (LabI x) -- reduction relation data _⇒_ {n : ℕ} : Exp {n} → Exp {n} → Set where ξ-App1 : {e₁ e₁' e₂ : Exp} → e₁ ⇒ e₁' → App e₁ e₂ ⇒ App e₁' e₂ ξ-App2 : {e e' v : Exp} → Val v → e ⇒ e' → App v e ⇒ App v e' β-App : {e v : Exp} → Val v → (App (Abs e) v) ⇒ (↑⁻¹[ ([ 0 ↦ ↑¹[ v ] ] e) ]) β-LabE : {s : Subset n} {f : ∀ l → l ∈ s → Exp} {x : Fin n} → (ins : x ∈ s) → LabE f (LabI x) ⇒ f x ins ---- properties & lemmas --- properties of shifting -- ∣ + x +ᶻ k ∣ +ᴺ m ≡ ∣ + (x +ᴺ m) +ᶻ k ∣ aux-calc-1 : {x m : ℕ} {k : ℤ} → k >ᶻ + 0 → ∣ + x +ᶻ k ∣ +ᴺ m ≡ ∣ + (x +ᴺ m) +ᶻ k ∣ aux-calc-1 {x} {m} {+_ n} ge rewrite (+-assoc x n m) | (+-comm n m) | (sym (+-assoc x m n)) = refl ↑ᴺk,l[x]+m≡↑ᴺk,l+m[x+m] : {k : ℤ} {l x m : ℕ} → k >ᶻ + 0 → ↑ᴺ k , l [ x ] +ᴺ m ≡ ↑ᴺ k , l +ᴺ m [ x +ᴺ m ] ↑ᴺk,l[x]+m≡↑ᴺk,l+m[x+m] {k} {l} {x} {m} ge with x <ᴺ? l ... | yes p with x +ᴺ m <ᴺ? l +ᴺ m ... | yes q = refl ... | no ¬q = contradiction (+-monoˡ-< m p) ¬q ↑ᴺk,l[x]+m≡↑ᴺk,l+m[x+m] {k} {l} {x} {m} ge | no ¬p with x +ᴺ m <ᴺ? l +ᴺ m ... | yes q = contradiction q (<⇒≱ (+-monoˡ-< m (≰⇒> ¬p))) ... | no ¬q = aux-calc-1 ge -- corollary for suc suc[↑ᴺk,l[x]]≡↑ᴺk,sucl[sucx] : {k : ℤ} {l x : ℕ} → k >ᶻ + 0 → ℕ.suc (↑ᴺ k , l [ x ]) ≡ ↑ᴺ k , ℕ.suc l [ ℕ.suc x ] suc[↑ᴺk,l[x]]≡↑ᴺk,sucl[sucx] {k} {l} {x} ge with (↑ᴺk,l[x]+m≡↑ᴺk,l+m[x+m] {k} {l} {x} {1} ge) ... | w rewrite (n+1≡sucn{↑ᴺ k , l [ x ]}) | (n+1≡sucn{x}) | (n+1≡sucn{l}) = w ↑-var-refl : {n : ℕ} {d : ℤ} {c : ℕ} {x : ℕ} {le : ℕ.suc x ≤ᴺ c} → ↑ d , c [ Var {n} x ] ≡ Var x ↑-var-refl {n} {d} {c} {x} {le} with (x <ᴺ? c) ... | no ¬p = contradiction le ¬p ... | yes p = refl ↑¹-var : {n x : ℕ} → ↑¹[ Var {n} x ] ≡ Var (ℕ.suc x) ↑¹-var {n} {zero} = refl ↑¹-var {n} {ℕ.suc x} rewrite (sym (n+1≡sucn{x +ᴺ 1})) | (sym (n+1≡sucn{x})) = cong ↑¹[_] (↑¹-var{n}{x}) ↑⁻¹ₖ[↑¹ₖ[s]]≡s : {n : ℕ} {e : Exp {n} } {k : ℕ} → ↑ -[1+ 0 ] , k [ ↑ + 1 , k [ e ] ] ≡ e ↑⁻¹ₖ[↑¹ₖ[s]]≡s {n} {Var x} {k} with (x <ᴺ? k) -- x < k -- => ↑⁻¹ₖ(↑¹ₖ(Var n)) = ↑⁻¹ₖ(Var n) = Var n ... | yes p = ↑-var-refl{n}{ -[1+ 0 ]}{k}{x}{p} -- x ≥ k -- => ↑⁻¹ₖ(↑¹ₖ(Var n)) = ↑⁻¹ₖ(Var |n + 1|) = Var (||n + 1| - 1|) = Var n ... | no ¬p with (¬[x≤k]⇒¬[sucx≤k] ¬p) ... | ¬p' with (x +ᴺ 1) <ᴺ? k ... | yes pp = contradiction pp ¬p' ... | no ¬pp rewrite (∣nℕ+1⊖1∣≡n{x}) = refl ↑⁻¹ₖ[↑¹ₖ[s]]≡s {n} {Abs e} {k} = cong Abs ↑⁻¹ₖ[↑¹ₖ[s]]≡s ↑⁻¹ₖ[↑¹ₖ[s]]≡s {n} {App e e₁} = cong₂ App ↑⁻¹ₖ[↑¹ₖ[s]]≡s ↑⁻¹ₖ[↑¹ₖ[s]]≡s ↑⁻¹ₖ[↑¹ₖ[s]]≡s {n} {LabI ins} = refl ↑⁻¹ₖ[↑¹ₖ[s]]≡s {n} {LabE f e} = cong₂ LabE (f-ext (λ x → f-ext (λ ins → ↑⁻¹ₖ[↑¹ₖ[s]]≡s))) ↑⁻¹ₖ[↑¹ₖ[s]]≡s ↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] : {n : ℕ} {k l : ℤ} {c : ℕ} {s : Exp {n}} → l ≥ᶻ +0 → ↑ k , c [ ↑ l , c [ s ] ] ≡ ↑ (l +ᶻ k) , c [ s ] ↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {n} {k} {l} {c} {Var x} ge with x <ᴺ? c ↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {n} {k} {l} {c} {Var x} ge | no ¬p with ∣ + x +ᶻ l ∣ <ᴺ? c ... | yes q = contradiction q (<⇒≱ (n≤m⇒n<sucm (≤-trans (≮⇒≥ ¬p) (m≥0⇒∣n+m∣≥n ge)))) ... | no ¬q rewrite (0≤n⇒+∣n∣≡n{+ x +ᶻ l} (m≥0⇒n+m≥0 ge)) | (Data.Integer.Properties.+-assoc (+_ x) l k) = refl ↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {n} {k} {l} {c} {Var x} ge | yes p with x <ᴺ? c ... | yes p' = refl ... | no ¬p' = contradiction p ¬p' ↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {n} {k} {l} {c} {Abs s} le = cong Abs (↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s]{n}{k}{l}{ℕ.suc c}{s} le) ↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {n} {k} {l} {c} {App s s₁} le = cong₂ App (↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s]{n}{k}{l}{c}{s} le) (↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s]{n}{k}{l}{c}{s₁} le) ↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {n} {k} {l} {c} {LabI ins} le = refl ↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {n} {k} {l} {c} {LabE f e} le = cong₂ LabE (f-ext (λ x → f-ext (λ ins → ↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {n} {k} {l} {c} {f x ins} le))) ( ↑ᵏ[↑ˡ[s]]≡↑ᵏ⁺ˡ[s] {n} {k} {l} {c} {e} le) ↑k,q[↑l,c[s]]≡↑l+k,c[s] : {n : ℕ} {k l : ℤ} {q c : ℕ} {s : Exp {n}} → + q ≤ᶻ + c +ᶻ l → c ≤ᴺ q → ↑ k , q [ ↑ l , c [ s ] ] ≡ ↑ (l +ᶻ k) , c [ s ] ↑k,q[↑l,c[s]]≡↑l+k,c[s] {n} {k} {l} {q} {c} {Var x} ge₁ ge₂ with x <ᴺ? c ... | yes p with x <ᴺ? q ... | yes p' = refl ... | no ¬p' = contradiction (≤-trans p ge₂) ¬p' ↑k,q[↑l,c[s]]≡↑l+k,c[s] {n} {k} {l} {q} {c} {Var x} ge₁ ge₂ | no ¬p with ∣ + x +ᶻ l ∣ <ᴺ? q ... | yes p' = contradiction p' (≤⇒≯ (+a≤b⇒a≤∣b∣{q}{+ x +ᶻ l} (Data.Integer.Properties.≤-trans ge₁ ((Data.Integer.Properties.+-monoˡ-≤ l (+≤+ (≮⇒≥ ¬p))))))) ... | no ¬p' rewrite (0≤n⇒+∣n∣≡n{+ x +ᶻ l} (Data.Integer.Properties.≤-trans (+≤+ z≤n) ((Data.Integer.Properties.≤-trans ge₁ ((Data.Integer.Properties.+-monoˡ-≤ l (+≤+ (≮⇒≥ ¬p)))))))) | (Data.Integer.Properties.+-assoc (+_ x) l k) = refl ↑k,q[↑l,c[s]]≡↑l+k,c[s] {n} {k} {l} {q} {c} {Abs s} ge₁ ge₂ = cong Abs (↑k,q[↑l,c[s]]≡↑l+k,c[s] {n} {k} {l} {ℕ.suc q} {ℕ.suc c} {s} (+q≤+c+l⇒+1q≤+1c+l{q}{c}{l} ge₁) (s≤s ge₂)) ↑k,q[↑l,c[s]]≡↑l+k,c[s] {n} {k} {l} {q} {c} {App s s₁} ge₁ ge₂ = cong₂ App (↑k,q[↑l,c[s]]≡↑l+k,c[s] {n} {k} {l} {q} {c} {s} ge₁ ge₂) (↑k,q[↑l,c[s]]≡↑l+k,c[s]{n} {k} {l} {q} {c} {s₁} ge₁ ge₂) ↑k,q[↑l,c[s]]≡↑l+k,c[s] {n} {k} {l} {q} {c} {LabI e} ge₁ ge₂ = refl ↑k,q[↑l,c[s]]≡↑l+k,c[s] {n} {k} {l} {q} {c} {LabE f e} ge₁ ge₂ = cong₂ LabE (f-ext (λ x → f-ext (λ ins → ↑k,q[↑l,c[s]]≡↑l+k,c[s] {n} {k} {l} {q} {c} {f x ins} ge₁ ge₂))) (↑k,q[↑l,c[s]]≡↑l+k,c[s] {n} {k} {l} {q} {c} {e} ge₁ ge₂) aux-calc-2 : {x l : ℕ} {k : ℤ} → k >ᶻ + 0 → ∣ + (x +ᴺ l) +ᶻ k ∣ ≡ ∣ + x +ᶻ k ∣ +ᴺ l aux-calc-2 {x} {l} {+_ n} ge rewrite (+-assoc x l n) | (+-comm l n) | (+-assoc x n l) = refl ↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] : {n : ℕ} {k : ℤ} {q c l : ℕ} {s : Exp {n}} → c ≤ᴺ q → + 0 <ᶻ k → ↑ k , q +ᴺ l [ ↑ + l , c [ s ] ] ≡ ↑ + l , c [ ↑ k , q [ s ] ] ↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {q} {c} {l} {Var x} le le' with x <ᴺ? q ... | yes p with x <ᴺ? c ... | yes p' with x <ᴺ? q +ᴺ l ... | yes p'' = refl ... | no ¬p'' = contradiction (≤-stepsʳ l p) ¬p'' ↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {q} {c} {l} {Var x} le le' | yes p | no ¬p' with x +ᴺ l <ᴺ? q +ᴺ l ... | yes p'' = refl ... | no ¬p'' = contradiction (Data.Nat.Properties.+-monoˡ-≤ l p) ¬p'' ↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {q} {c} {l} {Var x} le le' | no ¬p with x <ᴺ? c ... | yes p' = contradiction p' (<⇒≱ (a≤b<c⇒a<c le (≰⇒> ¬p))) ... | no ¬p' with x +ᴺ l <ᴺ? q +ᴺ l | ∣ + x +ᶻ k ∣ <ᴺ? c ... | _ | yes p''' = contradiction p''' (<⇒≱ (a≤b<c⇒a<c (≰⇒≥ ¬p') (s≤s (m>0⇒∣n+m∣>n {x} {k} le')))) ... | yes p'' | _ = contradiction p'' (<⇒≱ (+-monoˡ-< l (≰⇒> ¬p))) ... | no ¬p'' | no ¬p''' = cong Var (aux-calc-2 {x} {l} {k} le') ↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {q} {c} {l} {Abs s} le le' = cong Abs (↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {ℕ.suc q} {ℕ.suc c} {l} {s} (s≤s le) le') ↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {q} {c} {l} {App s s₁} le le' = cong₂ App (↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {q} {c} {l} {s} le le') (↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {q} {c} {l} {s₁} le le') ↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {q} {c} {l} {LabI x} le le' = refl ↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {q} {c} {l} {LabE f s} le le' = cong₂ LabE (f-ext (λ x → f-ext (λ ins → ↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {q} {c} {l} {f x ins} le le'))) (↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]] {n} {k} {q} {c} {l} {s} le le') -- corollary ↑k,sucq[↑1,c[s]]≡↑1,c[↑k,q[s]] : {n : ℕ} {k : ℤ} {q c : ℕ} {s : Exp {n}} → c ≤ᴺ q → + 0 <ᶻ k → ↑ k , ℕ.suc q [ ↑ + 1 , c [ s ] ] ≡ ↑ + 1 , c [ ↑ k , q [ s ] ] ↑k,sucq[↑1,c[s]]≡↑1,c[↑k,q[s]] {n} {k} {q} {c} {s} le le' rewrite (sym (n+1≡sucn{q})) = ↑k,q+l[↑l,c[s]]≡↑l,c[↑k,q[s]]{n}{k}{q}{c}{1}{s} le le' ↑Lab-triv : {n : ℕ} {l : Fin n} (k : ℤ) (q : ℕ) → LabI l ≡ ↑ k , q [ LabI l ] ↑Lab-triv {n} {l} k q = refl ↑ᴺ-triv : {m : ℤ} {n x : ℕ} → x ≥ᴺ n → ↑ᴺ m , n [ x ] ≡ ∣ + x +ᶻ m ∣ ↑ᴺ-triv {m} {n} {x} ge with x <ᴺ? n ... | yes p = contradiction p (≤⇒≯ ge) ... | no ¬p = refl ↑ᴺ⁰-refl : {n : ℕ} {c : ℕ} {x : ℕ} → ↑ᴺ + 0 , c [ x ] ≡ x ↑ᴺ⁰-refl {n} {c} {x} with x <ᴺ? c ... | yes p = refl ... | no ¬p = +-identityʳ x ↑⁰-refl : {n : ℕ} {c : ℕ} {e : Exp {n}} → ↑ + 0 , c [ e ] ≡ e ↑⁰-refl {n} {c} {Var x} = cong Var (↑ᴺ⁰-refl{n}{c}{x}) ↑⁰-refl {n} {c} {Abs e} = cong Abs (↑⁰-refl{n}{ℕ.suc c}{e}) ↑⁰-refl {n} {c} {App e e₁} = cong₂ App (↑⁰-refl{n}{c}{e}) (↑⁰-refl{n}{c}{e₁}) ↑⁰-refl {n} {c} {LabI x} = refl ↑⁰-refl {n} {c} {LabE x e} = cong₂ LabE (f-ext (λ l → f-ext λ i → ↑⁰-refl{n}{c}{x l i})) (↑⁰-refl{n}{c}{e}) --- properties of substitution subst-trivial : {n : ℕ} {x : ℕ} {s : Exp {n}} → [ x ↦ s ] Var x ≡ s subst-trivial {n} {x} {s} with x Data.Nat.≟ x ... | no ¬p = contradiction refl ¬p ... | yes p = refl var-subst-refl : {N n m : ℕ} {neq : n ≢ m} {e : Exp {N}} → [ n ↦ e ] (Var m) ≡ (Var m) var-subst-refl {N} {n} {m} {neq} {e} with _≟ᴺ_ n m | map′ (≡ᵇ⇒≡ m n) (≡⇒≡ᵇ m n) (Data.Bool.Properties.T? (m ≡ᵇ n)) ... | yes p | _ = contradiction p neq ... | no ¬p | yes q = contradiction q (≢-sym ¬p) ... | no ¬p | no ¬q = refl -- inversive lemma for variable in expression relation inv-in-var : {N n m : ℕ} → _∈`_ {N} n (Var m) → n ≡ m inv-in-var {N} {n} {.n} in-Var = refl inv-in-abs : {N n : ℕ} {e : Exp {N}} → _∈`_ {N} n (Abs e) → (ℕ.suc n) ∈` e inv-in-abs {N} {n} {e} (in-Abs i) = i inv-in-app : {N n : ℕ} {e e' : Exp {N}} → _∈`_ {N} n (App e e') → (_∈`_ n e ⊎ _∈`_ n e') inv-in-app {N} {n} {e} {e'} (in-App d) = d inv-in-labe : {N n : ℕ} {s : Subset N} {f : (∀ l → l ∈ s → Exp {N})} {e : Exp {N}} → _∈`_ {N} n (LabE {N} {s} f e) → (∃₂ λ l i → n ∈` (f l i)) ⊎ n ∈` e inv-in-labe {N} {n} {s} {f} {e} (in-LabE d) = d notin-shift : {N n k q : ℕ} {e : Exp {N}} → n ≥ᴺ q → ¬ n ∈` e → ¬ ((n +ᴺ k) ∈` ↑ + k , q [ e ]) notin-shift {N} {n} {k} {q} {Var x} geq j z with x <ᴺ? q ... | no ¬p with x ≟ᴺ n ... | yes p' rewrite p' = contradiction in-Var j ... | no ¬p' with cong (_∸ k) (inv-in-var z) ... | w rewrite (m+n∸n≡m n k) | (m+n∸n≡m x k) = contradiction (sym w) ¬p' notin-shift {N} {n} {k} {q} {Var .(n +ᴺ k)} geq j in-Var | yes p = contradiction geq (<⇒≱ (≤-trans (s≤s (m≤m+n n k)) p)) -- q ≤ n VS ℕ.suc (n + k) ≤ n notin-shift {N} {n} {k} {q} {Abs e} geq j (in-Abs x) = notin-shift (s≤s geq) (λ x₁ → contradiction (in-Abs x₁) j) x notin-shift {N} {n} {k} {q} {App e e₁} geq j z with dm2 (contraposition in-App j) | (inv-in-app z) ... | fst , snd | inj₁ x = notin-shift geq fst x ... | fst , snd | inj₂ y = notin-shift geq snd y notin-shift {N} {n} {k} {q} {LabI x} geq j () notin-shift {N} {n} {k} {q} {LabE f e} geq j z with dm2 (contraposition in-LabE j) | (inv-in-labe z) ... | fst , snd | inj₂ y = notin-shift geq snd y ... | fst , snd | inj₁ (fst₁ , fst₂ , snd₁) = notin-shift geq (¬∃⟶∀¬ (¬∃⟶∀¬ fst fst₁) fst₂) snd₁ -- corollary notin-shift-one : {N n : ℕ} {e : Exp{N}} → ¬ n ∈` e → ¬ (ℕ.suc n ∈` ↑¹[ e ]) notin-shift-one {N} {n} {e} nin rewrite (sym (n+1≡sucn{n})) = notin-shift{N}{n}{1} z≤n nin -- if n ∉ fv(e), then substitution of n does not do anything subst-refl-notin : {N n : ℕ} {e e' : Exp {N}} → ¬ n ∈` e → [ n ↦ e' ] e ≡ e subst-refl-notin {N} {n} {Var x} {e'} nin with x ≟ᴺ n ... | yes p rewrite p = contradiction in-Var nin ... | no ¬p = refl subst-refl-notin {N} {n} {Abs e} {e'} nin = cong Abs (subst-refl-notin (contraposition in-Abs nin)) subst-refl-notin {N} {n} {App e e₁} {e'} nin with dm2 (contraposition in-App nin) ... | fst , snd = cong₂ App (subst-refl-notin fst) (subst-refl-notin snd) subst-refl-notin {N} {n} {LabI x} {e'} nin = refl subst-refl-notin {N} {n} {LabE x e} {e'} nin with dm2 (contraposition in-LabE nin) ... | fst , snd = cong₂ LabE (f-ext (λ l → f-ext (λ x₁ → subst-refl-notin{e' = e'} (¬∃⟶∀¬ (¬∃⟶∀¬ (fst) l) x₁)))) (subst-refl-notin (snd)) notin-subst : {N n : ℕ} {e e' : Exp {N}} → ¬ n ∈` e' → ¬ (n ∈` ([ n ↦ e' ] e)) notin-subst {N} {n} {Var x} {e'} nin with x ≟ᴺ n ... | yes p = nin ... | no ¬p = λ x₁ → contradiction (inv-in-var x₁) (≢-sym ¬p) notin-subst {N} {n} {Abs e} {e'} nin with notin-shift{k = 1} z≤n nin ... | w rewrite (n+1≡sucn{n}) = λ x → notin-subst {n = ℕ.suc n} {e = e} {e' = ↑¹[ e' ]} w (inv-in-abs x) notin-subst {N} {n} {App e e₁} {e'} nin (in-App z) with z ... | inj₁ x = notin-subst{e = e} nin x ... | inj₂ y = notin-subst{e = e₁} nin y notin-subst {N} {n} {LabI x} {e'} nin = λ () notin-subst {N} {n} {LabE f e} {e'} nin (in-LabE z) with z ... | inj₁ (fst , fst₁ , snd) = notin-subst{e = f fst fst₁} nin snd ... | inj₂ y = notin-subst{e = e} nin y subst2-refl-notin : {N n : ℕ} {e e' s : Exp {N}} → ¬ n ∈` e' → [ n ↦ e ] ([ n ↦ e' ] s) ≡ [ n ↦ e' ] s subst2-refl-notin {N} {n} {e} {e'} {s} nin = subst-refl-notin (notin-subst{e = s} nin) -- if n ∈ [ m ↦ s ] e, n ∉ s, then n ≢ m subst-in-neq : {N n m : ℕ} {e s : Exp{N}} → ¬ n ∈` s → n ∈` ([ m ↦ s ] e) → n ≢ m subst-in-neq {N} {n} {m} {Var x} {s} nin ins with x ≟ᴺ m ... | yes p = contradiction ins nin subst-in-neq {N} {.x} {m} {Var x} {s} nin in-Var | no ¬p = ¬p subst-in-neq {N} {n} {m} {Abs e} {s} nin (in-Abs ins) = sucn≢sucm⇒n≢m (subst-in-neq{e = e} (notin-shift-one nin) ins) subst-in-neq {N} {n} {m} {App e e₁} {s} nin (in-App (inj₁ x)) = subst-in-neq{e = e} nin x subst-in-neq {N} {n} {m} {App e e₁} {s} nin (in-App (inj₂ y)) = subst-in-neq{e = e₁} nin y subst-in-neq {N} {n} {m} {LabE f e} {s} nin (in-LabE (inj₁ (fst , fst₁ , snd))) = subst-in-neq{e = f fst fst₁} nin snd subst-in-neq {N} {n} {m} {LabE f e} {s} nin (in-LabE (inj₂ y)) = subst-in-neq{e = e} nin y -- if n ≢ m, n ∈` e, then n ∈` [ m ↦ e' ] e subst-in : {N n m : ℕ} {e e' : Exp {N}} → n ≢ m → n ∈` e → n ∈` ([ m ↦ e' ] e) subst-in {N} {n} {m} {Var x} {e'} neq (in-Var) with n ≟ᴺ m ... | yes p = contradiction p neq ... | no ¬p = in-Var subst-in {N} {n} {m} {Abs e} {e'} neq (in-Abs j) = in-Abs (subst-in (n≢m⇒sucn≢sucm neq) j) subst-in {N} {n} {m} {App e e₁} {e'} neq (in-App z) with z ... | inj₁ x = in-App (inj₁ (subst-in neq x)) ... | inj₂ y = in-App (inj₂ (subst-in neq y)) subst-in {N} {n} {m} {LabE f e} {e'} neq (in-LabE z) with z ... | inj₁ (fst , fst₁ , snd) = in-LabE (inj₁ (fst , (fst₁ , (subst-in neq snd)))) ... | inj₂ y = in-LabE (inj₂ (subst-in neq y)) -- if n ≢ m, n ∉ e', n ∈ [ m ↦ e' ] e, then n ∈ e subst-in-reverse : {N n m : ℕ} {e e' : Exp {N}} → n ≢ m → ¬ (n ∈` e') → n ∈` ([ m ↦ e' ] e) → n ∈` e subst-in-reverse {N} {n} {m} {Var x} {e'} neq nin ins with x ≟ᴺ m ... | yes p = contradiction ins nin ... | no ¬p = ins subst-in-reverse {N} {n} {m} {Abs e} {e'} neq nin (in-Abs ins) = in-Abs (subst-in-reverse (n≢m⇒sucn≢sucm neq) (notin-shift-one{N}{n}{e'} nin) ins) subst-in-reverse {N} {n} {m} {App e e₁} {e'} neq nin (in-App (inj₁ x)) = in-App (inj₁ (subst-in-reverse neq nin x)) subst-in-reverse {N} {n} {m} {App e e₁} {e'} neq nin (in-App (inj₂ y)) = in-App (inj₂ (subst-in-reverse neq nin y)) subst-in-reverse {N} {n} {m} {LabE f e} {e'} neq nin (in-LabE (inj₁ (fst , fst₁ , snd))) = in-LabE (inj₁ (fst , (fst₁ , subst-in-reverse{e = f fst fst₁} neq nin snd))) subst-in-reverse {N} {n} {m} {LabE f e} {e'} neq nin (in-LabE (inj₂ y)) = in-LabE (inj₂ (subst-in-reverse neq nin y)) var-env-< : {N : ℕ} {Γ : Env {N}} {T : Ty} {n : ℕ} (j : n ∶ T ∈ Γ) → n <ᴺ (length Γ) var-env-< {N} {.(T ∷ _)} {T} {.0} here = s≤s z≤n var-env-< {N} {.(_ ∷ _)} {T} {.(ℕ.suc _)} (there j) = s≤s (var-env-< j) -- variables contained in a term are < length of env. free-vars-env-< : {N : ℕ} {e : Exp {N}} {Γ : Env} {T : Ty {N}} → Γ ⊢ e ∶ T → (∀ n → n ∈` e → n <ᴺ length Γ) free-vars-env-< {N} {.(Var n)} {Γ} {T} (TVar x) n in-Var = var-env-< x free-vars-env-< {N} {.(Abs _)} {Γ} {(Fun T₁ T₂)} (TAbs j) n (in-Abs ins) rewrite (length[A∷B]≡suc[length[B]] {lzero} {Ty} {T₁} {Γ}) = ≤-pred (free-vars-env-< j (ℕ.suc n) ins) free-vars-env-< {N} {App e e'} {Γ} {T} (TApp j j') n (in-App z) with z ... | inj₁ x = free-vars-env-< j n x ... | inj₂ y = free-vars-env-< j' n y -- free-vars-env-< {N} {LabE f (LabI l)} {Γ} {T} (TLabEl{scopecheck = s} j j') free-vars-env-< {N} {LabE f (LabI l)} {Γ} {T} (TLabEl{scopecheck = s} j j') n (in-LabE z) with z ... | inj₁ (fst , fst₁ , snd) = s fst fst₁ n snd ... | inj₂ () free-vars-env-< {N} {LabE f (Var m)} {Γ} {T} (TLabEx f' (TVar j)) n (in-LabE z) with n ≟ᴺ m ... | yes p rewrite p = var-env-< j ... | no ¬p with z ... | inj₁ (fst , fst₁ , snd) = free-vars-env-< (f' fst fst₁) n (subst-in ¬p snd) ... | inj₂ (in-Var) = var-env-< j -- closed expressions have no free variables closed-free-vars : {N : ℕ} {e : Exp {N}} {T : Ty {N}} → [] ⊢ e ∶ T → (∀ n → ¬ (n ∈` e)) closed-free-vars {N} {Var x} {T} (TVar ()) closed-free-vars {N} {LabI x} {T} j n () closed-free-vars {N} {Abs e} {.(Fun _ _)} (TAbs j) n (in-Abs x) = contradiction (free-vars-env-< j (ℕ.suc n) x) (≤⇒≯ (s≤s z≤n)) closed-free-vars {N} {e} {T} j n x = contradiction (free-vars-env-< j n x) (≤⇒≯ z≤n) -- App & LabE have the same proof -- shifting with a threshold above number of free variables has no effect shift-env-size : {n : ℕ} {k : ℤ} {q : ℕ} {e : Exp {n}} → (∀ n → n ∈` e → n <ᴺ q) → ↑ k , q [ e ] ≡ e shift-env-size {n} {k} {q} {Var x} lmap with x <ᴺ? q ... | yes p = refl ... | no ¬p = contradiction (lmap x in-Var) ¬p shift-env-size {n} {k} {q} {Abs e} lmap = cong Abs (shift-env-size (extr lmap)) where extr : (∀ n → n ∈` Abs e → n <ᴺ q) → (∀ n → n ∈` e → n <ᴺ ℕ.suc q) extr lmap zero ins = s≤s z≤n extr lmap (ℕ.suc n) ins = s≤s (lmap n (in-Abs ins)) shift-env-size {n} {k} {q} {App e e'} lmap = cong₂ App (shift-env-size (extr lmap)) (shift-env-size(extr' lmap)) where extr : (∀ n → n ∈` App e e' → n <ᴺ q) → (∀ n → n ∈` e → n <ᴺ q) extr lmap n ins = lmap n (in-App (inj₁ ins)) extr' : (∀ n → n ∈` App e e' → n <ᴺ q) → (∀ n → n ∈` e' → n <ᴺ q) extr' lmap n ins = lmap n (in-App (inj₂ ins)) shift-env-size {n} {k} {q} {LabI x} lmap = refl shift-env-size {n} {k} {q} {LabE{s = s} f e} lmap = cong₂ LabE (f-ext λ l' → (f-ext λ x → shift-env-size (extr lmap l' x))) (shift-env-size (extr' lmap)) where extr : (∀ n → n ∈` LabE f e → n <ᴺ q) → (l : Fin n) → (x : l ∈ s) → (∀ n → n ∈` f l x → n <ᴺ q) extr lmap l x n ins = lmap n (in-LabE (inj₁ (l , (x , ins)))) extr' : (∀ n → n ∈` LabE f e → n <ᴺ q) → (∀ n → n ∈` e → n <ᴺ q) extr' lmap n ins = lmap n (in-LabE (inj₂ ins)) -- shifting has no effect on closed terms (corollary of shift-env-size) closed-no-shift : {n : ℕ} {k : ℤ} {q : ℕ} {e : Exp {n}} {T : Ty {n}} → [] ⊢ e ∶ T → ↑ k , q [ e ] ≡ e closed-no-shift {n} {k} {zero} {e} {T} j = shift-env-size (free-vars-env-< j) closed-no-shift {n} {k} {ℕ.suc q} {e} {T} j = shift-env-size λ n i → <-trans (free-vars-env-< j n i) (s≤s z≤n) -- subst-change-in : {N n m : ℕ} {e s s' : Exp{N}} → ¬ (n ∈` s) × ¬ (n ∈` s') → n ∈` ([ m ↦ s ] e) → n ∈` ([ m ↦ s' ] e) subst-change-in {N} {n} {m} {Var x} {s} {s'} (fst , snd) ins with x ≟ᴺ m ... | yes eq = contradiction ins fst ... | no ¬eq = ins subst-change-in {N} {n} {m} {Abs e} {s} {s'} (fst , snd) (in-Abs ins) = in-Abs (subst-change-in{N}{ℕ.suc n}{ℕ.suc m}{e} (notin-shift-one{N}{n}{s} fst , notin-shift-one{N}{n}{s'} snd) ins) subst-change-in {N} {n} {m} {App e e₁} {s} {s'} p (in-App (inj₁ x)) = in-App (inj₁ (subst-change-in{N}{n}{m}{e} p x)) subst-change-in {N} {n} {m} {App e e₁} {s} {s'} p (in-App (inj₂ y)) = in-App (inj₂ (subst-change-in{N}{n}{m}{e₁} p y)) subst-change-in {N} {n} {m} {LabE f e} {s} {s'} p (in-LabE (inj₁ (fst , fst₁ , snd))) = in-LabE (inj₁ (fst , (fst₁ , (subst-change-in{N}{n}{m}{f fst fst₁}{s}{s'} p snd)))) subst-change-in {N} {n} {m} {LabE f e} {s} {s'} p (in-LabE (inj₂ y)) = in-LabE (inj₂ (subst-change-in {N} {n} {m} {e} p y)) -- swapping of substitutions A & B if variables of A are not free in substitution term of B and vice versa subst-subst-swap : {N n m : ℕ} {e e' s : Exp {N}} → n ≢ m → ¬ n ∈` e' → ¬ m ∈` e → [ n ↦ e ] ([ m ↦ e' ] s) ≡ [ m ↦ e' ] ([ n ↦ e ] s) subst-subst-swap {N} {n} {m} {e} {e'} {Var x} neq nin nin' with x ≟ᴺ m | x ≟ᴺ n ... | yes p | yes p' = contradiction (≡-trans (sym p') p) neq ... | yes p | no ¬p' with x ≟ᴺ m ... | yes p'' = subst-refl-notin nin ... | no ¬p'' = contradiction p ¬p'' subst-subst-swap {N} {n} {m} {e} {e'} {Var x} neq nin nin' | no ¬p | yes p' with x ≟ᴺ n ... | yes p'' = sym (subst-refl-notin nin') ... | no ¬p'' = contradiction p' ¬p'' subst-subst-swap {N} {n} {m} {e} {e'} {Var x} neq nin nin' | no ¬p | no ¬p' with x ≟ᴺ n | x ≟ᴺ m ... | yes p'' | _ = contradiction p'' ¬p' ... | _ | yes p''' = contradiction p''' ¬p ... | no p'' | no ¬p''' = refl subst-subst-swap {N} {n} {m} {e} {e'} {Abs s} neq nin nin' with (notin-shift{n = n}{1}{0} z≤n nin) | (notin-shift{n = m}{1}{0} z≤n nin') ... | w | w' rewrite (n+1≡sucn{n}) | (n+1≡sucn{m}) = cong Abs (subst-subst-swap{s = s} (n≢m⇒sucn≢sucm neq) w w') subst-subst-swap {N} {n} {m} {e} {e'} {App s s₁} neq nin nin' = cong₂ App (subst-subst-swap{s = s} neq nin nin') (subst-subst-swap{s = s₁} neq nin nin') subst-subst-swap {N} {n} {m} {e} {e'} {LabI x} neq nin nin' = refl subst-subst-swap {N} {n} {m} {e} {e'} {LabE f s} neq nin nin' = cong₂ LabE (f-ext (λ l → f-ext (λ x → subst-subst-swap{s = f l x} neq nin nin' ))) (subst-subst-swap{s = s} neq nin nin') -- this should be true for all k, but limiting to positive k makes the proof simpler aux-calc-3 : {m x : ℕ} {k : ℤ} → k >ᶻ + 0 → ∣ + m +ᶻ k ∣ ≡ ∣ + x +ᶻ k ∣ → m ≡ x aux-calc-3 {m} {x} {+_ n} gt eqv = +-cancelʳ-≡ m x eqv aux-calc-4 : {m x : ℕ} {k : ℤ} → k >ᶻ + 0 → m ≤ᴺ x → m <ᴺ ∣ + x +ᶻ k ∣ aux-calc-4 {m} {x} {+_ zero} (+<+ ()) aux-calc-4 {m} {x} {+[1+ n ]} (+<+ (s≤s z≤n)) leq = a≤b<c⇒a<c leq (m<m+n x {ℕ.suc n} (s≤s z≤n)) subst-shift-swap : {n : ℕ} {k : ℤ} {x q : ℕ} {s e : Exp {n}} → k >ᶻ + 0 → ↑ k , q [ [ x ↦ e ] s ] ≡ [ ↑ᴺ k , q [ x ] ↦ ↑ k , q [ e ] ] ↑ k , q [ s ] subst-shift-swap {n} {k} {x} {q} {Var m} {e} gt with m ≟ᴺ x ... | yes p with m <ᴺ? q | x <ᴺ? q ... | yes p' | yes p'' with m ≟ᴺ x ... | yes p''' = refl ... | no ¬p''' = contradiction p ¬p''' subst-shift-swap {n} {k} {x} {q} {Var m} {e} gt | yes p | yes p' | no ¬p'' rewrite (cong ℕ.suc p) = contradiction p' ¬p'' subst-shift-swap {n} {k} {x} {q} {Var m} {e} gt | yes p | no ¬p' | yes p'' rewrite (cong ℕ.suc p) = contradiction p'' ¬p' subst-shift-swap {n} {k} {x} {q} {Var m} {e} gt | yes p | no ¬p' | no ¬p'' with ∣ + m +ᶻ k ∣ ≟ᴺ ∣ + x +ᶻ k ∣ ... | yes p''' = refl ... | no ¬p''' rewrite p = contradiction refl ¬p''' subst-shift-swap {n} {k} {x} {q} {Var m} {e} gt | no ¬p with m <ᴺ? q | x <ᴺ? q ... | yes p' | yes p'' with m ≟ᴺ x ... | yes p''' = contradiction p''' ¬p ... | no ¬p''' = refl subst-shift-swap {n} {k} {x} {q} {Var m} {e} gt | no ¬p | yes p' | no ¬p'' with m ≟ᴺ ∣ + x +ᶻ k ∣ ... | yes p''' = contradiction p''' (<⇒≢ (aux-calc-4 gt (≤-pred (≤-trans p' (≰⇒≥ ¬p''))))) ... | no ¬p''' = refl subst-shift-swap {n} {k} {x} {q} {Var m} {e} gt | no ¬p | no ¬p' | yes p'' with ∣ + m +ᶻ k ∣ ≟ᴺ x ... | yes p''' = contradiction p''' (≢-sym (<⇒≢ (aux-calc-4{x}{m}{k} gt (≤-pred (≤-trans p'' (≰⇒≥ ¬p')))))) ... | no ¬p''' = refl subst-shift-swap {n} {k} {x} {q} {Var m} {e} gt | no ¬p | no ¬p' | no ¬p'' with ∣ + m +ᶻ k ∣ ≟ᴺ ∣ + x +ᶻ k ∣ ... | yes p''' = contradiction p''' (contraposition (aux-calc-3 gt) ¬p) ... | no ¬p''' = refl subst-shift-swap {n} {k} {x} {q} {Abs s} {e} gt with (subst-shift-swap{n}{k}{ℕ.suc x}{ℕ.suc q}{s}{↑¹[ e ]} gt) ... | w rewrite (↑k,sucq[↑1,c[s]]≡↑1,c[↑k,q[s]] {n} {k} {q} {0} {e} z≤n gt) | (suc[↑ᴺk,l[x]]≡↑ᴺk,sucl[sucx] {k} {q} {x} gt) = cong Abs w subst-shift-swap {n} {k} {x} {q} {App s₁ s₂} {e} gt = cong₂ App (subst-shift-swap {n} {k} {x} {q} {s₁} {e} gt) (subst-shift-swap {n} {k} {x} {q} {s₂} {e} gt) subst-shift-swap {n} {k} {x} {q} {LabI ins} {e} gt = refl subst-shift-swap {n} {k} {x} {q} {LabE f s} {e} gt = cong₂ LabE (f-ext (λ l → f-ext (λ ins → subst-shift-swap {n} {k} {x} {q} {f l ins} {e} gt))) (subst-shift-swap {n} {k} {x} {q} {s} {e} gt) --- properties and manipulation of environments -- type to determine whether var type judgement in env. (Δ ++ Γ) is in Δ or Γ data extract-env-or {n : ℕ} {Δ Γ : Env {n}} {T : Ty} {x : ℕ} : Set where in-Δ : x ∶ T ∈ Δ → extract-env-or -- x ≥ length Δ makes sure that x really is in Γ; e.g. -- x = 1, Δ = (S ∷ T), Γ = (T ∷ Γ'); here 1 ∶ T ∈ Δ as well as (1 ∸ 2) ≡ 0 ∶ T ∈ Γ in-Γ : (x ≥ᴺ length Δ) → (x ∸ length Δ) ∶ T ∈ Γ → extract-env-or extract : {n : ℕ} {Δ Γ : Env {n}} {T : Ty} {x : ℕ} (j : x ∶ T ∈ (Δ ++ Γ)) → extract-env-or{n}{Δ}{Γ}{T}{x} extract {n} {[]} {Γ} {T} {x} j = in-Γ z≤n j extract {n} {x₁ ∷ Δ} {Γ} {.x₁} {.0} here = in-Δ here extract {n} {x₁ ∷ Δ} {Γ} {T} {ℕ.suc x} (there j) with extract {n} {Δ} {Γ} {T} {x} j ... | in-Δ j' = in-Δ (there j') ... | in-Γ ge j'' = in-Γ (s≤s ge) j'' ext-behind : {n : ℕ} {Δ Γ : Env {n}} {T : Ty} {x : ℕ} → x ∶ T ∈ Δ → x ∶ T ∈ (Δ ++ Γ) ext-behind here = here ext-behind (there j) = there (ext-behind j) ext-front : {N n : ℕ} {Γ Δ : Env{N}} {S : Ty} → n ∶ S ∈ Γ → (n +ᴺ (length Δ)) ∶ S ∈ (Δ ++ Γ) ext-front {N} {n} {Γ} {[]} {S} j rewrite (n+length[]≡n{A = Ty {N}}{n = n}) = j ext-front {N} {n} {Γ} {T ∷ Δ} {S} j rewrite (+-suc n (foldr (λ _ → ℕ.suc) 0 Δ)) = there (ext-front j) swap-env-behind : {n : ℕ} {Γ Δ : Env {n}} {T : Ty} → 0 ∶ T ∈ (T ∷ Γ) → 0 ∶ T ∈ (T ∷ Δ) swap-env-behind {n}{Γ} {Δ} {T} j = here swap-type : {n : ℕ} {Δ ∇ Γ : Env {n}} {T : Ty} → (length Δ) ∶ T ∈ (Δ ++ T ∷ ∇ ++ Γ) → (length Δ +ᴺ length ∇) ∶ T ∈ (Δ ++ ∇ ++ T ∷ Γ) swap-type {n} {Δ} {∇} {Γ} {T} j with extract{n}{Δ}{T ∷ ∇ ++ Γ} j ... | in-Δ x = contradiction (var-env-< {n}{Δ} {T} x) (<-irrefl refl) ... | in-Γ le j' with extract{n}{T ∷ ∇}{Γ} j' ... | in-Δ j'' rewrite (n∸n≡0 (length Δ)) | (sym (length[A++B]≡length[A]+length[B]{lzero}{Ty}{Δ}{∇})) | (sym (++-assoc{lzero}{Ty}{Δ}{∇}{T ∷ Γ})) = ext-front{n}{0}{T ∷ Γ}{Δ ++ ∇}{T} (swap-env-behind{n}{∇}{Γ}{T} j'') ... | in-Γ le' j'' rewrite (length[A∷B]≡suc[length[B]]{lzero}{Ty}{T}{∇}) | (n∸n≡0 (length Δ)) = contradiction le' (<⇒≱ (s≤s z≤n)) env-pred : {n : ℕ} {Γ : Env {n}} {S T : Ty} {y : ℕ} {gt : y ≢ 0} → y ∶ T ∈ (S ∷ Γ) → ∣ y ⊖ 1 ∣ ∶ T ∈ Γ env-pred {n} {Γ} {S} {.S} {.0} {gt} here = contradiction refl gt env-pred {n} {Γ} {S} {T} {.(ℕ.suc _)} {gt} (there j) = j env-type-equiv-here : {n : ℕ} {Γ : Env {n}} {S T : Ty} → 0 ∶ T ∈ (S ∷ Γ) → T ≡ S env-type-equiv-here {n} {Γ} {S} {.S} here = refl env-type-uniq : {N n : ℕ} {Γ : Env {N}} {S T : Ty} → n ∶ T ∈ Γ → n ∶ S ∈ Γ → T ≡ S env-type-uniq {N} {.0} {.(S ∷ _)} {S} {.S} here here = refl env-type-uniq {N} {(ℕ.suc n)} {(A ∷ Γ)} {S} {T} (there j) (there j') = env-type-uniq {N} {n} {Γ} {S} {T} j j' env-type-equiv : {n : ℕ} {Δ ∇ : Env {n}} {S T : Ty} → length Δ ∶ T ∈ (Δ ++ S ∷ ∇) → T ≡ S env-type-equiv {n} {Δ} {∇} {S} {T} j with extract{n}{Δ}{S ∷ ∇} j ... | in-Δ x = contradiction (var-env-< x) (≤⇒≯ ≤-refl) ... | in-Γ x j' rewrite (n∸n≡0 (length Δ)) = env-type-equiv-here {n} {∇} {S} {T} j' env-type-equiv-j : {N : ℕ} {Γ : Env {N}} {S T : Ty} {n : ℕ} → T ≡ S → n ∶ T ∈ Γ → n ∶ S ∈ Γ env-type-equiv-j {N} {Γ} {S} {T} {n} eq j rewrite eq = j -- extension of environment -- lemma required for ∈` ext-∈` : {N m k q : ℕ} {e : Exp {N}} → (∀ n → n ∈` e → n <ᴺ m) → (∀ n → n ∈` ↑ + k , q [ e ] → n <ᴺ m +ᴺ k) ext-∈` {N} {m} {k} {q} {Var x} f n ins with x <ᴺ? q ... | yes p = ≤-trans (f n ins) (≤-stepsʳ{m}{m} k ≤-refl) ext-∈` {N} {m} {k} {q} {Var x} f .(x +ᴺ k) in-Var | no ¬p = Data.Nat.Properties.+-monoˡ-≤ k (f x in-Var) ext-∈` {N} {m} {k} {q} {Abs e} f n (in-Abs ins) = ≤-pred (ext-∈` {N} {ℕ.suc m} {k} {ℕ.suc q} {e = e} (extr f) (ℕ.suc n) ins) where extr : (∀ n → n ∈` Abs e → n <ᴺ m) → (∀ n → n ∈` e → n <ᴺ ℕ.suc m) extr f zero ins = s≤s z≤n extr f (ℕ.suc n) ins = s≤s (f n (in-Abs ins)) ext-∈` {N} {m} {k} {q} {App e e₁} f n (in-App (inj₁ x)) = ext-∈`{N}{m}{k}{q}{e} (extr f) n x where extr : (∀ n → n ∈` App e e₁ → n <ᴺ m) → (∀ n → n ∈` e → n <ᴺ m) extr f n ins = f n (in-App (inj₁ ins)) ext-∈` {N} {m} {k} {q} {App e e₁} f n (in-App (inj₂ y)) = ext-∈`{N}{m}{k}{q}{e₁} (extr f) n y where extr : (∀ n → n ∈` App e e₁ → n <ᴺ m) → (∀ n → n ∈` e₁ → n <ᴺ m) extr f n ins = f n (in-App (inj₂ ins)) ext-∈` {N} {m} {k} {q} {LabE f₁ e} f n (in-LabE (inj₁ (fst , fst₁ , snd))) = ext-∈`{N}{m}{k}{q}{f₁ fst fst₁} (extr f) n snd where extr : (∀ n → n ∈` LabE f₁ e → n <ᴺ m) → (∀ n → n ∈` f₁ fst fst₁ → n <ᴺ m) extr f n ins = f n (in-LabE (inj₁ (fst , (fst₁ , ins)))) ext-∈` {N} {m} {k} {q} {LabE f₁ e} f n (in-LabE (inj₂ y)) = ext-∈`{N}{m}{k}{q}{e} (extr f) n y where extr : (∀ n → n ∈` LabE f₁ e → n <ᴺ m) → (∀ n → n ∈` e → n <ᴺ m) extr f n ins = f n (in-LabE (inj₂ ins)) ext : {N : ℕ} {Γ Δ ∇ : Env {N}} {S : Ty} {s : Exp} → (∇ ++ Γ) ⊢ s ∶ S → (∇ ++ Δ ++ Γ) ⊢ ↑ (ℤ.pos (length Δ)) , length ∇ [ s ] ∶ S ext {N} {Γ} {Δ} {∇} (TVar {m = n} x) with extract{N}{∇}{Γ} x ... | in-Δ x₁ with n <ᴺ? length ∇ ... | yes p = TVar (ext-behind x₁) ... | no ¬p = contradiction (var-env-< x₁) ¬p ext {N} {Γ} {Δ} {∇} (TVar {m = n} x) | in-Γ x₁ x₂ with n <ᴺ? length ∇ ... | yes p = contradiction x₁ (<⇒≱ p) ... | no ¬p with (ext-front{N}{n ∸ length ∇}{Γ}{∇ ++ Δ} x₂) ... | w rewrite (length[A++B]≡length[A]+length[B]{lzero}{Ty}{∇}{Δ}) | (sym (+-assoc (n ∸ length ∇) (length ∇) (length Δ))) | (m∸n+n≡m{n}{length ∇} (≮⇒≥ ¬p)) | (++-assoc{lzero}{Ty}{∇}{Δ}{Γ}) = TVar w ext {N} {Γ} {Δ} {∇} {Fun T₁ T₂} {Abs e} (TAbs j) = TAbs (ext{N}{Γ}{Δ}{T₁ ∷ ∇} j) ext {N} {Γ} {Δ} {∇} {S} {App s₁ s₂} (TApp{T₁ = T₁} j₁ j₂) = TApp (ext{N}{Γ}{Δ}{∇}{Fun T₁ S} j₁) (ext{N}{Γ}{Δ}{∇}{T₁} j₂) ext {N} {Γ} {Δ} {∇} {S} {LabI l} (TLabI{x = x}{s} ins) = TLabI{x = x}{s} ins ext {N} {Γ} {Δ} {∇} {S} {LabE f e} (TLabEl{ins = ins}{f = .f}{scopecheck = s} j j') = TLabEl{ins = ins} {scopecheck = λ l i n x₁ → rw n (ext-∈`{N}{length (∇ ++ Γ)}{length Δ}{length ∇}{f l i} (s l i) n x₁)} (ext{N}{Γ}{Δ}{∇} j) (ext{N}{Γ}{Δ}{∇} j') where rw : ∀ n → n <ᴺ length (∇ ++ Γ) +ᴺ length Δ → n <ᴺ length (∇ ++ Δ ++ Γ) rw n a rewrite (length[A++B]≡length[A]+length[B]{lzero}{Ty}{∇}{Γ}) | (+-assoc (length ∇) (length Γ) (length Δ)) | (+-comm (length Γ) (length Δ)) | sym (length[A++B]≡length[A]+length[B]{lzero}{Ty}{Δ}{Γ}) | sym (length[A++B]≡length[A]+length[B]{lzero}{Ty}{∇}{Δ ++ Γ}) = a ext {N} {Γ} {[]} {∇} {S} {LabE f .(Var m)} (TLabEx {s = s} {f = .f} f' (TVar {m = m} x)) rewrite (↑ᴺ⁰-refl{N}{length ∇}{m}) | (f-ext (λ l → f-ext (λ i → ↑⁰-refl{N}{length ∇}{f l i}))) = TLabEx f' (TVar x) -- required lemma needs length Δ > 0, hence the case split ext {N} {Γ} {t ∷ Δ} {∇} {S} {LabE f .(Var m)} (TLabEx {s = s} {f = .f} f' (TVar {m = m} x)) with extract{N}{∇}{Γ} x ... | in-Δ x₁ with m <ᴺ? length ∇ ... | no ¬p = contradiction (var-env-< x₁) ¬p ... | yes p with (λ l i → ext{N}{Γ}{t ∷ Δ}{∇} (f' l i)) ... | w = TLabEx (rw w) (TVar (ext-behind x₁)) -- if m < k, [ m → ↑ₖ x ] (↑ₖ s) ≡ ↑ₖ ([ m ↦ x ] s) where rw : ((l : Fin N) → (i : l ∈ s) → (∇ ++ (t ∷ Δ) ++ Γ) ⊢ ↑ + length (t ∷ Δ) , length ∇ [ [ m ↦ LabI l ] (f l i) ] ∶ S) → ((l : Fin N) → (i : l ∈ s) → (∇ ++ (t ∷ Δ) ++ Γ) ⊢ [ m ↦ LabI l ] ↑ + length (t ∷ Δ) , length ∇ [ f l i ] ∶ S) rw q l i with q l i ... | w rewrite (subst-shift-swap{N}{+ length (t ∷ Δ)}{m}{length ∇}{f l i}{LabI l} (+<+ (s≤s z≤n))) with m <ᴺ? length ∇ ... | yes p = w ... | no ¬p = contradiction p ¬p ext {N} {Γ} {t ∷ Δ} {∇} {S} {LabE f .(Var _)} (TLabEx {s = s}{f = .f} f' (TVar{m = m} x)) | in-Γ x₁ x₂ with m <ᴺ? length ∇ ... | yes p = contradiction x₁ (<⇒≱ p) ... | no ¬p with (λ l i → (ext{N}{Γ}{t ∷ Δ}{∇} (f' l i))) | (ext-front{N}{m ∸ length ∇}{Γ}{∇ ++ (t ∷ Δ)} x₂) ... | w | w' rewrite (length[A++B]≡length[A]+length[B]{lzero}{Ty}{∇}{t ∷ Δ}) | (sym (+-assoc (m ∸ length ∇) (length ∇) (length (t ∷ Δ)))) | (m∸n+n≡m{m}{length ∇} (≮⇒≥ ¬p)) | (++-assoc{lzero}{Ty}{∇}{t ∷ Δ}{Γ}) = TLabEx (rw w) (TVar w') where rw : ((l : Fin N) → (i : l ∈ s) → ((∇ ++ (t ∷ Δ) ++ Γ) ⊢ ↑ + length (t ∷ Δ) , length ∇ [ [ m ↦ LabI l ] f l i ] ∶ S)) → ((l : Fin N) → (i : l ∈ s) → ((∇ ++ (t ∷ Δ) ++ Γ) ⊢ [ m +ᴺ length (t ∷ Δ) ↦ LabI l ] ↑ + length (t ∷ Δ) , length ∇ [ f l i ] ∶ S)) rw q l i with q l i ... | w rewrite (subst-shift-swap {N} {+ length (t ∷ Δ)} {m} {length ∇} {f l i} {LabI l} (+<+ (s≤s z≤n))) with m <ᴺ? length ∇ ... | yes p = contradiction x₁ (<⇒≱ p) ... | no ¬p = w ext-empty : {N : ℕ} {Γ : Env {N}} {T : Ty} {e : Exp} → [] ⊢ e ∶ T → Γ ⊢ e ∶ T ext-empty {N} {Γ} {T} {e} j with ext{N}{[]}{Γ}{[]} j ... | w rewrite (closed-no-shift{N}{+ length Γ}{0}{e}{T} j) | (A++[]≡A{lzero}{Ty}{Γ}) = w -- uniqueness of ∈ ∈-eq : {N : ℕ} {s : Subset N} {l : Fin N} → (ins : l ∈ s) → (ins' : l ∈ s) → ins ≡ ins' ∈-eq {ℕ.suc n} {.(true ∷ _)} {zero} here here = refl ∈-eq {ℕ.suc n} {(x ∷ s)} {Fin.suc l} (there j) (there j') = cong there (∈-eq j j') --- general typing properties subset-eq : {n : ℕ} {s s' : Subset n} → Label s ≡ Label s' → s ≡ s' subset-eq {n} {s} {.s} refl = refl ---- progress and preservation -- progress theorem, i.e. a well-typed closed expression is either a value -- or can be reduced further data Progress {n : ℕ} (e : Exp {n}) {T : Ty} {j : [] ⊢ e ∶ T} : Set where step : {e' : Exp{n}} → e ⇒ e' → Progress e value : Val e → Progress e progress : {n : ℕ} (e : Exp {n}) {T : Ty} {j : [] ⊢ e ∶ T} → Progress e {T} {j} progress (Var x) {T} {TVar ()} progress (Abs e) = value VFun progress (App e e₁) {T} {TApp{T₁ = T₁}{T₂ = .T} j j₁} with progress e {Fun T₁ T} {j} ... | step x = step (ξ-App1 x) ... | value VFun with progress e₁ {T₁} {j₁} ... | step x₁ = step (ξ-App2 VFun x₁) ... | value x₁ = step (β-App x₁) progress (LabI ins) {Label s} {TLabI l} = value VLab progress (LabE f (LabI l)) {T} {j = TLabEl{ins = ins} f' j} = step (β-LabE ins) progress {n} (LabE f (Var m)) {T} {TLabEx f' (TVar ())} --- preserve-subst' : {n : ℕ} {T S : Ty {n} } {Δ : Env {n}} {e s : Exp {n}} {v : Val s} (j : (Δ ++ S ∷ []) ⊢ e ∶ T) (j' : [] ⊢ s ∶ S) → Δ ⊢ [ length Δ ↦ s ] e ∶ T preserve-subst' {n} {T} {S} {Δ} {(Var m)} {s} {v} (TVar{m} x) j' with extract{n}{Δ}{S ∷ []}{T}{m} x ... | in-Δ x₁ with m ≟ᴺ length Δ ... | yes p = contradiction p (<⇒≢ (var-env-< x₁)) ... | no ¬p with m <ᴺ? length Δ ... | yes p' = TVar x₁ ... | no ¬p' = contradiction (var-env-< x₁) ¬p' preserve-subst' {n} {T} {S} {Δ} {(Var m)} {s} {v} (TVar{m} x) j' | in-Γ x₁ x₂ with m ≟ᴺ length Δ ... | yes p with ext{n}{[]}{Δ} j' ... | w rewrite p | (env-type-equiv x) | (closed-no-shift {n} {+ length Δ} {0} {s} j') | (A++[]≡A{lzero}{Ty}{Δ}) = w preserve-subst' {n} {T} {S} {Δ} {(Var m)} {s} {v} (TVar{m} x) j' | in-Γ x₁ x₂ | no ¬p with m <ᴺ? length Δ ... | yes p' = contradiction x₁ (<⇒≱ p') ... | no ¬p' with (<⇒≱ (≤∧≢⇒< (≤-step (≤∧≢⇒< (≮⇒≥ ¬p') (≢-sym ¬p))) (≢-sym (n≢m⇒sucn≢sucm ¬p)))) ... | w = contradiction (var-env-< x) (aux w) where aux : ¬ (ℕ.suc m ≤ᴺ ℕ.suc (length Δ)) → ¬ (ℕ.suc m ≤ᴺ length (Δ ++ S ∷ [])) aux t rewrite (length[A++B]≡length[A]+length[B]{A = Δ}{B = S ∷ []}) | (n+1≡sucn{length Δ}) = t preserve-subst' {n} {.(Fun _ _)} {S} {Δ} {(Abs e')} {s} {v} (TAbs{T₁ = T₁}{T₂} j) j' with preserve-subst'{n}{T₂}{S}{T₁ ∷ Δ}{e'}{s}{v} j j' ... | w rewrite (closed-no-shift {n} {+ 1} {0} {s} j') = TAbs w preserve-subst' {n} {T} {S} {Δ} {(App e e')} {s} {v} (TApp j j₁) j' = TApp (preserve-subst'{v = v} j j') (preserve-subst'{v = v} j₁ j') preserve-subst' {n} {T} {S} {Δ} {LabI x} {s} {v} (TLabI ins) j' = TLabI ins preserve-subst' {n} {T} {S} {Δ} {LabE{s = s'} f (LabI x)} {s} {v} (TLabEl{ins = ins}{scopecheck = sc} j j') j'' = TLabEl{ins = ins}{scopecheck = scopecheck} (preserve-subst'{v = v} j j'') (TLabI ins) where scopecheck : (l : Fin n) (i : l ∈ s') (n' : ℕ) → n' ∈` ([ length Δ ↦ s ] f l i) → n' <ᴺ length Δ scopecheck l i n' ins with subst-in-neq{n}{n'}{length Δ}{f l i}{s} (closed-free-vars j'' n') ins ... | w with (sc l i n' (subst-in-reverse{n}{n'}{length Δ}{e' = s} w (closed-free-vars j'' n') ins)) ... | w' rewrite (length[A++B∷[]]≡suc[length[A]]{lzero}{Ty}{Δ}{S}) = ≤∧≢⇒< (≤-pred w') w preserve-subst' {n} {T} {.(Fun _ _)} {Δ} {LabE f (Var m)} {Abs e} {VFun} (TLabEx f' (TVar{T = Label s} z)) (TAbs j') with m ≟ᴺ length Δ | preserve-subst'{v = VFun} (TVar z) (TAbs j') ... | yes p | _ rewrite p = contradiction (env-type-equiv z) λ () ... | no ¬p | w = TLabEx (rw (λ l i → preserve-subst'{v = VFun} (f' l i) (TAbs j'))) w where rw : ((l : Fin n) (i : l ∈ s) → Δ ⊢ [ length Δ ↦ Abs e ] ([ m ↦ LabI l ] f l i) ∶ T) → ((l : Fin n) (i : l ∈ s) → Δ ⊢ [ m ↦ LabI l ] ([ length Δ ↦ Abs e ] f l i) ∶ T) rw ρ l i with ρ l i ... | w rewrite sym (subst-subst-swap{n}{length Δ}{m}{Abs e}{LabI l}{f l i} (≢-sym ¬p) (λ ()) (closed-free-vars (TAbs j') m)) = w preserve-subst' {n} {T} {(Label s')} {Δ} {LabE f (Var m)} {LabI x} {VLab} (TLabEx f' (TVar{T = Label s} z)) (TLabI{s = s'} ins) with m ≟ᴺ length Δ | preserve-subst'{v = VLab} (TVar z) (TLabI ins) ... | yes p | w rewrite p | subset-eq (env-type-equiv z) = TLabEl{f = λ l i → [ length Δ ↦ LabI x ] (f l i)}{scopecheck } (rw{e = f x ins} (preserve-subst'{v = VLab} (f' x ins) (TLabI{s = s'} ins))) w where -- agda didn't let me rewrite this directly rw : {e : Exp} → (Δ ⊢ [ length Δ ↦ LabI x ] ([ length Δ ↦ LabI x ] e) ∶ T) → ( Δ ⊢ [ length Δ ↦ LabI x ] e ∶ T) rw {e} j rewrite sym (subst2-refl-notin{n}{length Δ}{LabI x}{LabI x}{e} (λ ())) = j -- if n ∈` [length Δ ↦ LabI x] (f l i), then also n ∈` [length Δ ↦ LabI l] (f l i), since both LabI l and LabI x are closed -- if n ∈` [length Δ ↦ LabI l] (f l i), then n < length (Δ ++ (S ∷ [])), we get this from f' ((Δ ++ S ∷ []) ⊢ [length Δ ↦ LabI l] (f l i) ∶ T) and free-vars-env-< -- if n ∈` [length Δ ↦ LabI l] (f l i), then also n ≢ (length Δ), since LabI closed -- hence n < length (Δ ++ (S ∷ [])) = length Δ + 1 ⇒ n ≤ length Δ, n ≤ length Δ and n ≢ length Δ implies n < length Δ scopecheck : (l : Fin n) (i : l ∈ s') (n' : ℕ) → n' ∈` ([ length Δ ↦ LabI x ] f l i) → n' <ᴺ length Δ scopecheck l i n' ins with (free-vars-env-< (f' l i) n' (subst-change-in{n}{n'}{length Δ}{f l i}{LabI x}{LabI l} ((λ ()) , (λ ())) ins)) ... | w rewrite (length[A++B∷[]]≡suc[length[A]]{lzero}{Ty}{Δ}{Label s'})= ≤∧≢⇒< (≤-pred w) (subst-in-neq{n}{n'}{length Δ}{f l i}{LabI x} (λ ()) ins) ... | no ¬p | w = TLabEx (rw λ l i → preserve-subst'{v = VLab} (f' l i) (TLabI ins)) w where rw : ((l : Fin n) (i : l ∈ s) → Δ ⊢ [ length Δ ↦ LabI x ] ([ m ↦ LabI l ] f l i) ∶ T) → ((l : Fin n) (i : l ∈ s) → Δ ⊢ [ m ↦ LabI l ] ([ length Δ ↦ LabI x ] f l i) ∶ T) rw ρ l i with ρ l i ... | w rewrite sym (subst-subst-swap{n}{length Δ}{m}{LabI x}{LabI l}{f l i} (≢-sym ¬p) (λ ()) (closed-free-vars (TLabI ins) m)) = w preserve' : {n : ℕ} {T : Ty {n}} (e e' : Exp) (j : [] ⊢ e ∶ T) (r : e ⇒ e') → [] ⊢ e' ∶ T preserve' {n} {T} .(App e₁ _) .(App e₁' _) (TApp j j') (ξ-App1 {e₁ = e₁} {e₁' = e₁'} r) = TApp (preserve' e₁ e₁' j r) j' preserve' {n} {T} .(App _ _) .(App _ _) (TApp j j') (ξ-App2{e = e}{e' = e'} x r) = TApp j (preserve' e e' j' r) preserve' {n} {T} (App (Abs e) s') .(↑ -[1+ 0 ] , 0 [ [ 0 ↦ ↑ + 1 , 0 [ s' ] ] e ]) (TApp (TAbs j) j₁) (β-App x) rewrite (closed-no-shift {n} {+ 1} {0} {s'} j₁) | (closed-no-shift {n} { -[1+ 0 ]} {0} {[ 0 ↦ s' ] e} (preserve-subst'{Δ = []}{v = x} j j₁)) = preserve-subst'{Δ = []}{v = x} j j₁ preserve' {n} {T} (LabE f (LabI l)) .(f x ins) (TLabEl{ins = ins'} j j') (β-LabE {x = x} ins) rewrite (∈-eq ins ins') = j
{ "alphanum_fraction": 0.4333222894, "avg_line_length": 52.2640692641, "ext": "agda", "hexsha": "f1a37747406e175c52d49e122887cf5559d351ea", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-14T17:52:29.000Z", "max_forks_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "kcaliban/ldlc", "max_forks_repo_path": "src/llc/LLC.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "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": "kcaliban/ldlc", "max_issues_repo_path": "src/llc/LLC.agda", "max_line_length": 244, "max_stars_count": null, "max_stars_repo_head_hexsha": "a87fb6402639c3d2bb393cc5466426c28e7a0398", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "kcaliban/ldlc", "max_stars_repo_path": "src/llc/LLC.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 23146, "size": 48292 }
{- This file contains: - Path lemmas used in the colimit-equivalence proof. Verbose, indeed. But should be simple. The length mainly thanks to: - Degenerate cubes that seem "obvious", but have to be constructed manually; - J rule is cubersome to use, especially when iteratively applied, also it is overcomplicated to construct JRefl in nested cases. -} {-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.HITs.James.Inductive.Coherence where open import Cubical.Foundations.Prelude open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Function private variable ℓ ℓ' : Level -- Lots of degenerate cubes used as intial input to J rule private module _ {A : Type ℓ}(a : A) where degenerate1 : (i j k : I) → A degenerate1 i j k = hfill (λ k → λ { (i = i0) → a ; (i = i1) → doubleCompPath-filler (refl {x = a}) refl refl k j ; (j = i0) → a ; (j = i1) → a}) (inS a) k degenerate1' : (i j k : I) → A degenerate1' i j k = hfill (λ k → λ { (i = i0) → a ; (i = i1) → compPath-filler (refl {x = a}) refl k j ; (j = i0) → a ; (j = i1) → a}) (inS a) k degenerate1'' : (i j k : I) → A degenerate1'' i j k = hfill (λ k → λ { (i = i0) → a ; (i = i1) → compPath-filler (refl {x = a}) (refl ∙ refl) k j ; (j = i0) → a ; (j = i1) → degenerate1 i k i1}) (inS a) k module _ {B : Type ℓ'}(f : A → B) where degenerate2 : (i j k : I) → B degenerate2 i j k = hfill (λ k → λ { (i = i0) → f a ; (i = i1) → doubleCompPath-filler (refl {x = f a}) refl refl k j ; (j = i0) → f a ; (j = i1) → f a }) (inS (f a)) k degenerate3 : (i j k : I) → B degenerate3 i j k = hfill (λ k → λ { (i = i0) → f (doubleCompPath-filler (refl {x = a}) refl refl k j) ; (i = i1) → doubleCompPath-filler (refl {x = f a}) refl refl k j ; (j = i0) → f a ; (j = i1) → f a }) (inS (f a)) k someCommonDegenerateCube : (i j k : I) → B someCommonDegenerateCube i j k = hcomp (λ l → λ { (i = i0) → f a ; (i = i1) → degenerate3 k j l ; (j = i0) → f a ; (j = i1) → f a ; (k = i0) → f (degenerate1 i j l) ; (k = i1) → degenerate2 i j l }) (f a) degenerate4 : (i j k : I) → A degenerate4 i j k = hfill (λ k → λ { (i = i0) → compPath-filler (refl {x = a}) (refl ∙∙ refl ∙∙ refl) k j ; (i = i1) → doubleCompPath-filler (refl {x = a}) refl refl j k ; (j = i0) → a ; (j = i1) → (refl {x = a} ∙∙ refl ∙∙ refl) k }) (inS a) k degenerate5 : (i j k : I) → A degenerate5 i j k = hcomp (λ l → λ { (i = i0) → compPath-filler (refl {x = a}) (refl ∙∙ refl ∙∙ refl) k j ; (i = i1) → doubleCompPath-filler (refl {x = a}) refl refl (j ∧ ~ l) k ; (j = i0) → a ; (j = i1) → doubleCompPath-filler (refl {x = a}) refl refl (~ i ∨ ~ l) k ; (k = i0) → a ; (k = i1) → degenerate4 i j i1 }) (degenerate4 i j k) degenerate5' : (i j k : I) → A degenerate5' i j k = hfill (λ k → λ { (i = i0) → doubleCompPath-filler (refl {x = a}) refl (refl ∙ refl) k j ; (i = i1) → a ; (j = i0) → a ; (j = i1) → compPath-filler (refl {x = a}) refl (~ i) k }) (inS a) k -- Cubes of which mostly are constructed by J rule module _ {A : Type ℓ}{a : A} where coh-helper-refl : (q' : a ≡ a)(h : refl ≡ q') → refl ≡ refl ∙∙ refl ∙∙ q' coh-helper-refl q' h i j = hcomp (λ k → λ { (i = i0) → a ; (i = i1) → doubleCompPath-filler refl refl q' k j ; (j = i0) → a ; (j = i1) → h i k }) a coh-helper' : (b : A)(p : a ≡ b) (c : A)(q : b ≡ c) (q' : b ≡ c)(r : PathP (λ i → p i ≡ q i) p q') → refl ≡ (sym q) ∙∙ refl ∙∙ q' coh-helper' = J> J> coh-helper-refl coh-helper'-Refl1 : coh-helper' _ refl ≡ J> coh-helper-refl coh-helper'-Refl1 = transportRefl _ coh-helper'-Refl2 : coh-helper' _ refl _ refl ≡ coh-helper-refl coh-helper'-Refl2 = (λ i → coh-helper'-Refl1 i _ refl) ∙ transportRefl _ coh-helper : {b c : A}(p : a ≡ b)(q q' : b ≡ c) (h : PathP (λ i → p i ≡ q i) p q') → refl ≡ (sym q) ∙∙ refl ∙∙ q' coh-helper p = coh-helper' _ p _ coh-helper-Refl : coh-helper-refl ≡ coh-helper refl refl coh-helper-Refl = sym coh-helper'-Refl2 module _ {A : Type ℓ}{B : Type ℓ'}{a b c d : A} where doubleCompPath-cong-filler : {a' b' c' d' : B} (f : A → B) {pa : f a ≡ a'}{pb : f b ≡ b'}{pc : f c ≡ c'}{pd : f d ≡ d'} (p : a ≡ b)(q : b ≡ c)(r : c ≡ d) {p' : a' ≡ b'}{q' : b' ≡ c'}{r' : c' ≡ d'} (h : PathP (λ i → pa i ≡ pb i) (cong f p) p') (h' : PathP (λ i → pb i ≡ pc i) (cong f q) q') (h'' : PathP (λ i → pc i ≡ pd i) (cong f r) r') → (i j k : I) → B doubleCompPath-cong-filler f p q r {p' = p'} {q' = q'} {r' = r'} h h' h'' i j k = hfill (λ k → λ { (i = i0) → f (doubleCompPath-filler p q r k j) ; (i = i1) → doubleCompPath-filler p' q' r' k j ; (j = i0) → h i (~ k) ; (j = i1) → h'' i k }) (inS (h' i j)) k doubleCompPath-cong : (f : A → B) (p : a ≡ b)(q : b ≡ c)(r : c ≡ d) → cong f (p ∙∙ q ∙∙ r) ≡ cong f p ∙∙ cong f q ∙∙ cong f r doubleCompPath-cong f p q r i j = doubleCompPath-cong-filler f {pa = refl} {pb = refl} {pc = refl} {pd = refl} p q r refl refl refl i j i1 module _ {A : Type ℓ}{a b c : A} where comp-cong-square' : (p : a ≡ b)(q : a ≡ c) (r : b ≡ c)(h : r ≡ sym p ∙∙ refl ∙∙ q) → p ∙ r ≡ q comp-cong-square' p q r h i j = hcomp (λ k → λ { (i = i0) → compPath-filler p r k j ; (i = i1) → doubleCompPath-filler (sym p) refl q j k ; (j = i0) → a ; (j = i1) → h i k }) (p j) module _ {B : Type ℓ'} where comp-cong-square : (f : A → B) (p : a ≡ b)(q : b ≡ c) → cong f (p ∙ q) ≡ cong f p ∙ cong f q comp-cong-square f p q i j = hcomp (λ k → λ { (i = i0) → f (compPath-filler p q k j) ; (i = i1) → compPath-filler (cong f p) (cong f q) k j ; (j = i0) → f a ; (j = i1) → f (q k) }) (f (p j)) module _ {A : Type ℓ}{B : Type ℓ'}{a b c : A} (f : A → B)(p : a ≡ b) (q : f a ≡ f c)(r : b ≡ c) (h : cong f r ≡ sym (cong f p) ∙∙ refl ∙∙ q) where comp-cong-helper-filler : (i j k : I) → B comp-cong-helper-filler i j k = hfill (λ k → λ { (i = i0) → comp-cong-square f p r (~ k) j ; (i = i1) → q j ; (j = i0) → f a ; (j = i1) → f c }) (inS (comp-cong-square' _ _ _ h i j)) k comp-cong-helper : cong f (p ∙ r) ≡ q comp-cong-helper i j = comp-cong-helper-filler i j i1 module _ {A : Type ℓ}{a : A} where push-helper-refl : (q' : a ≡ a)(h : refl ≡ q') → refl ≡ refl ∙ q' push-helper-refl q' h i j = hcomp (λ k → λ { (i = i0) → a ; (i = i1) → compPath-filler refl q' k j ; (j = i0) → a ; (j = i1) → h i k }) a push-helper' : (b : A)(p : a ≡ b) (c : A)(q : b ≡ c) (q' : c ≡ c)(h : refl ≡ q') → PathP (λ i → p i ≡ q i) p (q ∙ q') push-helper' = J> J> push-helper-refl push-helper'-Refl1 : push-helper' _ refl ≡ J> push-helper-refl push-helper'-Refl1 = transportRefl _ push-helper'-Refl2 : push-helper' _ refl _ refl ≡ push-helper-refl push-helper'-Refl2 = (λ i → push-helper'-Refl1 i _ refl) ∙ transportRefl _ push-helper : {b c : A} (p : a ≡ b)(q : b ≡ c)(q' : c ≡ c)(h : refl ≡ q') → PathP (λ i → p i ≡ q i) p (q ∙ q') push-helper p = push-helper' _ p _ push-helper-Refl : push-helper-refl ≡ push-helper refl refl push-helper-Refl = sym push-helper'-Refl2 module _ {A : Type ℓ}{B : Type ℓ'}{a : A}(f : A → B) where push-helper-cong-Type : {b c : A} (p : a ≡ b)(q : b ≡ c) (q' : c ≡ c)(sqr : refl ≡ q') → Type _ push-helper-cong-Type p q q' sqr = SquareP (λ i j → f (push-helper p q _ sqr i j) ≡ push-helper (cong f p) (cong f q) _ (λ i j → f (sqr i j)) i j) (λ i j → f (p i)) (λ i j → comp-cong-square f q q' j i) (λ i j → f (p i)) (λ i j → f (q i)) push-helper-cong-refl : push-helper-cong-Type refl refl refl refl push-helper-cong-refl = transport (λ t → SquareP (λ i j → f (push-helper-Refl t _ (λ i j → a) i j) ≡ push-helper-Refl t _ (λ i j → f a) i j) (λ i j → f a) (λ i j → comp-cong-square f (refl {x = a}) refl j i) (λ i j → f a) (λ i j → f a)) (λ i j k → someCommonDegenerateCube a f i j k) push-helper-cong' : (b : A)(p : a ≡ b) (c : A)(q : b ≡ c) (q' : c ≡ c)(sqr : refl ≡ q') → push-helper-cong-Type p q q' sqr push-helper-cong' = J> J> J> push-helper-cong-refl push-helper-cong : ∀ {b c} p q q' sqr → push-helper-cong-Type {b = b} {c = c} p q q' sqr push-helper-cong p = push-helper-cong' _ p _ module _ {A : Type ℓ}{a : A} where push-coh-helper-Type : {b c : A} (p : a ≡ b)(q q' : b ≡ c) (sqr : PathP (λ i → p i ≡ q i) p q') → Type _ push-coh-helper-Type p q q' sqr = SquareP (λ i j → push-helper p q _ (coh-helper _ _ _ sqr) i j ≡ sqr i j) (λ i j → p i) (λ i j → comp-cong-square' q q' _ refl j i) (λ i j → p i) (λ i j → q i) push-coh-helper-refl' : SquareP (λ i j → push-helper-refl _ (coh-helper-refl _ (λ i j → a)) i j ≡ a) (λ i j → a) (λ i j → comp-cong-square' (refl {x = a}) refl _ refl j i) (λ i j → a) (λ i j → a) push-coh-helper-refl' i j k = hcomp (λ l → λ { (i = i0) → a ; (i = i1) → degenerate5 a k j l ; (j = i0) → a ; (j = i1) → degenerate1 a i l (~ k) ; (k = i0) → degenerate1'' a i j l ; (k = i1) → a }) a push-coh-helper-refl : push-coh-helper-Type refl refl refl refl push-coh-helper-refl = transport (λ t → SquareP (λ i j → push-helper-Refl t _ (coh-helper-Refl t _ (λ i j → a)) i j ≡ a) (λ i j → a) (λ i j → comp-cong-square' (refl {x = a}) refl _ refl j i) (λ i j → a) (λ i j → a)) push-coh-helper-refl' push-coh-helper' : (b : A)(p : a ≡ b) (c : A)(q : b ≡ c) (q' : b ≡ c)(sqr : PathP (λ i → p i ≡ q i) p q') → push-coh-helper-Type p q q' sqr push-coh-helper' = J> J> J> push-coh-helper-refl push-coh-helper : ∀ {b c} p q q' sqr → push-coh-helper-Type {b = b} {c = c} p q q' sqr push-coh-helper p q q' sqr = push-coh-helper' _ p _ q q' sqr module _ {A : Type ℓ}{a : A} where push-square-helper-refl : refl ∙∙ refl ∙∙ (refl ∙ refl) ≡ refl {x = a} push-square-helper-refl i j = degenerate5' a i j i1 push-square-helper' : (b : A)(q : a ≡ b) (c : A)(q' : b ≡ c) → sym q ∙∙ refl ∙∙ (q ∙ q') ≡ q' push-square-helper' = J> J> push-square-helper-refl push-square-helper'-Refl1 : push-square-helper' _ refl ≡ J> push-square-helper-refl push-square-helper'-Refl1 = transportRefl _ push-square-helper'-Refl2 : push-square-helper' _ refl _ refl ≡ push-square-helper-refl push-square-helper'-Refl2 = (λ i → push-square-helper'-Refl1 i _ refl) ∙ transportRefl _ push-square-helper : {b c : A} (q : a ≡ b)(q' : b ≡ c) → sym q ∙∙ refl ∙∙ (q ∙ q') ≡ q' push-square-helper p = push-square-helper' _ p _ push-square-helper-Refl : push-square-helper-refl ≡ push-square-helper refl refl push-square-helper-Refl = sym push-square-helper'-Refl2 module _ {A : Type ℓ}{a : A} where coh-cube-helper-Type : {b c : A}(p : a ≡ b)(q : b ≡ c) (q' : c ≡ c)(sqr : refl ≡ q') → Type _ coh-cube-helper-Type {c = c} p q q' sqr = SquareP (λ i j → coh-helper _ _ _ (push-helper p q q' sqr) i j ≡ sqr i j) (λ i j → c) (λ i j → push-square-helper q q' j i) (λ i j → c) (λ i j → c) coh-cube-helper-refl' : SquareP (λ i j → coh-helper-refl _ (push-helper-refl refl (λ i j → a)) i j ≡ a) (λ i j → a) (λ i j → push-square-helper-refl {a = a} j i) (λ i j → a) (λ i j → a) coh-cube-helper-refl' i j k = hcomp (λ l → λ { (i = i0) → a ; (i = i1) → degenerate5' a k j l ; (j = i0) → a ; (j = i1) → degenerate1' a i l (~ k) ; (k = i0) → degenerate1'' a i j l ; (k = i1) → a }) a coh-cube-helper-refl : coh-cube-helper-Type refl refl refl refl coh-cube-helper-refl = transport (λ t → SquareP (λ i j → coh-helper-Refl t _ (push-helper-Refl t refl (λ i j → a)) i j ≡ a) (λ i j → a) (λ i j → push-square-helper-Refl {a = a} t j i) (λ i j → a) (λ i j → a)) coh-cube-helper-refl' coh-cube-helper' : (b : A)(p : a ≡ b) (c : A)(q : b ≡ c) (q' : c ≡ c)(sqr : refl ≡ q') → coh-cube-helper-Type p q q' sqr coh-cube-helper' = J> J> J> coh-cube-helper-refl coh-cube-helper : ∀ {b c} p q q' sqr → coh-cube-helper-Type {b = b} {c = c} p q q' sqr coh-cube-helper p q q' sqr = coh-cube-helper' _ p _ q q' sqr module _ {A : Type ℓ}{B : Type ℓ'}{a : A}(f : A → B) where coh-helper-cong-Type : {b c : A}{a' b' c' : B} (pa : f a ≡ a')(pb : f b ≡ b')(pc : f c ≡ c') {p : a ≡ b }(q r : b ≡ c ) {p' : a' ≡ b'}{q' r' : b' ≡ c'} (h : PathP (λ i → pa i ≡ pb i) (cong f p) p') (h' : PathP (λ i → pb i ≡ pc i) (cong f q) q') (h'' : PathP (λ i → pb i ≡ pc i) (cong f r) r') (sqr : PathP (λ i → p i ≡ q i) p r) (sqr' : PathP (λ i → p' i ≡ q' i) p' r') → Type _ coh-helper-cong-Type pa pb pc q r h h' h'' sqr sqr' = SquareP (λ i j → f (coh-helper _ _ _ sqr i j) ≡ coh-helper _ _ _ (λ i j → sqr' i j) i j) (λ i j → pc j) (λ i j → doubleCompPath-cong-filler f (sym q) refl r (λ i j → h' i (~ j)) (λ i j → pb i) h'' j i i1) (λ i j → pc j) (λ i j → pc j) coh-helper-cong-refl : coh-helper-cong-Type refl refl refl refl refl refl refl refl refl refl coh-helper-cong-refl = transport (λ t → SquareP (λ i j → f (coh-helper-Refl t _ (λ i j → a) i j) ≡ coh-helper-Refl t _ (λ i j → f a) i j) (λ i j → f a) (λ i j → doubleCompPath-cong-filler f refl refl refl (λ i j → f a) (λ i j → f a) (λ i j → f a) j i i1) (λ i j → f a) (λ i j → f a)) (λ i j k → someCommonDegenerateCube a f i j k) coh-helper-cong' : (b : A)(p : a ≡ b) (c : A)(q : b ≡ c) (a' : B)(pa : f a ≡ a') (b' : B)(pb : f b ≡ b') (c' : B)(pc : f c ≡ c') (r : b ≡ c)(sqr : PathP (λ i → p i ≡ q i) p r) (p' : a' ≡ b')(h : PathP (λ i → pa i ≡ pb i) (cong f p) p') (q' : b' ≡ c')(h' : PathP (λ i → pb i ≡ pc i) (cong f q) q') (r' : b' ≡ c')(h'' : PathP (λ i → pb i ≡ pc i) (cong f r) r') (sqr' : PathP (λ i → p' i ≡ q' i) p' r') (hsqr : SquareP (λ i j → h i j ≡ h' i j) (λ i j → f (sqr i j)) sqr' h h'') → coh-helper-cong-Type pa pb pc q r h h' h'' sqr sqr' coh-helper-cong' = J> J> J> J> J> J> J> J> J> J> coh-helper-cong-refl coh-helper-cong : ∀ {b c a' b' c' pa pb pc} p q r {p' q' r' h h' h''} sqr {sqr'} (hsqr : SquareP (λ i j → f (sqr i j) ≡ sqr' i j) (λ i j → h j i) (λ i j → h'' j i) (λ i j → h j i) (λ i j → h' j i)) → coh-helper-cong-Type {b = b} {c = c} {a' = a'} {b' = b'} {c' = c'} pa pb pc q r {p' = p'} {q' = q'} {r' = r'} h h' h'' sqr sqr' coh-helper-cong p q r sqr hsqr = coh-helper-cong' _ p _ q _ _ _ _ _ _ r sqr _ _ _ _ _ _ _ (λ i j k → hsqr j k i)
{ "alphanum_fraction": 0.4813524326, "avg_line_length": 31.5641547862, "ext": "agda", "hexsha": "31c1b91cffc6a98984b20f296bfc080858618a9c", "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/Coherence.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/Coherence.agda", "max_line_length": 108, "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/Coherence.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": 6435, "size": 15498 }
module Data.Option.Setoid where import Lvl open import Data open import Data.Option open import Functional open import Structure.Relator.Equivalence open import Structure.Relator.Properties open import Structure.Setoid open import Type private variable ℓ ℓₑ ℓₑₐ : Lvl.Level private variable A : Type{ℓ} instance Option-equiv : ⦃ equiv : Equiv{ℓₑ}(A) ⦄ → Equiv{ℓₑ}(Option A) Equiv._≡_ Option-equiv None None = Unit Equiv._≡_ Option-equiv None (Some _) = Empty Equiv._≡_ Option-equiv (Some _) None = Empty Equiv._≡_ Option-equiv (Some x) (Some y) = x ≡ y Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence Option-equiv)) {None} = <> Reflexivity.proof (Equivalence.reflexivity (Equiv.equivalence Option-equiv)) {Some _} = reflexivity(_≡_) Symmetry.proof (Equivalence.symmetry (Equiv.equivalence Option-equiv)) {None} {None} = const(<>) Symmetry.proof (Equivalence.symmetry (Equiv.equivalence Option-equiv)) {Some _} {Some _} = symmetry(_≡_) Transitivity.proof (Equivalence.transitivity (Equiv.equivalence Option-equiv)) {None} {None} {None} = const(const(<>)) Transitivity.proof (Equivalence.transitivity (Equiv.equivalence Option-equiv)) {Some _} {Some _} {Some _} = transitivity(_≡_)
{ "alphanum_fraction": 0.715408805, "avg_line_length": 47.1111111111, "ext": "agda", "hexsha": "b294b14d51ae4f1425ff92c14dcf8dec1f7d559f", "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/Option/Setoid.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/Option/Setoid.agda", "max_line_length": 127, "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/Option/Setoid.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": 386, "size": 1272 }
open import Nat open import Prelude open import core open import contexts open import htype-decidable open import lemmas-matching open import disjointness module elaborability where mutual elaborability-synth : {Γ : tctx} {e : hexp} {τ : htyp} → Γ ⊢ e => τ → Σ[ d ∈ ihexp ] Σ[ Δ ∈ hctx ] (Γ ⊢ e ⇒ τ ~> d ⊣ Δ) elaborability-synth SConst = _ , _ , ESConst elaborability-synth (SAsc {τ = τ} wt) with elaborability-ana wt ... | _ , _ , τ' , D = _ , _ , ESAsc D elaborability-synth (SVar x) = _ , _ , ESVar x elaborability-synth (SAp dis wt1 m wt2) with elaborability-ana (ASubsume wt1 (match-consist m)) | elaborability-ana wt2 ... | _ , _ , _ , D1 | _ , _ , _ , D2 = _ , _ , ESAp dis (elab-ana-disjoint dis D1 D2) wt1 m D1 D2 elaborability-synth SEHole = _ , _ , ESEHole elaborability-synth (SNEHole new wt) with elaborability-synth wt ... | d' , Δ' , wt' = _ , _ , ESNEHole (elab-new-disjoint-synth new wt') wt' elaborability-synth (SLam x₁ wt) with elaborability-synth wt ... | d' , Δ' , wt' = _ , _ , ESLam x₁ wt' elaborability-ana : {Γ : tctx} {e : hexp} {τ : htyp} → Γ ⊢ e <= τ → Σ[ d ∈ ihexp ] Σ[ Δ ∈ hctx ] Σ[ τ' ∈ htyp ] (Γ ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ) elaborability-ana {e = e} (ASubsume D x₁) with elaborability-synth D -- these cases just pass through, but we need to pattern match so we can prove things aren't holes elaborability-ana {e = c} (ASubsume D x₁) | _ , _ , D' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) D' x₁ elaborability-ana {e = e ·: x} (ASubsume D x₁) | _ , _ , D' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) D' x₁ elaborability-ana {e = X x} (ASubsume D x₁) | _ , _ , D' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) D' x₁ elaborability-ana {e = ·λ x e} (ASubsume D x₁) | _ , _ , D' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) D' x₁ elaborability-ana {e = ·λ x [ x₁ ] e} (ASubsume D x₂) | _ , _ , D' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) D' x₂ elaborability-ana {e = e1 ∘ e2} (ASubsume D x₁) | _ , _ , D' = _ , _ , _ , EASubsume (λ _ ()) (λ _ _ ()) D' x₁ -- the two holes are special-cased elaborability-ana {e = ⦇-⦈[ x ]} (ASubsume _ _ ) | _ , _ , _ = _ , _ , _ , EAEHole elaborability-ana {Γ} {⦇⌜ e ⌟⦈[ x ]} (ASubsume (SNEHole new wt) x₂) | _ , _ , ESNEHole x₁ D' with elaborability-synth wt ... | w , y , z = _ , _ , _ , EANEHole (elab-new-disjoint-synth new z) z -- the lambda cases elaborability-ana (ALam x₁ m wt) with elaborability-ana wt ... | _ , _ , _ , D' = _ , _ , _ , EALam x₁ m D'
{ "alphanum_fraction": 0.5100458231, "avg_line_length": 54.5576923077, "ext": "agda", "hexsha": "f9ed5e061991b63312ea0456e17db7328f9e272e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_forks_event_min_datetime": "2019-09-13T18:20:02.000Z", "max_forks_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_forks_repo_path": "elaborability.agda", "max_issues_count": 54, "max_issues_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_issues_repo_issues_event_max_datetime": "2018-11-29T16:32:40.000Z", "max_issues_repo_issues_event_min_datetime": "2017-06-29T20:53:34.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_issues_repo_path": "elaborability.agda", "max_line_length": 127, "max_stars_count": 16, "max_stars_repo_head_hexsha": "229dfb06ea51ebe91cb3b1c973c2f2792e66797c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-dynamics-agda", "max_stars_repo_path": "elaborability.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-19T02:50:23.000Z", "max_stars_repo_stars_event_min_datetime": "2018-03-12T14:32:03.000Z", "num_tokens": 1053, "size": 2837 }
open import Agda.Builtin.Char open import Agda.Builtin.Coinduction open import Agda.Builtin.IO open import Agda.Builtin.List open import Agda.Builtin.Unit open import Agda.Builtin.String data Colist {a} (A : Set a) : Set a where [] : Colist A _∷_ : A → ∞ (Colist A) → Colist A {-# FOREIGN GHC data Colist a = Nil | Cons a (MAlonzo.RTE.Inf (Colist a)) type Colist' l a = Colist a fromColist :: Colist a -> [a] fromColist Nil = [] fromColist (Cons x xs) = x : fromColist (MAlonzo.RTE.flat xs) #-} {-# COMPILE GHC Colist = data Colist' (Nil | Cons) #-} to-colist : ∀ {a} {A : Set a} → List A → Colist A to-colist [] = [] to-colist (x ∷ xs) = x ∷ ♯ to-colist xs a-definition-that-uses-♭ : ∀ {a} {A : Set a} → Colist A → Colist A a-definition-that-uses-♭ [] = [] a-definition-that-uses-♭ (x ∷ xs) = x ∷ ♯ a-definition-that-uses-♭ (♭ xs) postulate putStr : Colist Char → IO ⊤ {-# COMPILE GHC putStr = putStr . fromColist #-} main : IO ⊤ main = putStr (a-definition-that-uses-♭ (to-colist (primStringToList "apa\n")))
{ "alphanum_fraction": 0.6158139535, "avg_line_length": 26.2195121951, "ext": "agda", "hexsha": "6c99c74c432347d7ae0ede7fc7cb4fb6dfb0b035", "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/Compiler/simple/Issue2909-4.agda", "max_issues_count": 16, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Compiler/simple/Issue2909-4.agda", "max_line_length": 63, "max_stars_count": 7, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Compiler/simple/Issue2909-4.agda", "max_stars_repo_stars_event_max_datetime": "2018-11-06T16:38:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-11-05T22:13:36.000Z", "num_tokens": 385, "size": 1075 }
module Categories.Comonad.Cofree where
{ "alphanum_fraction": 0.8717948718, "avg_line_length": 19.5, "ext": "agda", "hexsha": "60ecd16f69afe30f199c28fbc99d1e115a6591a7", "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/Comonad/Cofree.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/Comonad/Cofree.agda", "max_line_length": 38, "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/Comonad/Cofree.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": 10, "size": 39 }
-- Andreas, 2011-10-06 module Issue483c where data _≡_ {A : Set}(a : A) : A → Set where refl : a ≡ a record _×_ (A B : Set) : Set where constructor _,_ field fst : A snd : B postulate A : Set f : .A → A -- this succeeds test : let X : .A → A X = _ in .(x : A) → (X ≡ f) × (X (f x) ≡ f x) test x = refl , refl -- so this should also succeed test2 : let X : .A → A X = _ in .(x : A) → (X (f x) ≡ f x) × (X ≡ f) test2 x = refl , refl
{ "alphanum_fraction": 0.4746450304, "avg_line_length": 18.2592592593, "ext": "agda", "hexsha": "4011cc7020825dc80eb5e5b2f02d142a9e0d6d97", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue483c.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue483c.agda", "max_line_length": 47, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/succeed/Issue483c.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": 199, "size": 493 }
------------------------------------------------------------------------ -- Alpha-equivalence ------------------------------------------------------------------------ open import Atom module Alpha-equivalence (atoms : χ-atoms) where open import Equality.Propositional open import Prelude hiding (const) open import Bag-equivalence equality-with-J using (_∈_) import Nat equality-with-J as Nat open import Chi atoms open import Free-variables atoms open χ-atoms atoms private variable A : Type b₁ b₂ : Br bs₁ bs₂ : List Br c c₁ c₂ : Const e e₁ e₂ e₃ e₁₁ e₁₂ e₂₁ e₂₂ : Exp es₁ es₂ : List Exp R R₁ R₂ : A → A → Type x x₁ x₁′ x₂ x₂′ y : A xs xs₁ xs₂ : List A ------------------------------------------------------------------------ -- The definition of α-equivalence -- R [ x ∼ y ] relates x to y, and for pairs of variables x′, y′ such -- that x is distinct from x′ and y is distinct from y′ it behaves -- like R. infix 5 _[_∼_] _[_∼_] : (Var → Var → Type) → Var → Var → (Var → Var → Type) (R [ x ∼ y ]) x′ y′ = x ≡ x′ × y ≡ y′ ⊎ x ≢ x′ × y ≢ y′ × R x′ y′ -- Alpha-⋆ lifts a binary relation to lists. infixr 5 _∷_ data Alpha-⋆ (R : A → A → Type) : List A → List A → Type where [] : Alpha-⋆ R [] [] _∷_ : R x₁ x₂ → Alpha-⋆ R xs₁ xs₂ → Alpha-⋆ R (x₁ ∷ xs₁) (x₂ ∷ xs₂) -- Alpha R is α-equivalence up to R: free variables are related if -- they are related by R. mutual data Alpha (R : Var → Var → Type) : Exp → Exp → Type where apply : Alpha R e₁₁ e₁₂ → Alpha R e₂₁ e₂₂ → Alpha R (apply e₁₁ e₂₁) (apply e₁₂ e₂₂) lambda : Alpha (R [ x₁ ∼ x₂ ]) e₁ e₂ → Alpha R (lambda x₁ e₁) (lambda x₂ e₂) case : Alpha R e₁ e₂ → Alpha-⋆ (Alpha-Br R) bs₁ bs₂ → Alpha R (case e₁ bs₁) (case e₂ bs₂) rec : Alpha (R [ x₁ ∼ x₂ ]) e₁ e₂ → Alpha R (rec x₁ e₁) (rec x₂ e₂) var : R x₁ x₂ → Alpha R (var x₁) (var x₂) const : Alpha-⋆ (Alpha R) es₁ es₂ → Alpha R (const c es₁) (const c es₂) data Alpha-Br (R : Var → Var → Type) : Br → Br → Type where nil : Alpha R e₁ e₂ → Alpha-Br R (branch c [] e₁) (branch c [] e₂) cons : Alpha-Br (R [ x₁ ∼ x₂ ]) (branch c xs₁ e₁) (branch c xs₂ e₂) → Alpha-Br R (branch c (x₁ ∷ xs₁) e₁) (branch c (x₂ ∷ xs₂) e₂) -- The α-equivalence relation. infix 4 _≈α_ _≈α_ : Exp → Exp → Type _≈α_ = Alpha _≡_ ------------------------------------------------------------------------ -- Some properties related to reflexivity -- If R y y holds assuming that y is distinct from x, then -- (R [ x ∼ x ]) y y holds. [≢→[∼]]→[∼] : ∀ R → (y ≢ x → R y y) → (R [ x ∼ x ]) y y [≢→[∼]]→[∼] {y = y} {x = x} _ r = case x V.≟ y of λ where (yes x≡y) → inj₁ (x≡y , x≡y) (no x≢y) → inj₂ ( x≢y , x≢y , r (x≢y ∘ sym) ) -- Alpha R is reflexive for expressions for which R x x holds for -- every free variable x. mutual refl-Alpha : ∀ e → (∀ x → x ∈FV e → R x x) → Alpha R e e refl-Alpha (apply e₁ e₂) r = apply (refl-Alpha e₁ λ x x∈e₁ → r x (apply-left x∈e₁)) (refl-Alpha e₂ λ x x∈e₂ → r x (apply-right x∈e₂)) refl-Alpha {R = R} (lambda x e) r = lambda (refl-Alpha e λ y y∈e → [≢→[∼]]→[∼] R λ y≢x → r y (lambda y≢x y∈e)) refl-Alpha (case e bs) r = case (refl-Alpha e λ x x∈e → r x (case-head x∈e)) (refl-Alpha-B⋆ bs λ x ∈bs x∉xs x∈ → r x (case-body x∈ ∈bs x∉xs)) refl-Alpha {R = R} (rec x e) r = rec (refl-Alpha e λ y y∈e → [≢→[∼]]→[∼] R λ y≢x → r y (rec y≢x y∈e)) refl-Alpha (var x) r = var (r x (var refl)) refl-Alpha (const c es) r = const (refl-Alpha-⋆ es λ x e e∈es x∈e → r x (const x∈e e∈es)) refl-Alpha-B : ∀ c xs e → (∀ x → ¬ x ∈ xs → x ∈FV e → R x x) → Alpha-Br R (branch c xs e) (branch c xs e) refl-Alpha-B c [] e r = nil (refl-Alpha e λ x x∈e → r x (λ ()) x∈e) refl-Alpha-B {R = R} c (x ∷ xs) e r = cons (refl-Alpha-B c xs e λ y y∉xs y∈e → [≢→[∼]]→[∼] R λ y≢x → r y [ y≢x , y∉xs ] y∈e) refl-Alpha-⋆ : ∀ es → (∀ x e → e ∈ es → x ∈FV e → R x x) → Alpha-⋆ (Alpha R) es es refl-Alpha-⋆ [] _ = [] refl-Alpha-⋆ (e ∷ es) r = refl-Alpha e (λ x x∈e → r x e (inj₁ refl) x∈e) ∷ refl-Alpha-⋆ es (λ x e e∈es x∈e → r x e (inj₂ e∈es) x∈e) refl-Alpha-B⋆ : ∀ bs → (∀ x {c xs e} → branch c xs e ∈ bs → ¬ x ∈ xs → x ∈FV e → R x x) → Alpha-⋆ (Alpha-Br R) bs bs refl-Alpha-B⋆ [] r = [] refl-Alpha-B⋆ (branch c xs e ∷ bs) r = refl-Alpha-B c xs e (λ x x∉xs x∈e → r x (inj₁ refl) x∉xs x∈e) ∷ refl-Alpha-B⋆ bs (λ x ∈bs x∉xs x∈ → r x (inj₂ ∈bs) x∉xs x∈) -- The α-equivalence relation is reflexive. refl-α : e ≈α e refl-α = refl-Alpha _ (λ _ _ → refl) -- Equational reasoning combinators. infix -1 finally-α _∎α infixr -2 step-≡-≈α step-≈α-≡ _≡⟨⟩α_ _∎α : ∀ e → e ≈α e _ ∎α = refl-α step-≡-≈α : ∀ e₁ → e₂ ≈α e₃ → e₁ ≡ e₂ → e₁ ≈α e₃ step-≡-≈α _ e₂≈e₃ e₁≡e₂ = subst (_≈α _) (sym e₁≡e₂) e₂≈e₃ syntax step-≡-≈α e₁ e₂≈e₃ e₁≡e₂ = e₁ ≡⟨ e₁≡e₂ ⟩α e₂≈e₃ step-≈α-≡ : ∀ e₁ → e₂ ≡ e₃ → e₁ ≈α e₂ → e₁ ≈α e₃ step-≈α-≡ _ e₂≡e₃ e₁≈e₂ = subst (_ ≈α_) e₂≡e₃ e₁≈e₂ syntax step-≈α-≡ e₁ e₂≡e₃ e₁≈e₂ = e₁ ≈⟨ e₁≈e₂ ⟩α e₂≡e₃ _≡⟨⟩α_ : ∀ e₁ → e₁ ≈α e₂ → e₁ ≈α e₂ _ ≡⟨⟩α e₁≈e₂ = e₁≈e₂ finally-α : ∀ e₁ e₂ → e₁ ≈α e₂ → e₁ ≈α e₂ finally-α _ _ e₁≈e₂ = e₁≈e₂ syntax finally-α e₁ e₂ e₁≈e₂ = e₁ ≈⟨ e₁≈e₂ ⟩α∎ e₂ ∎ ------------------------------------------------------------------------ -- A map function -- A kind of map function for _[_∼_]. map-[∼] : ∀ R₁ → (∀ {x₁ x₂} → R₁ x₁ x₂ → R₂ x₁ x₂) → (R₁ [ x₁ ∼ x₂ ]) x₁′ x₂′ → (R₂ [ x₁ ∼ x₂ ]) x₁′ x₂′ map-[∼] _ r = ⊎-map id (Σ-map id (Σ-map id r)) -- A kind of map function for Alpha. mutual map-Alpha : (∀ {x₁ x₂} → R₁ x₁ x₂ → R₂ x₁ x₂) → Alpha R₁ e₁ e₂ → Alpha R₂ e₁ e₂ map-Alpha r (var Rx₁x₂) = var (r Rx₁x₂) map-Alpha {R₁ = R₁} r (lambda e₁≈e₂) = lambda (map-Alpha (map-[∼] R₁ r) e₁≈e₂) map-Alpha {R₁ = R₁} r (rec e₁≈e₂) = rec (map-Alpha (map-[∼] R₁ r) e₁≈e₂) map-Alpha r (apply e₁₁≈e₁₂ e₂₁≈e₂₂) = apply (map-Alpha r e₁₁≈e₁₂) (map-Alpha r e₂₁≈e₂₂) map-Alpha r (const es₁≈es₂) = const (map-Alpha-⋆ r es₁≈es₂) map-Alpha r (case e₁≈e₂ bs₁≈bs₂) = case (map-Alpha r e₁≈e₂) (map-Alpha-Br-⋆ r bs₁≈bs₂) map-Alpha-Br : (∀ {x₁ x₂} → R₁ x₁ x₂ → R₂ x₁ x₂) → Alpha-Br R₁ b₁ b₂ → Alpha-Br R₂ b₁ b₂ map-Alpha-Br r (nil e₁≈e₂) = nil (map-Alpha r e₁≈e₂) map-Alpha-Br {R₁ = R₁} r (cons b₁≈b₂) = cons (map-Alpha-Br (map-[∼] R₁ r) b₁≈b₂) map-Alpha-⋆ : (∀ {x₁ x₂} → R₁ x₁ x₂ → R₂ x₁ x₂) → Alpha-⋆ (Alpha R₁) es₁ es₂ → Alpha-⋆ (Alpha R₂) es₁ es₂ map-Alpha-⋆ _ [] = [] map-Alpha-⋆ r (e₁≈e₂ ∷ es₁≈es₂) = map-Alpha r e₁≈e₂ ∷ map-Alpha-⋆ r es₁≈es₂ map-Alpha-Br-⋆ : (∀ {x₁ x₂} → R₁ x₁ x₂ → R₂ x₁ x₂) → Alpha-⋆ (Alpha-Br R₁) bs₁ bs₂ → Alpha-⋆ (Alpha-Br R₂) bs₁ bs₂ map-Alpha-Br-⋆ _ [] = [] map-Alpha-Br-⋆ r (b₁≈b₂ ∷ bs₁≈bs₂) = map-Alpha-Br r b₁≈b₂ ∷ map-Alpha-Br-⋆ r bs₁≈bs₂ ------------------------------------------------------------------------ -- Symmetry -- A kind of symmetry holds for _[_∼_]. sym-[∼] : ∀ R → (R [ x₁ ∼ x₂ ]) x₁′ x₂′ → (flip R [ x₂ ∼ x₁ ]) x₂′ x₁′ sym-[∼] _ = ⊎-map Prelude.swap (λ (x₁≢x₁′ , x₂≢x₂′ , R₁x₁′x₂′) → x₂≢x₂′ , x₁≢x₁′ , R₁x₁′x₂′) -- A kind of symmetry holds for Alpha. mutual sym-Alpha : Alpha R e₁ e₂ → Alpha (flip R) e₂ e₁ sym-Alpha (var Rx₁x₂) = var Rx₁x₂ sym-Alpha {R = R} (lambda e₁≈e₂) = lambda (map-Alpha (sym-[∼] R) (sym-Alpha e₁≈e₂)) sym-Alpha {R = R} (rec e₁≈e₂) = rec (map-Alpha (sym-[∼] R) (sym-Alpha e₁≈e₂)) sym-Alpha (apply e₁₁≈e₁₂ e₂₁≈e₂₂) = apply (sym-Alpha e₁₁≈e₁₂) (sym-Alpha e₂₁≈e₂₂) sym-Alpha (const es₁≈es₂) = const (sym-Alpha-⋆ es₁≈es₂) sym-Alpha (case e₁≈e₂ bs₁≈bs₂) = case (sym-Alpha e₁≈e₂) (sym-Alpha-Br-⋆ bs₁≈bs₂) sym-Alpha-Br : Alpha-Br R b₁ b₂ → Alpha-Br (flip R) b₂ b₁ sym-Alpha-Br (nil e₁≈e₂) = nil (sym-Alpha e₁≈e₂) sym-Alpha-Br {R = R} (cons b₁≈b₂) = cons (map-Alpha-Br (sym-[∼] R) (sym-Alpha-Br b₁≈b₂)) sym-Alpha-⋆ : Alpha-⋆ (Alpha R) es₁ es₂ → Alpha-⋆ (Alpha (flip R)) es₂ es₁ sym-Alpha-⋆ [] = [] sym-Alpha-⋆ (e₁≈e₂ ∷ es₁≈es₂) = sym-Alpha e₁≈e₂ ∷ sym-Alpha-⋆ es₁≈es₂ sym-Alpha-Br-⋆ : Alpha-⋆ (Alpha-Br R) bs₁ bs₂ → Alpha-⋆ (Alpha-Br (flip R)) bs₂ bs₁ sym-Alpha-Br-⋆ [] = [] sym-Alpha-Br-⋆ (b₁≈b₂ ∷ bs₁≈bs₂) = sym-Alpha-Br b₁≈b₂ ∷ sym-Alpha-Br-⋆ bs₁≈bs₂ -- The α-equivalence relation is symmetric. sym-α : e₁ ≈α e₂ → e₂ ≈α e₁ sym-α = map-Alpha sym ∘ sym-Alpha ------------------------------------------------------------------------ -- Several things respect α-equivalence -- The free variable relation respects α-equivalence. mutual Alpha-∈ : Alpha R e₁ e₂ → x₁ ∈FV e₁ → ∃ λ x₂ → R x₁ x₂ × x₂ ∈FV e₂ Alpha-∈ {R = R} (var Ry₁y₂) (var x₁≡y₁) = _ , subst (flip R _) (sym x₁≡y₁) Ry₁y₂ , var refl Alpha-∈ (lambda e₁≈e₂) (lambda x₁≢y₁ x₁∈) with Alpha-∈ e₁≈e₂ x₁∈ … | x₂ , inj₂ (_ , y₂≢x₂ , Rx₁x₂) , x₂∈ = x₂ , Rx₁x₂ , lambda (y₂≢x₂ ∘ sym) x₂∈ … | _ , inj₁ (y₁≡x₁ , _) , _ = ⊥-elim $ x₁≢y₁ (sym y₁≡x₁) Alpha-∈ (rec e₁≈e₂) (rec x₁≢y₁ x₁∈) with Alpha-∈ e₁≈e₂ x₁∈ … | x₂ , inj₂ (_ , y₂≢x₂ , Rx₁x₂) , x₂∈ = x₂ , Rx₁x₂ , rec (y₂≢x₂ ∘ sym) x₂∈ … | _ , inj₁ (y₁≡x₁ , _) , _ = ⊥-elim $ x₁≢y₁ (sym y₁≡x₁) Alpha-∈ (apply e₁₁≈e₁₂ e₂₁≈e₂₂) (apply-left x₁∈) = Σ-map id (Σ-map id apply-left) $ Alpha-∈ e₁₁≈e₁₂ x₁∈ Alpha-∈ (apply e₁₁≈e₁₂ e₂₁≈e₂₂) (apply-right x₁∈) = Σ-map id (Σ-map id apply-right) $ Alpha-∈ e₂₁≈e₂₂ x₁∈ Alpha-∈ (const es₁≈es₂) (const x₁∈ ∈es₁) = Σ-map id (Σ-map id $ uncurry λ _ → uncurry const) $ Alpha-⋆-∈ es₁≈es₂ x₁∈ ∈es₁ Alpha-∈ (case e₁≈e₂ bs₁≈bs₂) (case-head x₁∈) = Σ-map id (Σ-map id case-head) $ Alpha-∈ e₁≈e₂ x₁∈ Alpha-∈ (case e₁≈e₂ bs₁≈bs₂) (case-body x₁∈ ∈bs₁ ∉xs₁) = Σ-map id (Σ-map id λ (_ , _ , _ , x₂∈ , ∈bs₂ , ∉xs₂) → case-body x₂∈ ∈bs₂ ∉xs₂) $ Alpha-Br-⋆-∈ bs₁≈bs₂ x₁∈ ∈bs₁ ∉xs₁ Alpha-Br-∈ : Alpha-Br R (branch c₁ xs₁ e₁) (branch c₂ xs₂ e₂) → x₁ ∈FV e₁ → ¬ x₁ ∈ xs₁ → ∃ λ x₂ → R x₁ x₂ × x₂ ∈FV e₂ × ¬ x₂ ∈ xs₂ Alpha-Br-∈ (nil e₁≈e₂) x₁∈ _ = Σ-map id (Σ-map id (_, λ ())) $ Alpha-∈ e₁≈e₂ x₁∈ Alpha-Br-∈ (cons {x₁ = y₁} {x₂ = y₂} bs₁≈bs₂) x₁∈ x₁∉ with Alpha-Br-∈ bs₁≈bs₂ x₁∈ (x₁∉ ∘ inj₂) … | x₂ , inj₂ (_ , y₂≢x₂ , Rx₁x₂) , x₂∈ , x₂∉ = x₂ , Rx₁x₂ , x₂∈ , [ y₂≢x₂ ∘ sym , x₂∉ ] … | _ , inj₁ (y₁≡x₁ , _) , _ = ⊥-elim $ x₁∉ (inj₁ (sym y₁≡x₁)) Alpha-⋆-∈ : Alpha-⋆ (Alpha R) es₁ es₂ → x₁ ∈FV e₁ → e₁ ∈ es₁ → ∃ λ x₂ → R x₁ x₂ × ∃ λ e₂ → x₂ ∈FV e₂ × e₂ ∈ es₂ Alpha-⋆-∈ (e₁≈e₂ ∷ es₁≈es₂) x₁∈ (inj₁ ≡e₁) = Σ-map id (Σ-map id λ x₂∈ → _ , x₂∈ , inj₁ refl) $ Alpha-∈ e₁≈e₂ (subst (_ ∈FV_) ≡e₁ x₁∈) Alpha-⋆-∈ (e₁≈e₂ ∷ es₁≈es₂) x₁∈ (inj₂ ∈es₁) = Σ-map id (Σ-map id (Σ-map id (Σ-map id inj₂))) $ Alpha-⋆-∈ es₁≈es₂ x₁∈ ∈es₁ Alpha-Br-⋆-∈ : Alpha-⋆ (Alpha-Br R) bs₁ bs₂ → x₁ ∈FV e₁ → branch c₁ xs₁ e₁ ∈ bs₁ → ¬ x₁ ∈ xs₁ → ∃ λ x₂ → R x₁ x₂ × ∃ λ c₂ → ∃ λ xs₂ → ∃ λ e₂ → x₂ ∈FV e₂ × branch c₂ xs₂ e₂ ∈ bs₂ × ¬ x₂ ∈ xs₂ Alpha-Br-⋆-∈ (_∷_ {x₁ = branch _ _ _} {x₂ = branch _ _ _} b₁≈b₂ bs₁≈bs₂) x₁∈ (inj₁ ≡b₁) x₁∉ with Alpha-Br-∈ b₁≈b₂ (subst (_ ∈FV_) (cong (λ { (branch _ _ e) → e }) ≡b₁) x₁∈) (x₁∉ ∘ subst (_ ∈_) (cong (λ { (branch _ xs _) → xs }) (sym ≡b₁))) … | x₂ , Rx₁x₂ , x₂∈ , x₂∉ = x₂ , Rx₁x₂ , _ , _ , _ , x₂∈ , inj₁ refl , x₂∉ Alpha-Br-⋆-∈ (b₁≈b₂ ∷ bs₁≈bs₂) x₁∈ (inj₂ ∈bs₁) x₁∉ = (Σ-map id $ Σ-map id $ Σ-map id $ Σ-map id $ Σ-map id $ Σ-map id $ Σ-map inj₂ id) $ Alpha-Br-⋆-∈ bs₁≈bs₂ x₁∈ ∈bs₁ x₁∉ α-∈ : e₁ ≈α e₂ → x ∈FV e₁ → x ∈FV e₂ α-∈ e₁≈e₂ x∈ with Alpha-∈ e₁≈e₂ x∈ … | x′ , x≡x′ , x′∈ = subst (_∈FV _) (sym x≡x′) x′∈ -- The predicate Closed′ respects α-equivalence. α-closed′ : e₁ ≈α e₂ → Closed′ xs e₁ → Closed′ xs e₂ α-closed′ e₁≈e₂ cl x x∉ x∈ = cl x x∉ (α-∈ (sym-α e₁≈e₂) x∈) -- The predicate Closed respects α-equivalence. α-closed : e₁ ≈α e₂ → Closed e₁ → Closed e₂ α-closed = α-closed′ -- Substitution does not necessarily respect α-equivalence. ¬-subst-α : ¬ (∀ {x₁ x₂ e₁ e₂ e₁′ e₂′} → Alpha (_≡_ [ x₁ ∼ x₂ ]) e₁ e₂ → e₁′ ≈α e₂′ → e₁ [ x₁ ← e₁′ ] ≈α e₂ [ x₂ ← e₂′ ]) ¬-subst-α subst-α = not-equal (subst-α e¹≈e² e′≈e′) where x¹ = V.name 0 x² = V.name 1 z = V.name 2 e¹ = lambda x¹ (var z) e² = lambda x² (var z) e′ = var x¹ e¹≈e² : Alpha (_≡_ [ z ∼ z ]) e¹ e² e¹≈e² = lambda (var (inj₂ ( V.distinct-codes→distinct-names (λ ()) , V.distinct-codes→distinct-names (λ ()) , inj₁ (refl , refl) ))) e′≈e′ : e′ ≈α e′ e′≈e′ = refl-α not-equal : ¬ e¹ [ z ← e′ ] ≈α e² [ z ← e′ ] not-equal _ with z V.≟ x¹ | z V.≟ x² | z V.≟ z not-equal (lambda (var (inj₁ (_ , x²≡x¹)))) | no _ | no _ | yes _ = from-⊎ (1 Nat.≟ 0) (V.name-injective x²≡x¹) not-equal (lambda (var (inj₂ (x¹≢x¹ , _)))) | no _ | no _ | yes _ = x¹≢x¹ refl not-equal _ | yes z≡x¹ | _ | _ = from-⊎ (2 Nat.≟ 0) (V.name-injective z≡x¹) not-equal _ | _ | yes z≡x² | _ = from-⊎ (2 Nat.≟ 1) (V.name-injective z≡x²) not-equal _ | _ | _ | no z≢z = z≢z refl -- TODO: Does substitution of closed terms respect α-equivalence? Does -- the semantics respect α-equivalence for closed terms?
{ "alphanum_fraction": 0.493729036, "avg_line_length": 28.630480167, "ext": "agda", "hexsha": "5d8a5fe57008897de99395978f9ace86336681ad", "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": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/chi", "max_forks_repo_path": "src/Alpha-equivalence.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_issues_repo_issues_event_max_datetime": "2020-06-08T11:08:25.000Z", "max_issues_repo_issues_event_min_datetime": "2020-05-21T23:29:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/chi", "max_issues_repo_path": "src/Alpha-equivalence.agda", "max_line_length": 72, "max_stars_count": 2, "max_stars_repo_head_hexsha": "30966769b8cbd46aa490b6964a4aa0e67a7f9ab1", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/chi", "max_stars_repo_path": "src/Alpha-equivalence.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-20T16:27:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:07.000Z", "num_tokens": 6643, "size": 13714 }
-- {-# OPTIONS -v tc.term.exlam:100 -v extendedlambda:100 -v int2abs.reifyterm:100 -v tc.with:100 -v tc.mod.apply:100 #-} module Issue778b (Param : Set) where open import Issue778M Param data D : (Nat → Nat) → Set where d : D pred → D pred test : (f : Nat → Nat) → D f → Nat test .pred (d x) = bla where bla : Nat bla with x ... | (d y) = test pred y
{ "alphanum_fraction": 0.6016042781, "avg_line_length": 26.7142857143, "ext": "agda", "hexsha": "e7696f5e56b00e928eecc1c784a5a3963ec3f35a", "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/succeed/Issue778b.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/succeed/Issue778b.agda", "max_line_length": 121, "max_stars_count": 1, "max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "np/agda-git-experiment", "max_stars_repo_path": "test/succeed/Issue778b.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": 129, "size": 374 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Groups.Definition open import Setoids.Setoids open import Groups.Subgroups.Definition open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) module Groups.Subgroups.Normal.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ : A → A → A} (G : Group S _+_) where normalSubgroup : {c : _} {pred : A → Set c} (sub : Subgroup G pred) → Set (a ⊔ c) normalSubgroup {pred = pred} sub = {g k : A} → pred k → pred (g + (k + Group.inverse G g))
{ "alphanum_fraction": 0.6478599222, "avg_line_length": 39.5384615385, "ext": "agda", "hexsha": "36c1d9b06a6a7d2253e14b457079a820e9ace836", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Groups/Subgroups/Normal/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": "Groups/Subgroups/Normal/Definition.agda", "max_line_length": 128, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Groups/Subgroups/Normal/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": 171, "size": 514 }
------------------------------------------------------------------------------ -- Distributive laws on a binary operation: Lemma 3 ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module DistributiveLaws.Lemma3-ATP where open import DistributiveLaws.Base ------------------------------------------------------------------------------ postulate lemma₃ : ∀ x y z → (x · y) · (z · z) ≡ (x · y) · z {-# ATP prove lemma₃ #-}
{ "alphanum_fraction": 0.3588516746, "avg_line_length": 34.8333333333, "ext": "agda", "hexsha": "d82dfcf18e0d084a37aa5f2073ab2f3cb3c55f4a", "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/DistributiveLaws/Lemma3-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/DistributiveLaws/Lemma3-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/DistributiveLaws/Lemma3-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": 111, "size": 627 }
module nat-tests where open import eq open import nat open import nat-division open import nat-to-string open import product {- you can prove x + 0 ≡ x and 0 + x ≡ x without induction, if you use this more verbose definition of addition: -} _+a_ : ℕ → ℕ → ℕ 0 +a 0 = 0 (suc x) +a 0 = (suc x) 0 +a (suc y) = (suc y) (suc x) +a (suc y) = suc (suc (x +a y)) 0+a : ∀ (x : ℕ) → x +a 0 ≡ x 0+a 0 = refl 0+a (suc y) = refl +a0 : ∀ (x : ℕ) → 0 +a x ≡ x +a0 0 = refl +a0 (suc y) = refl 8-div-3-lem : (8 ÷ 3 !! refl) ≡ (2 , 2) 8-div-3-lem = refl 23-div-5-lem : (23 ÷ 5 !! refl) ≡ (4 , 3) 23-div-5-lem = refl ℕ-to-string-lem : ℕ-to-string 237 ≡ "237" ℕ-to-string-lem = refl
{ "alphanum_fraction": 0.5667655786, "avg_line_length": 19.8235294118, "ext": "agda", "hexsha": "8a9441ee4a98ed32557891ae5cfba7eb2bbd2605", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "nat-tests.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "nat-tests.agda", "max_line_length": 66, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "nat-tests.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 299, "size": 674 }
{-# OPTIONS --cubical --safe --exact-split --without-K #-} -- this depends mainly on agda/cubical, but also uses the standard library for `Function` module scratch where open import Cubical.Foundations.Prelude open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.HLevels open import Cubical.Relation.Nullary open import Cubical.HITs.HitInt renaming (abs to absℤ ; Sign to Sign'; sign to sign') open import Cubical.HITs.Rational open import Cubical.Data.Bool open import Cubical.Data.Nat renaming (_+_ to _+ℕ_; _*_ to _*ℕ_) open import Cubical.Data.Empty open import Cubical.Data.Unit open import Cubical.Data.Prod open import Agda.Primitive open import Function private variable ℓ ℓ' : Level const₂ : {A B : Set ℓ} {C : Set ℓ'} → C → A → B → C const₂ c _ _ = c record FromNat (A : Set ℓ) : Set (lsuc ℓ) where field Constraint : ℕ → Set ℓ fromNat : (n : ℕ) ⦃ _ : Constraint n ⦄ → A open FromNat ⦃ ... ⦄ public using (fromNat) {-# BUILTIN FROMNAT fromNat #-} record FromNeg (A : Set ℓ) : Set (lsuc ℓ) where field Constraint : ℕ → Set ℓ fromNeg : (n : ℕ) ⦃ _ : Constraint n ⦄ → A open FromNeg ⦃ ... ⦄ public using (fromNeg) {-# BUILTIN FROMNEG fromNeg #-} instance NatFromNat : FromNat ℕ NatFromNat .FromNat.Constraint _ = Unit fromNat ⦃ NatFromNat ⦄ n = n instance ℤFromNat : FromNat ℤ ℤFromNat .FromNat.Constraint _ = Unit fromNat ⦃ ℤFromNat ⦄ n = pos n instance ℤFromNeg : FromNeg ℤ ℤFromNeg .FromNeg.Constraint _ = Unit fromNeg ⦃ ℤFromNeg ⦄ n = neg n instance ℚFromNat : FromNat ℚ ℚFromNat .FromNat.Constraint _ = Unit fromNat ⦃ ℚFromNat ⦄ n = int (pos n) instance ℚFromNeg : FromNeg ℚ ℚFromNeg .FromNeg.Constraint _ = Unit fromNeg ⦃ ℚFromNeg ⦄ n = int (neg n) record Op< (A B : Set ℓ) (C : A → B → Set ℓ') : Set (ℓ-max ℓ ℓ') where infix 5 _<_ field _<_ : (a : A) → (b : B) → C a b open Op< ⦃ ... ⦄ public record Op> (A B : Set ℓ) (C : A → B → Set ℓ') : Set (ℓ-max ℓ ℓ') where infix 5 _>_ field _>_ : (a : A) → (b : B) → C a b open Op> ⦃ ... ⦄ public record Op≥ (A B : Set ℓ) (C : A → B → Set ℓ') : Set (ℓ-max ℓ ℓ') where infix 5 _≥_ field _≥_ : (a : A) → (b : B) → C a b open Op≥ ⦃ ... ⦄ public record Op≤ (A B : Set ℓ) (C : A → B → Set ℓ') : Set (ℓ-max ℓ ℓ') where infix 5 _≤_ field _≤_ : (a : A) → (b : B) → C a b open Op≤ ⦃ ... ⦄ public record Op== (A B : Set ℓ) (C : A → B → Set ℓ') : Set (ℓ-max ℓ ℓ') where infix 5 _==_ field _==_ : (a : A) → (b : B) → C a b open Op== ⦃ ... ⦄ public record Op+ (A B : Set ℓ) (C : A → B → Set ℓ') : Set (ℓ-max ℓ ℓ') where infixl 7 _+_ field _+_ : (a : A) → (b : B) → C a b open Op+ ⦃ ... ⦄ public record Op- (A B : Set ℓ) (C : A → B → Set ℓ') : Set (ℓ-max ℓ ℓ') where infixl 7 _-_ field _-_ : (a : A) → (b : B) → C a b open Op- ⦃ ... ⦄ public record Op* (A B : Set ℓ) (C : A → B → Set ℓ') : Set (ℓ-max ℓ ℓ') where infixl 8 _*_ field _*_ : (a : A) → (b : B) → C a b open Op* ⦃ ... ⦄ public record OpUnary- (A : Set ℓ) (B : A → Set ℓ') : Set (ℓ-max ℓ ℓ') where field -_ : (a : A) → B a open OpUnary- ⦃ ... ⦄ public instance ℕ< : Op< ℕ ℕ (const₂ Bool) _<_ ⦃ ℕ< ⦄ n m = n less-than m where _less-than_ : ℕ → ℕ → Bool zero less-than zero = false zero less-than suc _ = true suc _ less-than zero = false suc a less-than suc b = a less-than b instance ℕ> : Op> ℕ ℕ (const₂ Bool) _>_ ⦃ ℕ> ⦄ n m = n greater-than m where _greater-than_ : ℕ → ℕ → Bool zero greater-than zero = false zero greater-than suc b = false suc a greater-than zero = true suc a greater-than suc b = a greater-than b instance ℕ≥ : Op≥ ℕ ℕ (const₂ Bool) _≥_ ⦃ ℕ≥ ⦄ a b = not (a < b) instance ℕ≤ : Op≤ ℕ ℕ (const₂ Bool) _≤_ ⦃ ℕ≤ ⦄ a b = not (a > b) instance ℕ== : Op== ℕ ℕ (const₂ Bool) _==_ ⦃ ℕ== ⦄ a b = a eq b where _eq_ : ℕ → ℕ → Bool zero eq zero = true zero eq suc _ = false suc _ eq zero = false suc a eq suc b = a eq b a<b≡¬a≥b : {a b : ℕ} → a < b ≡ not (a ≥ b) a<b≡¬a≥b {a} {b} = sym (notnot (a < b)) a>b≡¬a≤b : {a b : ℕ} → a > b ≡ not (a ≤ b) a>b≡¬a≤b {a} {b} = sym (notnot (a > b)) instance ℕ+ : Op+ ℕ ℕ (const₂ ℕ) _+_ ⦃ ℕ+ ⦄ a b = a +ℕ b instance ℕ- : Op- ℕ ℕ (λ a b → ⦃ _ : a ≥ b ≡ true ⦄ → ℕ) _-_ ⦃ ℕ- ⦄ a b = a minus b where _minus_ : (a : ℕ) → (b : ℕ) → ⦃ _ : a ≥ b ≡ true ⦄ → ℕ n minus zero = n _minus_ zero (suc b) ⦃ a≥b ⦄ = ⊥-elim (false≢true a≥b) (suc a) minus (suc b) = a minus b instance ℕ* : Op* ℕ ℕ (const₂ ℕ) _*_ ⦃ ℕ* ⦄ a b = a *ℕ b --ℤ--------------- instance ℤ< : Op< ℤ ℤ (const₂ Bool) _<_ ⦃ ℤ< ⦄ n m = n less-than m where _less-than_ : ℤ → ℤ → Bool pos n less-than pos m = n < m neg n less-than neg m = n > m pos _ less-than neg _ = false neg zero less-than pos zero = false neg zero less-than pos (suc _) = true neg (suc _) less-than pos _ = true pos zero less-than posneg _ = false pos (suc _) less-than posneg _ = false neg zero less-than posneg _ = false neg (suc _) less-than posneg _ = true posneg _ less-than pos zero = false posneg _ less-than pos (suc _) = true posneg _ less-than neg zero = false posneg _ less-than neg (suc _) = false posneg _ less-than posneg _ = false instance ℤ> : Op> ℤ ℤ (const₂ Bool) _>_ ⦃ ℤ> ⦄ n m = m < n instance ℤ≥ : Op≥ ℤ ℤ (const₂ Bool) _≥_ ⦃ ℤ≥ ⦄ a b = not (a < b) instance ℤ≤ : Op≤ ℤ ℤ (const₂ Bool) _≤_ ⦃ ℤ≤ ⦄ a b = not (a > b) instance ℤ== : Op== ℤ ℤ (const₂ Bool) _==_ ⦃ ℤ== ⦄ a b = a eq b where _eq_ : ℤ → ℤ → Bool pos n eq pos m = n == m neg n eq neg m = n == m pos zero eq neg zero = true pos zero eq neg (suc _) = false pos (suc _) eq neg _ = false neg zero eq pos zero = true neg zero eq pos (suc _) = false neg (suc _) eq pos _ = false pos zero eq posneg _ = true pos (suc _) eq posneg _ = false neg zero eq posneg _ = true neg (suc _) eq posneg _ = false posneg _ eq pos zero = true posneg _ eq pos (suc _) = false posneg _ eq neg zero = true posneg _ eq neg (suc _) = false posneg _ eq posneg _ = true instance ℤ+ : Op+ ℤ ℤ (const₂ ℤ) _+_ ⦃ ℤ+ ⦄ a b = a +ℤ b instance ℤ- : Op- ℤ ℤ (const₂ ℤ) _-_ ⦃ ℤ- ⦄ a (pos n) = a + (neg n) _-_ ⦃ ℤ- ⦄ a (neg n) = a + (pos n) _-_ ⦃ ℤ- ⦄ a (posneg _) = a instance ℤ* : Op* ℤ ℤ (const₂ ℤ) _*_ ⦃ ℤ* ⦄ a b = a *ℤ b instance ℤunary- : OpUnary- ℤ (const ℤ) -_ ⦃ ℤunary- ⦄ (pos n) = neg n -_ ⦃ ℤunary- ⦄ (neg n) = pos n -_ ⦃ ℤunary- ⦄ (posneg i) = (sym posneg) i -- use of this lemma could be made automatic by changing `path` in ℚ to take instance arguments instead of implicit arguments. -- `nonzero-prod` would then be an instance of `¬ (q * r ≡ pos 0)` -- however currently, since `¬ (q * r ≡ pos 0)` is a function type, it is not allowed as an instance argument type nonzero-prod : (q r : ℤ) → ¬ (q ≡ 0) → ¬ (r ≡ 0) → ¬ (q * r ≡ 0) nonzero-prod (pos (suc n)) (pos (suc m)) _ _ q*r≡0 = snotz (cong absℤ q*r≡0) nonzero-prod (pos (suc n)) (neg (suc m)) _ _ q*r≡0 = snotz (cong absℤ q*r≡0) nonzero-prod (neg (suc n)) (pos (suc m)) _ _ q*r≡0 = snotz (cong absℤ q*r≡0) nonzero-prod (neg (suc n)) (neg (suc m)) _ _ q*r≡0 = snotz (cong absℤ q*r≡0) nonzero-prod (pos zero) _ q≢0 _ _ = q≢0 refl nonzero-prod (neg zero) _ q≢0 _ _ = q≢0 (sym posneg) nonzero-prod (pos (suc _)) (pos zero) _ r≢0 _ = r≢0 refl nonzero-prod (pos (suc _)) (neg zero) _ r≢0 _ = r≢0 (sym posneg) nonzero-prod (neg (suc _)) (pos zero) _ r≢0 _ = r≢0 refl nonzero-prod (neg (suc _)) (neg zero) _ r≢0 _ = r≢0 (sym posneg) nonzero-prod q@(pos (suc _)) (posneg i) _ r≢0 _ = r≢0 λ j → posneg (i ∧ ~ j) nonzero-prod q@(neg (suc _)) (posneg i) _ r≢0 _ = r≢0 λ j → posneg (i ∧ ~ j) nonzero-prod (posneg i) _ q≢0 _ _ = q≢0 λ j → posneg (i ∧ ~ j) 0≡m*ℤ0 : (m : ℤ) → 0 ≡ m * 0 0≡m*ℤ0 (pos n) = cong pos $ 0≡m*0 n 0≡m*ℤ0 (neg zero) = refl 0≡m*ℤ0 (neg (suc n)) = posneg ∙ (cong ℤ.neg $ 0≡m*0 n) 0≡m*ℤ0 (posneg i) = refl 0≡0*ℤm : (m : ℤ) → 0 ≡ 0 * m 0≡0*ℤm (pos n) = refl 0≡0*ℤm (neg zero) = refl 0≡0*ℤm (neg (suc n)) = posneg 0≡0*ℤm (posneg i) = refl m≡0+ℤm : (m : ℤ) → m ≡ 0 + m m≡0+ℤm (pos zero) = refl m≡0+ℤm (neg zero) = sym posneg m≡0+ℤm (posneg i) = λ j → posneg (i ∧ ~ j) m≡0+ℤm (pos (suc n)) = cong sucℤ $ m≡0+ℤm (pos n) m≡0+ℤm (neg (suc n)) = cong predℤ $ m≡0+ℤm (neg n) m≡m*1 : (m : ℕ) → m ≡ m * 1 m≡m*1 zero = refl m≡m*1 (suc m) = cong suc $ m≡m*1 m m≡m*ℤ1 : (m : ℤ) → m ≡ m * 1 m≡m*ℤ1 (pos zero) = refl m≡m*ℤ1 (pos (suc n)) = cong (ℤ.pos ∘ suc) $ m≡m*1 n m≡m*ℤ1 (neg zero) = sym posneg m≡m*ℤ1 (neg (suc n)) = cong (ℤ.neg ∘ suc) $ m≡m*1 n m≡m*ℤ1 (posneg i) = λ j → posneg (i ∧ ~ j) ℤ+-pred : (m n : ℤ) → m + predℤ n ≡ predℤ (m + n) ℤ+-pred m (pos zero) = refl ℤ+-pred m (pos (suc n)) = sym $ predSucℤ (m + pos n) ℤ+-pred m (neg n) = refl ℤ+-pred m (posneg i) = refl ℤ+-suc : (m n : ℤ) → m + sucℤ n ≡ sucℤ (m + n) ℤ+-suc m (pos zero) = refl ℤ+-suc m (pos (suc n)) = refl ℤ+-suc m (neg zero) = refl ℤ+-suc m (neg (suc n)) = sym $ sucPredℤ (m + neg n) ℤ+-suc m (posneg i) = refl ℤ+-comm-0 : (z : ℤ) → (i : I) → posneg i + z ≡ z ℤ+-comm-0 z i = cong (_+ z) (λ j → posneg (i ∧ ~ j)) ∙ sym (m≡0+ℤm z) ℤ+-comm-0-0 : (i j : I) → posneg i ≡ posneg j ℤ+-comm-0-0 i j = λ k → posneg ((~ k ∧ i) ∨ (k ∧ j)) ℤ+-comm : (m n : ℤ) → m + n ≡ n + m ℤ+-comm (pos zero) (pos zero) = ℤ+-comm-0-0 i0 i0 ℤ+-comm (neg zero) (neg zero) = ℤ+-comm-0-0 i1 i1 ℤ+-comm (pos zero) (neg zero) = ℤ+-comm-0-0 i0 i1 ℤ+-comm (neg zero) (pos zero) = ℤ+-comm-0-0 i1 i0 ℤ+-comm (posneg i) (pos zero) = ℤ+-comm-0-0 i i0 ℤ+-comm (posneg i) (neg zero) = ℤ+-comm-0-0 i i1 ℤ+-comm (pos zero) (posneg j) = ℤ+-comm-0-0 i0 j ℤ+-comm (neg zero) (posneg j) = ℤ+-comm-0-0 i1 j ℤ+-comm (posneg i) (posneg j) = ℤ+-comm-0-0 i j ℤ+-comm (pos zero) (pos (suc n)) = cong sucℤ $ ℤ+-comm-0 (pos n) i0 ℤ+-comm (neg zero) (pos (suc n)) = cong sucℤ $ ℤ+-comm-0 (pos n) i1 ℤ+-comm (posneg i) (pos (suc n)) = cong sucℤ $ ℤ+-comm-0 (pos n) i ℤ+-comm (pos zero) (neg (suc n)) = cong predℤ $ ℤ+-comm-0 (neg n) i0 ℤ+-comm (neg zero) (neg (suc n)) = cong predℤ $ ℤ+-comm-0 (neg n) i1 ℤ+-comm (posneg i) (neg (suc n)) = cong predℤ $ ℤ+-comm-0 (neg n) i ℤ+-comm (pos (suc m)) (pos zero) = cong sucℤ $ sym $ ℤ+-comm-0 (pos m) i0 ℤ+-comm (pos (suc m)) (neg zero) = cong sucℤ $ sym $ ℤ+-comm-0 (pos m) i1 ℤ+-comm (pos (suc m)) (posneg i) = cong sucℤ $ sym $ ℤ+-comm-0 (pos m) i ℤ+-comm (neg (suc m)) (pos zero) = cong predℤ $ sym $ ℤ+-comm-0 (neg m) i0 ℤ+-comm (neg (suc m)) (neg zero) = cong predℤ $ sym $ ℤ+-comm-0 (neg m) i1 ℤ+-comm (neg (suc m)) (posneg i) = cong predℤ $ sym $ ℤ+-comm-0 (neg m) i ℤ+-comm (pos (suc m)) (pos (suc n)) = cong sucℤ ( pos (suc m) + pos n ≡⟨ ℤ+-comm (pos (suc m)) (pos n) ⟩ pos n + pos (suc m) ≡⟨ refl ⟩ sucℤ (pos n + pos m) ≡⟨ cong sucℤ $ ℤ+-comm (pos n) (pos m) ⟩ sucℤ (pos m + pos n) ≡⟨ refl ⟩ pos m + pos (suc n) ≡⟨ ℤ+-comm (pos m) (pos (suc n)) ⟩ pos (suc n) + pos m ∎ ) ℤ+-comm (neg (suc m)) (pos (suc n)) = ( sucℤ (neg (suc m) + pos n) ≡⟨ cong sucℤ $ ℤ+-comm (neg (suc m)) (pos n) ⟩ sucℤ (pos n + neg (suc m)) ≡⟨ refl ⟩ sucℤ (predℤ (pos n + neg m)) ≡⟨ sucPredℤ _ ⟩ pos n + neg m ≡⟨ ℤ+-comm (pos n) (neg m) ⟩ neg m + pos n ≡⟨ sym $ predSucℤ _ ⟩ predℤ (sucℤ (neg m + pos n)) ≡⟨ refl ⟩ predℤ (neg m + pos (suc n)) ≡⟨ cong predℤ $ ℤ+-comm (neg m) (pos (suc n)) ⟩ predℤ (pos (suc n) + neg m) ∎ ) ℤ+-comm (pos (suc m)) (neg (suc n)) = ( predℤ (pos (suc m) + neg n) ≡⟨ cong predℤ $ ℤ+-comm (pos (suc m)) (neg n) ⟩ predℤ (neg n + pos (suc m)) ≡⟨ refl ⟩ predℤ (sucℤ (neg n + pos m)) ≡⟨ predSucℤ _ ⟩ neg n + pos m ≡⟨ ℤ+-comm (neg n) (pos m) ⟩ pos m + neg n ≡⟨ sym $ sucPredℤ _ ⟩ sucℤ (predℤ (pos m + neg n)) ≡⟨ refl ⟩ sucℤ (pos m + neg (suc n)) ≡⟨ cong sucℤ $ ℤ+-comm (pos m) (neg (suc n)) ⟩ sucℤ (neg (suc n) + pos m) ∎ ) ℤ+-comm (neg (suc m)) (neg (suc n)) = cong predℤ ( neg (suc m) + neg n ≡⟨ ℤ+-comm (neg (suc m)) (neg n) ⟩ neg n + neg (suc m) ≡⟨ refl ⟩ predℤ (neg n + neg m) ≡⟨ cong predℤ $ ℤ+-comm (neg n) (neg m) ⟩ predℤ (neg m + neg n) ≡⟨ refl ⟩ neg m + neg (suc n) ≡⟨ ℤ+-comm (neg m) (neg (suc n)) ⟩ neg (suc n) + neg m ∎ ) ℤ+-assoc : (m n o : ℤ) → m + (n + o) ≡ m + n + o ℤ+-assoc m n (pos zero) = refl ℤ+-assoc m n (pos (suc o)) = ( m + sucℤ (n + pos o) ≡⟨ ℤ+-suc m (n + pos o) ⟩ sucℤ (m + (n + pos o)) ≡⟨ cong sucℤ $ ℤ+-assoc m n (pos o) ⟩ sucℤ (m + n + pos o) ∎ ) ℤ+-assoc m n (neg zero) = refl ℤ+-assoc m n (neg (suc o)) = ( m + predℤ (n + neg o) ≡⟨ ℤ+-pred m (n + neg o) ⟩ predℤ (m + (n + neg o)) ≡⟨ cong predℤ $ ℤ+-assoc m n (neg o) ⟩ predℤ (m + n + neg o) ∎ ) ℤ+-assoc m n (posneg i) = refl lemma : (m n : ℕ) → n + m * suc n ≡ m + n * suc m lemma m n = ( n + m * suc n ≡⟨ cong (n +_) $ *-suc m n ⟩ n + (m + m * n) ≡⟨ +-assoc n m (m * n) ⟩ n + m + m * n ≡⟨ cong (_+ m * n) $ +-comm n m ⟩ m + n + m * n ≡⟨ cong (m + n +_) $ *-comm m n ⟩ m + n + n * m ≡⟨ sym $ +-assoc m n (n * m) ⟩ m + (n + n * m) ≡⟨ cong (m +_) $ sym $ *-suc n m ⟩ m + n * suc m ∎ ) ℤ*-comm : (m n : ℤ) → m * n ≡ n * m ℤ*-comm (pos zero) (pos zero) = refl ℤ*-comm (neg zero) (pos zero) = refl ℤ*-comm (posneg i) (pos zero) = refl ℤ*-comm (pos zero) (neg zero) = refl ℤ*-comm (neg zero) (neg zero) = refl ℤ*-comm (posneg i) (neg zero) = refl ℤ*-comm (pos zero) (posneg i) = refl ℤ*-comm (neg zero) (posneg i) = refl ℤ*-comm (posneg i) (posneg j) = refl ℤ*-comm (pos zero) (pos (suc n)) = cong pos $ 0≡m*0 n ℤ*-comm (neg zero) (pos (suc n)) = cong pos $ 0≡m*0 n ℤ*-comm (posneg i) (pos (suc n)) = cong pos $ 0≡m*0 n ℤ*-comm (pos zero) (neg (suc n)) = cong neg $ 0≡m*0 n ℤ*-comm (neg zero) (neg (suc n)) = cong neg $ 0≡m*0 n ℤ*-comm (posneg i) (neg (suc n)) = cong neg $ 0≡m*0 n ℤ*-comm (pos (suc m)) (pos zero) = cong pos $ sym $ 0≡m*0 m ℤ*-comm (neg (suc m)) (pos zero) = cong neg $ sym $ 0≡m*0 m ℤ*-comm (pos (suc m)) (neg zero) = cong pos $ sym $ 0≡m*0 m ℤ*-comm (neg (suc m)) (neg zero) = cong neg $ sym $ 0≡m*0 m ℤ*-comm (pos (suc m)) (posneg i) = cong pos $ sym $ 0≡m*0 m ℤ*-comm (neg (suc m)) (posneg i) = cong neg $ sym $ 0≡m*0 m ℤ*-comm (pos (suc m)) (neg (suc n)) = cong (ℤ.neg ∘ suc) $ lemma m n ℤ*-comm (neg (suc m)) (neg (suc n)) = cong (ℤ.pos ∘ suc) $ lemma m n ℤ*-comm (pos (suc m)) (pos (suc n)) = cong (ℤ.pos ∘ suc) $ lemma m n ℤ*-comm (neg (suc m)) (pos (suc n)) = cong (ℤ.neg ∘ suc) $ lemma m n neg-distrib-+ : (m n : ℕ) → neg (m + n) ≡ neg m + neg n neg-distrib-+ m zero = cong neg $ +-zero m neg-distrib-+ m (suc n) = ( neg (m + suc n) ≡⟨ cong neg $ +-suc m n ⟩ predℤ (neg (m + n)) ≡⟨ cong predℤ $ neg-distrib-+ m n ⟩ predℤ (neg m + neg n) ∎ ) pos-distrib-+ : (m n : ℕ) → pos (m + n) ≡ pos m + pos n pos-distrib-+ m zero = cong pos $ +-zero m pos-distrib-+ m (suc n) = ( pos (m + suc n) ≡⟨ cong pos $ +-suc m n ⟩ sucℤ (pos (m + n)) ≡⟨ cong sucℤ $ pos-distrib-+ m n ⟩ sucℤ (pos m + pos n) ∎ ) lemma2 : (m n : ℕ) → suc (n + m * suc (suc n)) ≡ suc m + (n + m * suc n) lemma2 m n = ( suc (n + m * suc (suc n)) ≡⟨ cong (suc ∘ (n +_)) $ *-suc m (suc n) ⟩ suc (n + (m + m * suc n)) ≡⟨ cong (suc ∘ (n +_)) $ +-comm m (m * suc n) ⟩ suc (n + (m * suc n + m)) ≡⟨ cong (suc) $ +-assoc n (m * suc n) m ⟩ suc (n + m * suc n + m) ≡⟨ sym $ +-suc (n + m * suc n) m ⟩ n + m * suc n + suc m ≡⟨ +-comm (n + m * suc n) (suc m) ⟩ suc m + (n + m * suc n) ∎ ) lemma3 : (m : ℤ) → (i : I) → m * 1 ≡ (m + m * posneg i) lemma3 m i = ( m * 1 ≡⟨ sym $ m≡m*ℤ1 m ⟩ m ≡⟨ refl ⟩ m + 0 ≡⟨ cong (m +_) $ 0≡m*ℤ0 m ⟩ m + m * 0 ≡⟨ cong (λ x → m + m * x) (λ j → posneg (i ∧ j)) ⟩ m + m * posneg i ∎ ) ℤ-m+-m≡0 : (m : ℕ) → pos m + neg m ≡ 0 ℤ-m+-m≡0 zero = refl ℤ-m+-m≡0 (suc m) = ( predℤ (pos (suc m) + neg m) ≡⟨ cong predℤ $ ℤ+-comm (pos (suc m)) (neg m) ⟩ predℤ (neg m + pos (suc m)) ≡⟨ refl ⟩ predℤ (sucℤ (neg m + pos m)) ≡⟨ predSucℤ _ ⟩ neg m + pos m ≡⟨ ℤ+-comm (neg m) (pos m) ⟩ pos m + neg m ≡⟨ ℤ-m+-m≡0 m ⟩ 0 ∎ ) ℤ--m+m≡0 : (m : ℕ) → neg m + pos m ≡ 0 ℤ--m+m≡0 m = ℤ+-comm (neg m) (pos m) ∙ ℤ-m+-m≡0 m ℤ*-suc : (m n : ℤ) → m * sucℤ n ≡ m + m * n ℤ*-suc m (pos zero) = lemma3 m i0 ℤ*-suc m (neg zero) = lemma3 m i1 ℤ*-suc m (posneg i) = lemma3 m i ℤ*-suc (pos zero) (pos (suc n)) = refl ℤ*-suc (neg zero) (pos (suc n)) = posneg ℤ*-suc (posneg i) (pos (suc n)) = λ j → posneg (i ∧ j) ℤ*-suc (pos zero) (neg (suc zero)) = refl ℤ*-suc (pos zero) (neg (suc (suc n))) = sym posneg ℤ*-suc (neg zero) (neg (suc zero)) = posneg ℤ*-suc (neg zero) (neg (suc (suc n))) = refl ℤ*-suc (posneg i) (neg (suc zero)) = λ j → posneg (i ∧ j) ℤ*-suc (posneg i) (neg (suc (suc n))) = λ j → posneg (i ∨ ~ j) ℤ*-suc (pos (suc m)) (neg (suc zero)) = ( pos (suc m) * -0 ≡⟨ cong (pos (suc m) *_) $ sym $ posneg ⟩ pos (suc m) * 0 ≡⟨ sym $ 0≡m*ℤ0 (pos (suc m)) ⟩ 0 ≡⟨ sym $ ℤ--m+m≡0 m ⟩ neg m + pos m ≡⟨ sym $ predSucℤ _ ⟩ predℤ (sucℤ (neg m + pos m)) ≡⟨ refl ⟩ predℤ (neg m + pos (suc m)) ≡⟨ cong predℤ $ ℤ+-comm (neg m) (pos (suc m)) ⟩ predℤ (pos (suc m) + neg m) ≡⟨ cong (predℤ ∘ (pos (suc m) +_) ∘ ℤ.neg) $ m≡m*1 m ⟩ predℤ (pos (suc m) + neg (m * 1)) ∎ ) ℤ*-suc (pos (suc m)) (neg (suc (suc n))) = cong predℤ $ sym ( predℤ (pos (suc m) + neg (n + m * suc (suc n))) ≡⟨ cong predℤ $ ℤ+-comm (pos (suc m)) (neg (n + m * suc (suc n))) ⟩ predℤ (neg (n + m * suc (suc n)) + pos (suc m)) ≡⟨ refl ⟩ predℤ (sucℤ (neg (n + m * suc (suc n)) + pos m)) ≡⟨ predSucℤ (neg (n + m * suc (suc n)) + pos m) ⟩ neg (n + m * suc (suc n)) + pos m ≡⟨ cong ((_+ pos m) ∘ ℤ.neg ∘ (n +_)) $ *-suc m (suc n) ⟩ neg (n + (m + m * suc n)) + pos m ≡⟨ cong ((_+ pos m) ∘ ℤ.neg ∘ (n +_)) $ +-comm m (m * suc n) ⟩ neg (n + (m * suc n + m)) + pos m ≡⟨ cong ((_+ pos m) ∘ ℤ.neg) $ +-assoc n (m * suc n) m ⟩ neg (n + m * suc n + m) + pos m ≡⟨ cong (_+ pos m) $ neg-distrib-+ (n + m * suc n) m ⟩ neg (n + m * suc n) + neg m + pos m ≡⟨ sym $ ℤ+-assoc (neg (n + m * suc n)) (neg m) (pos m) ⟩ neg (n + m * suc n) + (neg m + pos m) ≡⟨ cong (neg (n + m * suc n) +_) $ ℤ--m+m≡0 m ⟩ neg (n + m * suc n) + 0 ≡⟨ refl ⟩ neg (n + m * suc n) ∎ ) ℤ*-suc (neg (suc m)) (neg (suc zero)) = ( neg (suc m) * -0 ≡⟨ cong (neg (suc m) *_) $ sym $ posneg ⟩ neg (suc m) * 0 ≡⟨ sym $ 0≡m*ℤ0 (neg (suc m)) ⟩ 0 ≡⟨ sym $ ℤ-m+-m≡0 m ⟩ pos m + neg m ≡⟨ sym $ sucPredℤ (pos m + neg m) ⟩ sucℤ (predℤ (pos m + neg m)) ≡⟨ refl ⟩ sucℤ (pos m + neg (suc m)) ≡⟨ cong sucℤ $ ℤ+-comm (pos m) (neg (suc m)) ⟩ sucℤ (neg (suc m) + pos m) ≡⟨ cong (sucℤ ∘ (neg (suc m) +_) ∘ ℤ.pos) $ m≡m*1 m ⟩ sucℤ (neg (suc m) + pos (m * 1)) ∎ ) ℤ*-suc (neg (suc m)) (neg (suc (suc n))) = cong sucℤ $ sym ( sucℤ (predℤ (neg m) + pos (n + m * suc (suc n))) ≡⟨ cong sucℤ $ ℤ+-comm (predℤ (neg m)) (pos (n + m * suc (suc n))) ⟩ sucℤ (pos (n + m * suc (suc n)) + predℤ (neg m)) ≡⟨ cong sucℤ $ ℤ+-pred (pos (n + m * suc (suc n))) (neg m) ⟩ sucℤ (predℤ (pos (n + m * suc (suc n)) + neg m)) ≡⟨ sucPredℤ _ ⟩ pos (n + m * suc (suc n)) + neg m ≡⟨ cong ((_+ neg m) ∘ ℤ.pos ∘ (n +_)) $ *-suc m (suc n) ⟩ pos (n + (m + m * suc n)) + neg m ≡⟨ cong ((_+ neg m) ∘ ℤ.pos) $ +-assoc n m (m * suc n) ⟩ pos (n + m + m * suc n) + neg m ≡⟨ cong ((_+ neg m) ∘ ℤ.pos ∘ (_+ m * suc n)) $ +-comm n m ⟩ pos (m + n + m * suc n) + neg m ≡⟨ cong ((_+ neg m) ∘ ℤ.pos) $ sym $ +-assoc m n (m * suc n) ⟩ pos (m + (n + m * suc n)) + neg m ≡⟨ cong (_+ neg m) $ pos-distrib-+ m (n + m * suc n) ⟩ pos m + pos (n + m * suc n) + neg m ≡⟨ cong (_+ neg m) $ ℤ+-comm (pos m) (pos (n + m * suc n)) ⟩ pos (n + m * suc n) + pos m + neg m ≡⟨ sym $ ℤ+-assoc (pos (n + m * suc n)) (pos m) (neg m) ⟩ pos (n + m * suc n) + (pos m + neg m) ≡⟨ cong (pos (n + m * suc n) +_) $ ℤ-m+-m≡0 m ⟩ pos (n + m * suc n) + 0 ≡⟨ refl ⟩ pos (n + m * suc n) ∎ ) ℤ*-suc (pos (suc m)) (pos (suc n)) = cong sucℤ ( pos (suc (n + m * suc (suc n))) ≡⟨ cong ℤ.pos $ lemma2 m n ⟩ pos (suc m + (n + m * suc n)) ≡⟨ pos-distrib-+ (suc m) (n + m * suc n) ⟩ pos (suc m) + pos (n + m * suc n) ∎ ) ℤ*-suc (neg (suc m)) (pos (suc n)) = cong predℤ ( neg (suc (n + m * suc (suc n))) ≡⟨ cong ℤ.neg $ lemma2 m n ⟩ neg (suc m + (n + m * suc n)) ≡⟨ neg-distrib-+ (suc m) (n + m * suc n) ⟩ neg (suc m) + neg (n + m * suc n) ∎ ) lemma4 : (m : ℕ) → neg (suc (m * 1)) ≡ predℤ (pos (m * 0) + neg m) lemma4 m = cong predℤ ( neg (m * 1) ≡⟨ cong ℤ.neg $ sym $ m≡m*1 m ⟩ neg m ≡⟨ m≡0+ℤm _ ⟩ pos 0 + neg m ≡⟨ cong ((_+ neg m) ∘ ℤ.pos) $ 0≡m*0 m ⟩ pos (m * 0) + neg m ∎ ) lemma5 : (m : ℕ) → pos (suc (m * 1)) ≡ sucℤ (neg (m * 0) + pos m) lemma5 m = cong sucℤ ( pos (m * 1) ≡⟨ cong ℤ.pos $ sym $ m≡m*1 m ⟩ pos m ≡⟨ m≡0+ℤm _ ⟩ 0 + pos m ≡⟨ cong (_+ pos m) posneg ⟩ neg 0 + pos m ≡⟨ cong ((_+ pos m) ∘ ℤ.neg) $ 0≡m*0 m ⟩ neg (m * 0) + pos m ∎ ) lemma6 : (m n : ℕ) → n + m * suc (suc n) ≡ m + (n + m * suc n) lemma6 m n = ( n + m * suc (suc n) ≡⟨ cong (n +_) $ *-suc m (suc n) ⟩ n + (m + m * suc n) ≡⟨ +-assoc n m (m * suc n) ⟩ n + m + m * suc n ≡⟨ cong (_+ m * suc n) $ +-comm n m ⟩ m + n + m * suc n ≡⟨ sym $ +-assoc m n (m * suc n) ⟩ m + (n + m * suc n) ∎ ) lemma7 : (m n : ℕ) → m + (n + m * n) ≡ n + m * suc n lemma7 m n = ( m + (n + m * n) ≡⟨ +-assoc m n (m * n) ⟩ m + n + m * n ≡⟨ cong (_+ m * n) $ +-comm m n ⟩ n + m + m * n ≡⟨ sym $ +-assoc n m (m * n) ⟩ n + (m + m * n) ≡⟨ cong (n +_) $ sym $ *-suc m n ⟩ n + m * suc n ∎ ) ℤ*-pred : (m n : ℤ) → m * predℤ n ≡ m * n - m ℤ*-pred (pos zero) (pos zero) = sym posneg ℤ*-pred (neg zero) (pos zero) = sym posneg ℤ*-pred (posneg i) (pos zero) = sym posneg ℤ*-pred (pos zero) (neg zero) = sym posneg ℤ*-pred (neg zero) (neg zero) = sym posneg ℤ*-pred (posneg i) (neg zero) = sym posneg ℤ*-pred (pos zero) (posneg i) = sym posneg ℤ*-pred (neg zero) (posneg i) = sym posneg ℤ*-pred (posneg i) (posneg j) = sym posneg ℤ*-pred (pos (suc m)) (pos zero) = lemma4 m ℤ*-pred (pos (suc m)) (neg zero) = lemma4 m ℤ*-pred (pos (suc m)) (posneg i) = lemma4 m ℤ*-pred (neg (suc m)) (pos zero) = lemma5 m ℤ*-pred (neg (suc m)) (neg zero) = lemma5 m ℤ*-pred (neg (suc m)) (posneg i) = lemma5 m ℤ*-pred (pos zero) (pos (suc n)) = refl ℤ*-pred (neg zero) (pos (suc n)) = refl ℤ*-pred (posneg i) (pos (suc n)) = refl ℤ*-pred (pos zero) (neg (suc n)) = refl ℤ*-pred (neg zero) (neg (suc n)) = refl ℤ*-pred (posneg i) (neg (suc n)) = refl ℤ*-pred (pos (suc m)) (pos (suc n)) = ( pos (n + m * n) ≡⟨ m≡0+ℤm _ ⟩ 0 + pos (n + m * n) ≡⟨ cong (_+ pos (n + m * n)) $ sym $ ℤ--m+m≡0 m ⟩ neg m + pos m + pos (n + m * n) ≡⟨ sym $ ℤ+-assoc (neg m) (pos m) (pos (n + m * n)) ⟩ neg m + (pos m + pos (n + m * n)) ≡⟨ cong (neg m +_) $ sym $ pos-distrib-+ m (n + m * n) ⟩ neg m + pos (m + (n + m * n)) ≡⟨ cong ((neg m +_) ∘ ℤ.pos) $ lemma7 m n ⟩ neg m + pos (n + m * suc n) ≡⟨ cong (neg m +_) $ sym $ predSucℤ (pos (n + m * suc n)) ⟩ neg m + predℤ (sucℤ (pos (n + m * suc n))) ≡⟨ ℤ+-pred (neg m) (sucℤ (pos (n + m * suc n))) ⟩ predℤ (neg m + sucℤ (pos (n + m * suc n))) ≡⟨ cong predℤ $ ℤ+-comm (neg m) (sucℤ (pos (n + m * suc n))) ⟩ predℤ (sucℤ (pos (n + m * suc n)) + neg m) ∎ ) ℤ*-pred (neg (suc m)) (pos (suc n)) = ( neg (n + m * n) ≡⟨ m≡0+ℤm _ ⟩ 0 + neg (n + m * n) ≡⟨ cong (_+ neg (n + m * n)) $ sym $ ℤ-m+-m≡0 m ⟩ pos m + neg m + neg (n + m * n) ≡⟨ sym $ ℤ+-assoc (pos m) (neg m) (neg (n + m * n)) ⟩ pos m + (neg m + neg (n + m * n)) ≡⟨ cong (pos m +_) $ sym $ neg-distrib-+ m (n + m * n) ⟩ pos m + neg (m + (n + m * n)) ≡⟨ cong ((pos m +_) ∘ ℤ.neg) $ lemma7 m n ⟩ pos m + neg (n + m * suc n) ≡⟨ cong (pos m +_) $ sym $ sucPredℤ (neg (n + m * suc n)) ⟩ pos m + sucℤ (predℤ (neg (n + m * suc n))) ≡⟨ ℤ+-suc (pos m) (predℤ (neg (n + m * suc n))) ⟩ sucℤ (pos m + predℤ (neg (n + m * suc n))) ≡⟨ cong sucℤ $ ℤ+-comm (pos m) (predℤ (neg (n + m * suc n))) ⟩ sucℤ (predℤ (neg (n + m * suc n)) + pos m) ∎ ) ℤ*-pred (pos (suc m)) (neg (suc n)) = cong predℤ ( predℤ (neg (n + m * suc (suc n))) ≡⟨ cong (predℤ ∘ ℤ.neg) $ lemma6 m n ⟩ predℤ (neg (m + (n + m * suc n))) ≡⟨ cong predℤ $ neg-distrib-+ m (n + m * suc n) ⟩ predℤ (neg m + neg (n + m * suc n)) ≡⟨ ℤ+-pred (neg m) (neg (n + m * suc n)) ⟩ neg m + predℤ (neg (n + m * suc n)) ≡⟨ ℤ+-comm (neg m) (predℤ (neg (n + m * suc n))) ⟩ predℤ (neg (n + m * suc n)) + neg m ∎ ) ℤ*-pred (neg (suc m)) (neg (suc n)) = cong sucℤ ( sucℤ (pos (n + m * suc (suc n))) ≡⟨ cong (sucℤ ∘ ℤ.pos) $ lemma6 m n ⟩ sucℤ (pos (m + (n + m * suc n))) ≡⟨ cong sucℤ $ pos-distrib-+ m (n + m * suc n) ⟩ sucℤ (pos m + pos (n + m * suc n)) ≡⟨ sym $ ℤ+-suc (pos m) (pos (n + m * suc n)) ⟩ pos m + sucℤ (pos (n + m * suc n)) ≡⟨ ℤ+-comm (pos m) (sucℤ (pos (n + m * suc n))) ⟩ sucℤ (pos (n + m * suc n)) + pos m ∎ ) lemma-ℤ*+-right-distrib : ∀ i → (q r : ℤ) → (q + r) * posneg i ≡ q * posneg i + r * posneg i lemma-ℤ*+-right-distrib i q r = ( (q + r) * 0 ≡⟨ sym $ 0≡m*ℤ0 (q + r) ⟩ 0 ≡⟨ refl ⟩ 0 + 0 ≡⟨ cong (0 +_) $ 0≡m*ℤ0 r ⟩ 0 + (r * 0) ≡⟨ cong (_+ (r * 0)) $ 0≡m*ℤ0 q ⟩ (q * 0) + (r * 0) ∎ ) ℤ*+-right-distrib : (q r s : ℤ) → (q + r) * s ≡ q * s + r * s ℤ*+-right-distrib q r (pos zero) = lemma-ℤ*+-right-distrib i0 q r ℤ*+-right-distrib q r (neg zero) = lemma-ℤ*+-right-distrib i1 q r ℤ*+-right-distrib q r (posneg i) = lemma-ℤ*+-right-distrib i q r ℤ*+-right-distrib q r (pos (suc n)) = ( (q + r) * sucℤ (pos n) ≡⟨ ℤ*-suc (q + r) (pos n) ⟩ q + r + (q + r) * pos n ≡⟨ cong (q + r +_) $ ℤ*+-right-distrib q r (pos n) ⟩ q + r + (q * pos n + r * pos n) ≡⟨ ℤ+-assoc (q + r) (q * pos n) (r * pos n) ⟩ q + r + q * pos n + r * pos n ≡⟨ cong (_+ r * pos n) $ sym $ ℤ+-assoc q r (q * pos n) ⟩ q + (r + q * pos n) + r * pos n ≡⟨ cong ((_+ r * pos n) ∘ (q +_)) $ ℤ+-comm r (q * pos n) ⟩ q + (q * pos n + r) + r * pos n ≡⟨ cong (_+ r * pos n) $ ℤ+-assoc q (q * pos n) r ⟩ q + q * pos n + r + r * pos n ≡⟨ sym $ ℤ+-assoc (q + q * pos n) r (r * pos n) ⟩ q + q * pos n + (r + r * pos n) ≡⟨ cong (q + q * pos n +_) $ sym $ ℤ*-suc r (pos n) ⟩ q + q * pos n + r * sucℤ (pos n) ≡⟨ cong (_+ r * sucℤ (pos n)) $ sym $ ℤ*-suc q (pos n) ⟩ q * sucℤ (pos n) + r * sucℤ (pos n) ∎ ) ℤ*+-right-distrib q r (neg (suc n)) = ( (q + r) * predℤ (neg n) ≡⟨ ℤ*-pred (q + r) (neg n) ⟩ (q + r) * (neg n) - (q + r) ≡⟨ cong (_- (q + r)) $ ℤ*+-right-distrib q r (neg n) ⟩ q * neg n + r * neg n - (q + r) ≡⟨ {!!} ⟩ -- TODO: needs things like a + (- b) = a - b q * neg n - q + (r * neg n - r) ≡⟨ cong (q * neg n - q +_) $ sym $ ℤ*-pred r (neg n) ⟩ q * neg n - q + r * predℤ (neg n) ≡⟨ cong (_+ r * predℤ (neg n)) $ sym $ ℤ*-pred q (neg n) ⟩ q * predℤ (neg n) + r * predℤ (neg n) ∎ ) ℤ*+-left-distrib : (q r s : ℤ) → q * (r + s) ≡ q * r + q * s ℤ*+-left-distrib q r s = ( q * (r + s) ≡⟨ ℤ*-comm q (r + s) ⟩ (r + s) * q ≡⟨ ℤ*+-right-distrib r s q ⟩ r * q + s * q ≡⟨ cong (_+ s * q) $ ℤ*-comm r q ⟩ q * r + s * q ≡⟨ cong (q * r +_) $ ℤ*-comm s q ⟩ q * r + q * s ∎ ) lemma-ℤ*-assoc : ∀ i → (m n : ℤ) → m * (n * posneg i) ≡ m * n * posneg i lemma-ℤ*-assoc i m n = ( m * (n * 0) ≡⟨ cong (m *_) $ sym $ 0≡m*ℤ0 n ⟩ m * 0 ≡⟨ sym $ 0≡m*ℤ0 m ⟩ 0 ≡⟨ 0≡m*ℤ0 (m * n) ⟩ m * n * 0 ∎ ) ℤ*-assoc : (m n o : ℤ) → m * (n * o) ≡ m * n * o ℤ*-assoc m n (pos zero) = lemma-ℤ*-assoc i0 m n ℤ*-assoc m n (neg zero) = lemma-ℤ*-assoc i1 m n ℤ*-assoc m n (posneg i) = lemma-ℤ*-assoc i m n ℤ*-assoc m n (pos (suc o)) = ( m * (n * sucℤ (pos o)) ≡⟨ cong (m *_) $ ℤ*-suc n (pos o) ⟩ m * (n + n * pos o) ≡⟨ ℤ*+-left-distrib m n (n * pos o) ⟩ m * n + m * (n * pos o) ≡⟨ cong (m * n +_) $ ℤ*-assoc m n (pos o) ⟩ m * n + m * n * pos o ≡⟨ sym $ ℤ*-suc (m * n) (pos o) ⟩ m * n * sucℤ (pos o) ∎ ) ℤ*-assoc m n (neg (suc o)) = ( m * (n * predℤ (neg o)) ≡⟨ cong (m *_) $ ℤ*-pred n (neg o) ⟩ m * (n * neg o - n) ≡⟨ {!!} ⟩ -- TODO: needs things like a + (- b) = a - b m * (n * neg o) - m * n ≡⟨ cong (_- m * n) $ ℤ*-assoc m n (neg o) ⟩ m * n * neg o - m * n ≡⟨ sym $ ℤ*-pred (m * n) (neg o) ⟩ m * n * predℤ (neg o) ∎ ) instance ℚ+ : Op+ ℚ ℚ (const₂ ℚ) _+_ ⦃ ℚ+ ⦄ q r = q plus r where plus-lemma1 : (u a v b w c : ℤ) (x : ¬ a ≡ 0) (p₁ : ¬ b ≡ 0) (p₂ : ¬ c ≡ 0) (y : v * c ≡ w * b) → con (u * b + v * a) (a * b) (nonzero-prod a b x p₁) ≡ con (u * c + w * a) (a * c) (nonzero-prod a c x p₂) plus-lemma1 u a v b w c x p₁ p₂ y = path _ _ _ _ $ (u * b + v * a) * (a * c) ≡⟨ ℤ*+-right-distrib (u * b) (v * a) (a * c) ⟩ u * b * (a * c) + v * a * (a * c) ≡⟨ cong (_+ (v * a * (a * c))) $ u * b * (a * c) ≡⟨ sym $ ℤ*-assoc u b (a * c) ⟩ u * (b * (a * c)) ≡⟨ cong (u *_) $ ℤ*-comm b (a * c) ⟩ u * (a * c * b) ≡⟨ cong ((u *_) ∘ (_* b)) $ ℤ*-comm a c ⟩ u * (c * a * b) ≡⟨ cong (u *_) $ sym $ ℤ*-assoc c a b ⟩ u * (c * (a * b)) ≡⟨ ℤ*-assoc u c (a * b) ⟩ u * c * (a * b) ∎ ⟩ u * c * (a * b) + v * a * (a * c) ≡⟨ cong (u * c * (a * b) +_) $ v * a * (a * c) ≡⟨ sym $ ℤ*-assoc v a (a * c) ⟩ v * (a * (a * c)) ≡⟨ cong (v *_) $ ℤ*-comm a (a * c) ⟩ v * (a * c * a) ≡⟨ cong ((v *_) ∘ (_* a)) $ ℤ*-comm a c ⟩ v * (c * a * a) ≡⟨ cong (v *_) $ sym $ ℤ*-assoc c a a ⟩ v * (c * (a * a)) ≡⟨ ℤ*-assoc v c (a * a) ⟩ v * c * (a * a) ≡⟨ cong (_* (a * a)) y ⟩ w * b * (a * a) ≡⟨ sym $ ℤ*-assoc w b (a * a) ⟩ w * (b * (a * a)) ≡⟨ cong (w *_) $ ℤ*-assoc b a a ⟩ w * (b * a * a) ≡⟨ cong ((w *_) ∘ (_* a)) $ ℤ*-comm b a ⟩ w * (a * b * a) ≡⟨ cong (w *_) $ ℤ*-comm (a * b) a ⟩ w * (a * (a * b)) ≡⟨ ℤ*-assoc w a (a * b) ⟩ w * a * (a * b) ∎ ⟩ u * c * (a * b) + w * a * (a * b) ≡⟨ sym $ ℤ*+-right-distrib (u * c) (w * a) (a * b) ⟩ (u * c + w * a) * (a * b) ∎ plus-lemma2 : (u a v b w c : ℤ) (x : ¬ a ≡ 0) (p₁ : ¬ b ≡ 0) (p₂ : ¬ c ≡ 0) (y : v * c ≡ w * b) → con (v * a + u * b) (b * a) (nonzero-prod b a p₁ x) ≡ con (w * a + u * c) (c * a) (nonzero-prod c a p₂ x) plus-lemma2 u a v b w c x p₁ p₂ y = -- trying to reuse plus_lemma1 with this proof con (v * a + u * b) (b * a) _ ≡⟨ cong (λ nom → con nom (b * a) _) $ ℤ+-comm (v * a) (u * b) ⟩ con (u * b + v * a) (b * a) _ ≡⟨ cong₂ (λ denom prf → con (u * b + v * a) denom prf) (ℤ*-comm b a) $ {!!} ⟩ -- TODO: not sure if this is the right approach con (u * b + v * a) (a * b) (nonzero-prod a b x p₁) ≡⟨ plus-lemma1 u a v b w c x p₁ p₂ y ⟩ con (u * c + w * a) (a * c) (nonzero-prod a c x p₂) ≡⟨ cong₂ (λ denom prf → con (u * c + w * a) denom prf) (ℤ*-comm a c) $ {!!} ⟩ -- TODO: ditto con (u * c + w * a) (c * a) (nonzero-prod c a p₂ x) ≡⟨ cong (λ nom → con nom (c * a) (nonzero-prod c a p₂ x)) $ ℤ+-comm (u * c) (w * a) ⟩ con (w * a + u * c) (c * a) _ ∎ _plus_ : ℚ → ℚ → ℚ con u a x plus con v b y = con (u * b + v * a) (a * b) (nonzero-prod a b x y) con u a x plus path v b w c {p₁} {p₂} y i = plus-lemma1 u a v b w c x p₁ p₂ y i path v b w c {p₁} {p₂} y i plus con u a x = plus-lemma2 u a v b w c x p₁ p₂ y i path u a v b {p} {q} x i plus path u₁ a₁ v₁ b₁ {p₁} {q₁} x₁ j = isSet→isSet' trunc (plus-lemma1 u a u₁ a₁ v₁ b₁ p p₁ q₁ x₁) (plus-lemma1 v b u₁ a₁ v₁ b₁ q p₁ q₁ x₁) (plus-lemma2 u₁ a₁ u a v b p₁ p q x) (plus-lemma2 v₁ b₁ u a v b q₁ p q x) i j q@(path _ _ _ _ _ _) plus trunc r r₁ x y i i₁ = trunc (q plus r) (q plus r₁) (cong (q plus_) x) (cong (q plus_) y) i i₁ q@(con _ _ _) plus trunc r r₁ x y i i₁ = trunc (q plus r) (q plus r₁) (cong (q plus_) x) (cong (q plus_) y) i i₁ trunc q q₁ x y i i₁ plus r = trunc (q plus r) (q₁ plus r) (cong (_plus r) x) (cong (_plus r) y) i i₁ neg-assoc* : {a b : ℤ} → - (a * b) ≡ (- a) * b neg-assoc* {pos zero} {pos n₁} = sym posneg neg-assoc* {pos (suc n)} {pos n₁} = refl neg-assoc* {pos zero} {neg zero} = sym posneg neg-assoc* {pos zero} {neg (suc n₁)} = posneg neg-assoc* {pos (suc n)} {neg zero} = refl neg-assoc* {pos (suc n)} {neg (suc n₁)} = refl neg-assoc* {pos zero} {posneg i} = sym posneg neg-assoc* {pos (suc n)} {posneg i} = refl neg-assoc* {neg zero} {pos n₁} = sym posneg neg-assoc* {neg (suc n)} {pos n₁} = refl neg-assoc* {neg zero} {neg zero} = sym posneg neg-assoc* {neg (suc n)} {neg zero} = refl neg-assoc* {neg zero} {neg (suc n₁)} = posneg neg-assoc* {neg (suc n)} {neg (suc n₁)} = refl neg-assoc* {neg zero} {posneg i} = sym posneg neg-assoc* {neg (suc n)} {posneg i} = refl neg-assoc* {posneg i} {pos n} = sym posneg neg-assoc* {posneg i} {neg zero} = sym posneg neg-assoc* {posneg i} {neg (suc n)} = posneg neg-assoc* {posneg i} {posneg i₁} = sym posneg instance ℚunary- : OpUnary- ℚ (const ℚ) -_ ⦃ ℚunary- ⦄ q = negative q where negative : ℚ → ℚ negative (con u a x) = con (- u) a x negative (path u a v b {p} {q} x i) = path (- u) a (- v) b {p = p} {q = q} ( - u * b ≡⟨ sym $ neg-assoc* {a = u} {b = b} ⟩ - (u * b) ≡⟨ cong -_ x ⟩ - (v * a) ≡⟨ neg-assoc* {a = v} {b = a} ⟩ - v * a ∎ ) i negative (trunc q q₁ x y i i₁) = trunc (negative q) (negative q₁) (cong negative x) (cong negative y) i i₁ instance ℚ- : Op- ℚ ℚ (const₂ ℚ) _-_ ⦃ ℚ- ⦄ q r = q + (- r) instance ℚ< : Op< ℚ ℚ (const₂ Bool) _<_ ⦃ ℚ< ⦄ n m = n less-than m where _less-than_ : ℚ → ℚ → Bool con u a _ less-than con v b _ = u * b < v * a q@(con u a x) less-than path v b w c y i = {!!} -- not sure path u a v b x i less-than r = {!!} q@(con _ _ _) less-than trunc r r₁ x y i i₁ = isSetBool (q less-than r) (q less-than r₁) (cong (q less-than_) x) (cong (q less-than_) y) i i₁ trunc q q₁ x y i i₁ less-than r = isSetBool (q less-than r) (q₁ less-than r) (cong (_less-than r) x) (cong (_less-than r) y) i i₁ instance ℚ> : Op> ℚ ℚ (const₂ Bool) _>_ ⦃ ℚ> ⦄ n m = m < n pabsℤ : ℤ → ℤ pabsℤ = pos ∘ absℤ abs-distrib* : {a b : ℤ} → pabsℤ (a * b) ≡ pabsℤ a * pabsℤ b abs-distrib* {pos n} {pos n₁} = refl abs-distrib* {pos n} {neg zero} = refl abs-distrib* {pos n} {neg (suc n₁)} = refl abs-distrib* {pos n} {posneg i} = refl abs-distrib* {neg zero} {pos n₁} = refl abs-distrib* {neg (suc n)} {pos n₁} = refl abs-distrib* {neg zero} {neg zero} = refl abs-distrib* {neg zero} {neg (suc n₁)} = refl abs-distrib* {neg (suc n)} {neg zero} = refl abs-distrib* {neg (suc n)} {neg (suc n₁)} = refl abs-distrib* {neg zero} {posneg i} = refl abs-distrib* {neg (suc n)} {posneg i} = refl abs-distrib* {posneg i} {pos n} = refl abs-distrib* {posneg i} {neg zero} = refl abs-distrib* {posneg i} {neg (suc n)} = refl abs-distrib* {posneg i} {posneg i₁} = refl abs-zero : {a : ℤ} → pabsℤ a ≡ 0 → a ≡ 0 abs-zero {pos zero} _ = refl abs-zero {pos (suc _)} p = p abs-zero {neg zero} _ = sym posneg abs-zero {neg (suc _)} p = cong (neg ∘ absℤ) p ∙ (sym posneg) abs-zero {posneg i} _ = λ j → posneg (i ∧ ~ j) abs : ℚ → ℚ abs (con u a x) = con (pabsℤ u) (pabsℤ a) λ y → x (abs-zero y) abs (path u a v b {p} {q} x i) = path (pabsℤ u) (pabsℤ a) (pabsℤ v) (pabsℤ b) {p = λ x → p (abs-zero x)} {q = λ x → q (abs-zero x)} ((sym $ abs-distrib* {a = u} {b = b}) ∙ cong pabsℤ x ∙ abs-distrib* {a = v} {b = a}) i abs (trunc q q₁ x y i i₁) = trunc (abs q) (abs q₁) (cong abs x) (cong abs y) i i₁ infix 10 _~⟨_⟩_ -- The reason for all of the above machinery: data ℝ : Set data _~⟨_⟩_ : ℝ → (tol : ℚ) → ⦃ _ : tol > 0 ≡ true ⦄ → ℝ → Set data ℝ where rat : (q : ℚ) → ℝ lim : (x : ℚ → ℝ) → ((δ ε : ℚ) ⦃ _ : δ + ε > 0 ≡ true ⦄ → x δ ~⟨ δ + ε ⟩ x ε) → ℝ eq : (u v : ℝ) → ((ε : ℚ) ⦃ _ : ε > 0 ≡ true ⦄ → u ~⟨ ε ⟩ v) → u ≡ v data _~⟨_⟩_ where ~-rat-rat : ∀ {q r ε} ⦃ _ : ε > 0 ≡ true ⦄ → abs (q - r) < ε ≡ true → rat q ~⟨ ε ⟩ rat r ~-rat-lim : ∀ {q y l δ ε} ⦃ _ : ε - δ > 0 ≡ true ⦄ ⦃ _ : ε > 0 ≡ true ⦄ → rat q ~⟨ ε - δ ⟩ y δ → rat q ~⟨ ε ⟩ lim y l ~-lim-rat : ∀ {x l r δ ε} ⦃ _ : ε - δ > 0 ≡ true ⦄ ⦃ _ : ε > 0 ≡ true ⦄ → x δ ~⟨ ε - δ ⟩ rat r → lim x l ~⟨ ε ⟩ rat r ~-lim-lim : ∀ {x lₓ y ly ε δ η} ⦃ _ : ε > 0 ≡ true ⦄ ⦃ _ : ε - δ - η > 0 ≡ true ⦄ → x δ ~⟨ ε - δ - η ⟩ y η → lim x lₓ ~⟨ ε ⟩ lim y ly ~-isProp : ∀ {u v ε} ⦃ _ : ε > 0 ≡ true ⦄ → isProp (u ~⟨ ε ⟩ v)
{ "alphanum_fraction": 0.47503486, "avg_line_length": 41.8540965208, "ext": "agda", "hexsha": "96c61d901f3ee7b320be55b61f7c274f64508f65", "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": "34b42b3de1de3dba2e11a3ac5ea4e48982b06b2e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dylanede/cubical-experiments", "max_forks_repo_path": "scratch.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "34b42b3de1de3dba2e11a3ac5ea4e48982b06b2e", "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": "dylanede/cubical-experiments", "max_issues_repo_path": "scratch.agda", "max_line_length": 161, "max_stars_count": null, "max_stars_repo_head_hexsha": "34b42b3de1de3dba2e11a3ac5ea4e48982b06b2e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dylanede/cubical-experiments", "max_stars_repo_path": "scratch.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 18062, "size": 37292 }
data Bool : Set where true false : Bool data Nat : Set where zero : Nat suc : Nat → Nat one : Nat one = suc zero two : Nat two = suc one data Fin : Nat → Set where zero : ∀{n} → Fin (suc n) suc : ∀{n} (i : Fin n) → Fin (suc n) --This part works as expected: s : ∀ n → (f : (k : Fin n) → Bool) → Fin (suc n) s n f = zero t1 : Fin two t1 = s one (λ { zero → true ; (suc ()) }) -- But Agda is not able to infer the 1 in this case: ttwo : Fin two ttwo = s _ (λ { zero → true ; (suc ()) }) -- Warning: -- _142 : Nat -- The problem gets worse when i add arguments to the ttwo function. This gives an error: t3 : Set → Fin two t3 A = s _ (λ { zero → true ; (suc ()) })
{ "alphanum_fraction": 0.5655976676, "avg_line_length": 17.5897435897, "ext": "agda", "hexsha": "4a082d2dbccc4bea95793310b4383b7513713c74", "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/Issue1922.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/Issue1922.agda", "max_line_length": 89, "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/Issue1922.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": 246, "size": 686 }
{-# OPTIONS --rewriting #-} open import Reflection hiding (return; _>>=_) renaming (_≟_ to _≟r_) open import Data.List hiding (_++_) open import Data.Vec as V using (Vec; updateAt) open import Data.Unit open import Data.Nat as N open import Data.Nat.Properties open import Data.Fin using (Fin; #_; suc; zero) open import Data.Maybe hiding (_>>=_; map) open import Function open import Data.Bool open import Data.Product hiding (map) open import Data.String renaming (_++_ to _++s_; concat to sconc; length to slen) open import Data.Char renaming (_≈?_ to _c≈?_; show to showChar) open import Relation.Binary.PropositionalEquality hiding ([_]) open import Relation.Nullary open import Relation.Nullary.Decidable hiding (map) open import Data.Nat.Show renaming (show to showNat) open import Level renaming (zero to lzero; suc to lsuc) open import Category.Monad using (RawMonad) open RawMonad {{...}} public instance monadMB : ∀ {f} → RawMonad {f} Maybe monadMB = record { return = just ; _>>=_ = Data.Maybe._>>=_ } monadTC : ∀ {f} → RawMonad {f} TC monadTC = record { return = Reflection.return ; _>>=_ = Reflection._>>=_ } data Err {a} (A : Set a) : Set a where error : String → Err A ok : A → Err A instance monadErr : ∀ {f} → RawMonad {f} Err monadErr = record { return = ok ; _>>=_ = λ { (error s) f → error s ; (ok a) f → f a } } record RawMonoid {a}(A : Set a) : Set a where field _++_ : A → A → A ε : A ++/_ : List A → A ++/ [] = ε ++/ (x ∷ a) = x ++ ++/ a infixr 5 _++_ open RawMonoid {{...}} public instance monoidLst : ∀ {a}{A : Set a} → RawMonoid (List A) monoidLst {A = A} = record { _++_ = Data.List._++_; ε = [] } monoidErrLst : ∀{a}{A : Set a} → RawMonoid (Err $ List A) monoidErrLst = record { _++_ = λ where (error s) _ → error s _ (error s) → error s (ok s₁) (ok s₂) → ok (s₁ ++ s₂) ; ε = ok [] } defToTerm : Name → Definition → List (Arg Term) → Term defToTerm _ (function cs) as = pat-lam cs as defToTerm _ (constructor′ d) as = con d as defToTerm _ _ _ = unknown derefImmediate : Term → TC Term derefImmediate (def f args) = getDefinition f >>= λ f' → return (defToTerm f f' args) derefImmediate x = return x derefT : Term → TC Term derefT (def f args) = getType f derefT (con f args) = getType f derefT x = return x Ctx = List $ Arg Type drop-ctx' : Ctx → ℕ → Ctx drop-ctx' l zero = l drop-ctx' [] (suc n) = [] drop-ctx' (x ∷ l) (suc n) = drop-ctx' l n take-ctx' : Ctx → ℕ → Ctx take-ctx' [] zero = [] take-ctx' [] (suc p) = [] --error "take-ctx: ctx too short for the prefix" take-ctx' (x ∷ l) zero = [] take-ctx' (x ∷ l) (suc p) = x ∷ take-ctx' l p -- FIXME we probably want to error out on these two functions. pi-to-ctx : Term → Ctx pi-to-ctx (Π[ s ∶ a ] x) = (a ∷ pi-to-ctx x) pi-to-ctx _ = [] ctx-to-pi : List (Arg Type) → Type ctx-to-pi [] = def (quote ⊤) [] ctx-to-pi (a ∷ t) = Π[ "_" ∶ a ] ctx-to-pi t ty-con-args : Arg Type → List $ Arg Type ty-con-args (arg _ (con c args)) = args ty-con-args (arg _ (def c args)) = args ty-con-args _ = [] con-to-ctx : Term → Term × Ctx con-to-ctx (Π[ s ∶ a ] x) = let t , args = con-to-ctx x in t , a ∷ args con-to-ctx x = x , [] record Eq : Set where constructor _↦_ field left : Term right : Term Eqs = List Eq eqs-shift-vars : Eqs → ℕ → Eqs mbeqs-eqs : Maybe Eqs → Eqs mbeqs-eqs (just x) = x mbeqs-eqs nothing = [] -- stupid name, this generates equalities for two terms being somewhat similar. unify-eq : Term → Term → Eqs unify-eq-map : List $ Arg Term → List $ Arg Term → Maybe Eqs unify-eq (var x []) y = [ var x [] ↦ y ] unify-eq (var x args@(_ ∷ _)) t₂ = {!!} unify-eq (con c args) (con c′ args′) with c ≟-Name c′ ... | yes p = mbeqs-eqs $ unify-eq-map args args′ ... | no ¬p = [] unify-eq (def f args) (def f′ args′) with f ≟-Name f′ -- Generally speaking this is a lie of course, as -- not all the definitons are injective. However, -- we mainly use these for types such as Vec, Nat, etc -- and for these cases it is fine. How do I check whether -- the definition is a data type or not? ... | yes p = mbeqs-eqs $ unify-eq-map args args′ ... | no ¬p = [] unify-eq (lam v t) t₂ = {!!} unify-eq (pat-lam cs args) t₂ = {!!} unify-eq (pi a b) t₂ = {!!} unify-eq (sort s) t₂ = {!!} unify-eq (lit l) y = [ lit l ↦ y ] unify-eq (meta x x₁) t₂ = {!!} unify-eq unknown t₂ = {!!} unify-eq x (var y []) = [ x ↦ var y [] ] unify-eq x (var y args@(_ ∷ _)) = {!!} --[ x ↦ var y [] ] unify-eq a b = [] test-unify₁ = unify-eq (var 0 []) (con (quote ℕ.suc) [ vArg $ con (quote ℕ.zero) [] ] ) test-unify₂ = unify-eq (con (quote ℕ.suc) [ vArg $ con (quote ℕ.zero) [] ] ) (var 0 []) unify-eq-map [] [] = just [] unify-eq-map [] (y ∷ _) = nothing unify-eq-map (x ∷ _) [] = nothing unify-eq-map (arg _ x ∷ xs) (arg _ y ∷ ys) = do eqs ← unify-eq-map xs ys return $ unify-eq x y ++ eqs eq-find-l : Eqs → Term → Term eq-find-l [] t = t eq-find-l (l ↦ r ∷ eqs) t with l ≟r t ... | yes l≡t = r ... | no l≢t = eq-find-l eqs t decvar : Term → (min off : ℕ) → Err Term decvar-map : List $ Arg Term → (min off : ℕ) → Err $ List $ Arg Term decvar (var x args) m o with x ≥? m decvar (var x args) m o | yes x≥m with x ≥? o decvar (var x args) m o | yes x≥m | yes x≥o = do args ← decvar-map args m o return $ var (x ∸ o) args decvar (var x args) m o | yes x≥m | no x≱o = error "decvar: variable index is less than decrement" decvar (var x args) m o | no x≱m = do args ← decvar-map args m o return $ var x args decvar (con c args) m o = do args ← decvar-map args m o return $ con c args decvar (def f args) m o = do args ← decvar-map args m o return $ def f args decvar (lam v t) m o = {!!} decvar (pat-lam cs args) m o = {!!} decvar (Π[ s ∶ arg i a ] x) m o = do a ← decvar a m o x ← decvar x (1 + m) o return $ Π[ s ∶ arg i a ] x decvar (sort (set t)) m o = do t ← decvar t m o return $ sort $ set t decvar (sort (lit n)) m o = return $ sort $ lit n decvar (sort unknown) m o = return $ sort $ unknown decvar (lit l) m o = return $ lit l decvar (meta x args) m o = do args ← decvar-map args m o return $ meta x args decvar unknown m o = return unknown decvar-map [] m o = ok [] decvar-map (arg i x ∷ l) m o = do x ← decvar x m o l ← decvar-map l m o return $ (arg i x) ∷ l -- Note that we throw away the equality in case it didn't decvar'd correctly. decvar-eqs : Eqs → (min off : ℕ) → Eqs decvar-eqs [] m o = [] decvar-eqs (x ↦ y ∷ eqs) m o with (decvar x m o) | (decvar y m o) decvar-eqs (x ↦ y ∷ eqs) m o | ok x′ | ok y′ = x′ ↦ y′ ∷ decvar-eqs eqs m o decvar-eqs (x ↦ y ∷ eqs) m o | _ | _ = decvar-eqs eqs m o check-var-pred : Term → (p : ℕ → Bool) → (min : ℕ) → Bool check-var-pred-map : List $ Arg Term → (p : ℕ → Bool) (min : ℕ) → Bool check-var-pred (var x args) p m with x ≥? m check-var-pred (var x args) p m | yes x≥m with p x check-var-pred (var x args) p m | yes x≥m | true = true check-var-pred (var x args) p m | yes x≥m | false = check-var-pred-map args p m check-var-pred (var x args) p m | no x≱m = check-var-pred-map args p m check-var-pred (con c args) p m = check-var-pred-map args p m check-var-pred (def f args) p m = check-var-pred-map args p m check-var-pred (lam v t) p m = {!!} check-var-pred (pat-lam cs args) p m = {!!} check-var-pred (Π[ s ∶ (arg i a) ] x) p m with check-var-pred a p m ... | true = true ... | false = check-var-pred x p (1 + m) check-var-pred (sort (set t)) p m = check-var-pred t p m check-var-pred (sort (lit n)) p m = false check-var-pred (sort unknown) p m = false check-var-pred (lit l) p m = false check-var-pred (meta x args) p m = check-var-pred-map args p m check-var-pred unknown p m = false check-var-pred-map [] p m = false check-var-pred-map (arg _ x ∷ l) p m with check-var-pred x p m ... | true = true ... | false = check-var-pred-map l p m -- eliminate equalities where we reverence variables that are greaterh than n eqs-elim-vars-ge-l : Eqs → (n : ℕ) → Eqs eqs-elim-vars-ge-l [] n = [] eqs-elim-vars-ge-l (l ↦ r ∷ eqs) n with check-var-pred l (isYes ∘ (_≥? n)) 0 ... | true = eqs-elim-vars-ge-l eqs n ... | false = (l ↦ r) ∷ eqs-elim-vars-ge-l eqs n subst-eq-var : Eqs → Type → (min : ℕ) → Type subst-eq-var-map : Eqs → List $ Arg Type → (min : ℕ) → List $ Arg Type -- Iterate over a reversed telescopic context and try to subsitute variables -- from eqs, if we have some. subst-eq-vars : Eqs → List $ Arg Type → List $ Arg Type subst-eq-vars eqs [] = [] subst-eq-vars eqs ((arg i ty) ∷ tys) = let eqs = decvar-eqs eqs 0 1 in (arg i $ subst-eq-var eqs ty 0) ∷ subst-eq-vars eqs tys subst-eq-var eqs t@(var x []) m with x ≥? m ... | yes p = eq-find-l eqs t ... | no ¬p = t subst-eq-var eqs (var x (x₁ ∷ args)) m = {!!} subst-eq-var eqs (con c args) m = con c $ subst-eq-var-map eqs args m subst-eq-var eqs (def f args) m = def f $ subst-eq-var-map eqs args m subst-eq-var eqs (lam v t) m = {!!} subst-eq-var eqs (pat-lam cs args) m = {!!} subst-eq-var eqs (Π[ s ∶ (arg i a) ] x) m = Π[ s ∶ (arg i $ subst-eq-var eqs a m) ] -- We need to increase all the variables in -- eqs berfore entering x. subst-eq-var (eqs-shift-vars eqs 1) x (1 + m) subst-eq-var eqs (sort s) m = {!!} subst-eq-var eqs (lit l) m = lit l subst-eq-var eqs (meta x x₁) m = {!!} subst-eq-var eqs unknown m = unknown subst-eq-var-map eqs [] m = [] subst-eq-var-map eqs (arg i x ∷ l) m = arg i (subst-eq-var eqs x m) ∷ subst-eq-var-map eqs l m -- shift all the variables by n shift-vars : Type → (min off : ℕ) → Type shift-vars-map : List $ Arg Type → ℕ → ℕ → List $ Arg Type shift-vars (var x args) m o with x ≥? m ... | yes p = var (o + x) (shift-vars-map args m o) ... | no ¬p = var x (shift-vars-map args m o) shift-vars (con c args) m o = con c $ shift-vars-map args m o shift-vars (def f args) m o = def f $ shift-vars-map args m o shift-vars (lam v (abs s x)) m o = lam v $ abs s $ shift-vars x (1 + m) o shift-vars (pat-lam cs args) m o = {!!} shift-vars (Π[ s ∶ arg i a ] x) m o = Π[ s ∶ arg i (shift-vars a m o) ] shift-vars x (1 + m) o shift-vars (sort (set t)) m o = sort $ set $ shift-vars t m o shift-vars (sort (lit n)) m o = sort $ lit n shift-vars (sort unknown) m o = sort unknown shift-vars (lit l) m o = lit l shift-vars (meta x args) m o = meta x $ shift-vars-map args m o shift-vars unknown m o = unknown shift-vars-map [] m o = [] shift-vars-map (arg i x ∷ l) m o = arg i (shift-vars x m o) ∷ shift-vars-map l m o eqs-shift-vars [] n = [] eqs-shift-vars (l ↦ r ∷ eqs) n = let l′ = shift-vars l 0 n r′ = shift-vars r 0 n in l′ ↦ r′ ∷ eqs-shift-vars eqs n trans-eqs : Eqs → Eq → Eqs trans-eqs [] (l ↦ r) = [] trans-eqs ((l′ ↦ r′) ∷ eqs) eq@(l ↦ r) with l′ ≟r l ... | yes l′≡l = unify-eq r′ r ++ trans-eqs eqs eq ... | no _ with l′ ≟r r ... | yes l′≡r = unify-eq r′ l ++ trans-eqs eqs eq ... | no _ with r′ ≟r l ... | yes r′≡l = unify-eq l′ r ++ trans-eqs eqs eq ... | no _ with r′ ≟r r ... | yes r′≡r = unify-eq l′ l ++ trans-eqs eqs eq ... | no _ = trans-eqs eqs eq merge-eqs : (l r : Eqs) → (acc : Eqs) → Eqs merge-eqs l [] acc = l ++ acc merge-eqs l (x ∷ r) acc = merge-eqs l r (x ∷ acc ++ trans-eqs l x) TyPat = Arg Type × Arg Pattern merge-tys-pats : List $ Arg Type → List $ Arg Pattern → Err $ List TyPat merge-tys-pats [] [] = ok [] merge-tys-pats [] (x ∷ ps) = error "merge-tys-pats: more patterns than types" merge-tys-pats (x ∷ tys) [] = error "merge-tys-pats: more types than patterns" merge-tys-pats (ty ∷ tys) (p ∷ ps) = ok [ ty , p ] ++ merge-tys-pats tys ps shift-ty-vars-map : List TyPat → (min off : ℕ) → List TyPat shift-ty-vars-map [] m o = [] shift-ty-vars-map ((arg i ty , p) ∷ l) m o = (arg i (shift-vars ty m o) , p) ∷ shift-ty-vars-map l m o subst-typats : List TyPat → (min var : ℕ) → Type → List TyPat subst-typats [] m v x = [] subst-typats ((arg tv ty , p) ∷ l) m v x = let ty′ = subst-eq-var [ (var v []) ↦ x ] ty m in (arg tv ty′ , p) ∷ subst-typats l (1 + m) (1 + v) (shift-vars x 0 1) gen-n-vars : (count v : ℕ) → List $ Arg Term gen-n-vars 0 _ = [] gen-n-vars (suc n) v = vArg (var v []) ∷ gen-n-vars n (1 + v) {-# TERMINATING #-} pats-ctx-open-cons : List TyPat → Eqs → TC $ Eqs × (Err $ List TyPat) pats-ctx-open-cons [] eqs = return $ eqs , ok [] pats-ctx-open-cons ((arg tv ty , arg pv (con c ps)) ∷ l) eqs = do con-type ← getType c let con-ret , con-ctx = con-to-ctx con-type -- bump indices in x by the length of ps let #ps = length ps let ty = shift-vars ty 0 #ps let con-eqs = unify-eq con-ret ty --let con-eqs = mbeqs-eqs $ unify-eq-map con-type-args ty-args let ctx = subst-eq-vars con-eqs (take-ctx' (reverse con-ctx) #ps) case #ps N.≟ 0 of λ where (no #ps≢0) → do -- Throw away substitutions that point further than the number -- of arguments to the constructor let con-eqs′ = eqs-elim-vars-ge-l con-eqs #ps let eqs′ = eqs-shift-vars eqs #ps let ctxl = merge-tys-pats (reverse ctx) ps -- substitute constructor into the rest of the context let l′ = subst-typats l 0 0 (con c $ gen-n-vars #ps 0) -- We eliminated 0 variable, so bump all the variables greater than 0 let l′ = shift-ty-vars-map l′ 1 (#ps ∸ 1) eqs″ , ctxr ← pats-ctx-open-cons l′ (merge-eqs eqs′ con-eqs′ []) return $ eqs″ , ctxl ++ ctxr (yes ps≡0) → do let con-eqs′ = eqs-elim-vars-ge-l con-eqs 0 -- shift con-eqs′ by 1 to account for the newly inserted Dot. let con-eqs′ = eqs-shift-vars con-eqs′ 1 -- Add equality of the newly inserted Dot and shift eqs by 1 --let eqs′ = (var 0 [] ≜ con c []) ∷ eqs-shift-vars eqs 1 let eqs′ = eqs-shift-vars eqs 1 -- substitute constructor into the rest of the context let l′ = subst-typats l 0 0 (con c []) eqs″ , ctxr ← pats-ctx-open-cons l′ (merge-eqs eqs′ con-eqs′ []) return $ eqs″ , ok [ arg tv ty , arg pv dot ] ++ ctxr pats-ctx-open-cons ((ty , arg i dot) ∷ l) eqs = do -- leave the dot and psas the equations further let eqs′ = eqs-shift-vars eqs 1 eqs″ , ctx ← pats-ctx-open-cons l eqs′ return $ eqs″ , ok [ ty , arg i dot ] ++ ctx pats-ctx-open-cons ((ty , arg i (var s)) ∷ l) eqs = do -- pass the equations further and leave the variable as is let eqs′ = eqs-shift-vars eqs 1 eqs″ , ctx ← pats-ctx-open-cons l eqs′ return $ eqs″ , ok [ ty , arg i (var s) ] ++ ctx pats-ctx-open-cons ((ty , arg i (lit x)) ∷ l) eqs = do -- we don't get any new equations from the literal so -- pass the equations further and insert the dot let eqs′ = eqs-shift-vars eqs 1 let l′ = subst-typats l 0 0 (lit x) eqs″ , ctx ← pats-ctx-open-cons l′ eqs′ return $ eqs″ , ok [ ty , arg i dot ] ++ ctx pats-ctx-open-cons ((ty , arg i (proj f)) ∷ l) eqs = return $ eqs , error "pats-ctx-open-cons: projection found, fixme" pats-ctx-open-cons ((ty , arg i absurd) ∷ l) eqs = return $ eqs , error "pats-ctx-open-cons: absurd pattern found, fixme" -- Check whether the varibale (var 0) can be found in the tyspats -- telescopic context. check-ref : List TyPat → (v : ℕ) → Bool check-ref [] v = false check-ref ((arg _ ty , _) ∷ l) v with check-var-pred ty (isYes ∘ (N._≟ v)) 0 ... | true = true ... | false = check-ref l (1 + v) -- XXX we are going to ignore the errors from the decvar, as we assume that -- (var 0) is not referenced in the telescopic pattern. dec-typats : List TyPat → (min : ℕ) → List TyPat dec-typats [] m = [] dec-typats ((arg ti ty , p) ∷ l) m with decvar ty m 1 ... | ok ty′ = (arg ti ty′ , p) ∷ dec-typats l (1 + m) ... | error _ = (arg ti ty , p) ∷ dec-typats l (1 + m) -- Try to eliminate dots if there is no references in the rhs to this variable {-# TERMINATING #-} -- XXX this can be resolved, this function IS terminating try-elim-dots : List TyPat → List TyPat try-elim-dots [] = [] try-elim-dots ((ty , arg i dot) ∷ tyspats) with check-ref tyspats 0 ... | true = (ty , arg i dot) ∷ try-elim-dots tyspats ... | false = try-elim-dots (dec-typats tyspats 1) try-elim-dots ((ty , p) ∷ tyspats) = (ty , p) ∷ try-elim-dots tyspats -- Look at the ctx list in *reverse* and get the list of variables that -- correspond to dot patterns get-dots : List TyPat → ℕ → List ℕ get-dots [] o = [] get-dots ((_ , arg _ dot) ∷ l) o = o ∷ get-dots l (1 + o) get-dots (_ ∷ l) o = get-dots l (1 + o) -- Check if a given term contains any variable from the list check-refs : Term → List ℕ → Bool check-refs t [] = false check-refs t (v ∷ vs) with check-var-pred t (isYes ∘ (N._≟ v)) 0 ... | true = true ... | false = check-refs t vs -- Eliminate the rhs of each eq in case it references dot patterns. eqs-elim-nondots : Eqs → List ℕ → Eqs eqs-elim-nondots [] _ = [] eqs-elim-nondots (eq@(_ ↦ r) ∷ eqs) vs with check-refs r vs ... | true = eqs-elim-nondots eqs vs ... | false = eq ∷ eqs-elim-nondots eqs vs -- Substitute the variables from eqs into the *reversed* telescopic -- context. subst-eq-typats : Eqs → List TyPat → List TyPat subst-eq-typats eqs [] = [] subst-eq-typats [] l = l subst-eq-typats eqs ((arg ti ty , p) ∷ typats) = let eqs = decvar-eqs eqs 0 1 in (arg ti (subst-eq-var eqs ty 0) , p) ∷ subst-eq-typats eqs typats check-no-dots : List TyPat → Bool check-no-dots [] = true check-no-dots ((_ , arg _ dot) ∷ l) = false check-no-dots (_ ∷ l) = check-no-dots l check-all-vars : List TyPat → Bool check-all-vars [] = true check-all-vars ((_ , arg _ (var _)) ∷ l) = check-all-vars l check-all-vars (_ ∷ l) = false check-conlit : List TyPat → Bool check-conlit [] = false check-conlit ((_ , arg _ (con _ _)) ∷ l) = true check-conlit ((_ , arg _ (lit _)) ∷ l) = true check-conlit (_ ∷ l) = check-conlit l {-# TERMINATING #-} compute-ctx : List TyPat → TC $ Err $ List TyPat compute-ctx typats with check-no-dots typats ∧ check-all-vars typats ... | true = return $ ok typats ... | false with check-conlit typats ... | true = do eqs , typats ← pats-ctx-open-cons typats [] case typats of λ where (error s) → return $ error s (ok t) → let sub = eqs-elim-nondots (eqs ++ map (λ { (l ↦ r) → r ↦ l}) eqs) (get-dots (reverse t) 0) t = subst-eq-typats sub (reverse t) t = try-elim-dots (reverse t) in compute-ctx t ... | false = return $ error "compute-ctx: can't eliminate dots in the context" -- try normalising every clause of the pat-lam, given -- the context passed as an argument. Propagate error that -- can be produced by pats-ctx. pat-lam-norm : Term → Ctx → TC $ Err Term pat-lam-norm (pat-lam cs args) ctx = do cs ← hlpr ctx cs case cs of λ where (ok cs) → return $ ok (pat-lam cs args) (error s) → return $ error s --return $ ok (pat-lam cs args) where hlpr : Ctx → List Clause → TC $ Err (List Clause) hlpr ctx [] = return $ ok [] hlpr ctx (clause ps t ∷ l) = do case merge-tys-pats ctx ps of λ where (error s) → return $ error s (ok typats) → do typats ← compute-ctx typats case typats of λ where (ok typats) → do let ctx′ = map proj₁ typats t ← inContext (reverse ctx′) (normalise t) l ← hlpr ctx l return $ ok [ clause ps t ] ++ l (error s) → --return $ clause ps t ∷ l -- Make sure that we properly error out -- Uncomment above line, in case you want to skip the error. return $ error s hlpr ctx (a ∷ l) = do l' ← hlpr ctx l return (ok [ a ] ++ l') --return (a ∷ l') pat-lam-norm x ctx = return $ error "pat-lam-norm: Shouldn't happen" --return $ ok x macro reflect : Term → Term → TC ⊤ reflect f a = -- not sure I need this --withNormalisation true normalise f >>= (derefImmediate) >>= quoteTC >>= unify a reflect-ty : Name → Type → TC ⊤ reflect-ty f a = getType f >>= quoteTC >>= normalise >>= unify a tstctx : Name → Type → TC ⊤ tstctx f a = do t ← getType f q ← quoteTC (con-to-ctx t) unify a q rtest : Term → Term → TC ⊤ rtest f a = do t ← derefT f v ← derefImmediate f v ← pat-lam-norm v (pi-to-ctx t) q ← quoteTC v --q ← quoteTC (con-to-ctx t) unify a q norm-test : Term → Term → TC ⊤ norm-test tm a = do t ← derefT tm v ← derefImmediate tm --let vec-and'-pat-[] = (hArg dot ∷ vArg (con (quote nil) []) ∷ vArg (var "_") ∷ []) {- let add-2v-pat = (hArg (var "_") ∷ vArg (con (quote imap) (hArg dot ∷ vArg (var "a") ∷ [])) ∷ vArg (con (quote imap) (hArg dot ∷ vArg (var "b") ∷ [])) ∷ []) -} {- let vec-sum-pat = (hArg dot ∷ vArg (con (quote V._∷_) (hArg (var "_") ∷ vArg (var "x") ∷ vArg (var "a") ∷ [])) ∷ vArg (con (quote V._∷_) (hArg dot ∷ vArg (var "y") ∷ vArg (var "b") ∷ [])) ∷ []) -} let vec-sum-pat-[] = (hArg dot ∷ vArg (con (quote V.[]) []) ∷ vArg (var "_") ∷ []) {- let ty-args = args-to-ctx vec-args 0 t ← getType (quote V._∷_) let t = subst-args 2 (reverse $ take-ctx' ty-args 2) 0 t -} let ctx = pi-to-ctx t case merge-tys-pats ctx vec-sum-pat-[] of λ where (error s) → unify a (lit (string s)) (ok typats) → do eqs , t ← pats-ctx-open-cons typats [] --let t = ok typats case t of λ where (error s) → unify a (lit (string s)) (ok t) → do -- let sub = eqs-elim-nondots (eqs ++ map (λ { (l ≜ r) → r ≜ l}) eqs) (get-dots (reverse t) 0) -- let t = subst-eq-typats sub (reverse t) -- let t = try-elim-dots (reverse t) q ← quoteTC t unify a q --t ← inferType v -- (vArg n ∷ [ vArg lz ])) --let v = plug-new-args v (vArg n ∷ [ vArg lz ]) --t ← inContext (reverse $ hArg lz ∷ [ hArg n ]) (normalise v) --t ← reduce t --t ← getType t --t ← inContext [] (normalise t) --q ← quoteTC (pi-to-ctx t) infert : Type → Term → TC ⊤ infert t a = inferType t >>= quoteTC >>= unify a -- {- open import Data.Vec vec-and : ∀ {n} → Vec Bool n → Vec Bool n → Vec Bool n vec-and (x ∷ a) (y ∷ b) = x ∧ y ∷ vec-and a b vec-and [] _ = [] -- explicit length vec-and-nd : ∀ {n} → Vec Bool n → Vec Bool n → Vec Bool n vec-and-nd {0} [] _ = [] vec-and-nd {suc n} (_∷_ {n = n} x a) (_∷_ {n = n} y b) = x ∧ y ∷ vec-and-nd a b data Vec' {l : Level} (A : Set l) : ℕ → Set l where nil : Vec' A 0 cons : A → {n : ℕ} → Vec' A n → Vec' A (1 + n) vec-and' : ∀ {n} → Vec' Bool n → Vec' Bool n → Vec' Bool n vec-and' nil _ = nil vec-and' (cons x a) (cons y b) = cons (x ∧ y) (vec-and' a b) {-# BUILTIN REWRITE _≡_ #-} {-# REWRITE +-identityʳ #-} a = 1 + 0 xx : ℕ → Bool → ℕ → ℕ xx x true y = let a = x * x in a + y xx x false y = x + 2 + 0 postulate rev-rev : ∀ {a}{X : Set a}{n}{xs : Vec X n} → let rev = V.foldl (Vec X) (λ rev x → x ∷ rev) [] in rev (rev xs) ≡ xs {-# REWRITE rev-rev #-} test-reverse : ∀ {a}{X : Set a}{n} → X → Vec X n → Vec X (suc n) test-reverse x xs = x ∷ V.reverse (V.reverse xs) test-rev-pat : ∀ {a}{X : Set a}{n} → X → Vec X n → Vec X (suc n) test-rev-pat x [] = x ∷ [] test-rev-pat x xs = x ∷ V.reverse (V.reverse xs) open import Array add-2v : ∀ {n} → let X = Ar ℕ 1 (n ∷ []) in X → X → X add-2v (imap a) (imap b) = imap λ iv → a iv + b iv postulate asum : ∀ {n} → Ar ℕ 1 (n ∷ []) → ℕ mm : ∀ {m n k} → let Mat a b = Ar ℕ 2 (a ∷ b ∷ []) in Mat m n → Mat n k → Mat m k mm (imap a) (imap b) = imap λ iv → let i = ix-lookup iv (# 0) j = ix-lookup iv (# 1) in asum (imap λ kv → let k = ix-lookup kv (# 0) in a (i ∷ k ∷ []) * b (k ∷ j ∷ [])) data P (x : ℕ) : Set where c : P x data TT : ℕ → Set where tc : ∀ {n} → P (suc n) → TT (suc n) foo : ∀ {n} → TT (suc n) → ℕ foo (tc x) = 5 xxx = 3 N.< 5
{ "alphanum_fraction": 0.5664654429, "avg_line_length": 33.5875862069, "ext": "agda", "hexsha": "9f14c960f38323acbb8617b46afe71ee44d3c3cd", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-10-12T07:19:48.000Z", "max_forks_repo_forks_event_min_datetime": "2020-10-12T07:19:48.000Z", "max_forks_repo_head_hexsha": "584fedb30552f820c0668cedae53ec3d926860b5", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "ashinkarov/agda-array", "max_forks_repo_path": "Renormalise.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "584fedb30552f820c0668cedae53ec3d926860b5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "ashinkarov/agda-array", "max_issues_repo_path": "Renormalise.agda", "max_line_length": 108, "max_stars_count": 6, "max_stars_repo_head_hexsha": "584fedb30552f820c0668cedae53ec3d926860b5", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "ashinkarov/agda-array", "max_stars_repo_path": "Renormalise.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-15T14:21:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-09T13:53:46.000Z", "num_tokens": 8826, "size": 24351 }
open import Structure.Operator.Monoid open import Structure.Setoid open import Type module Numeral.Natural.Oper.Summation {ℓᵢ ℓ ℓₑ} {I : Type{ℓᵢ}} {T : Type{ℓ}} {_▫_ : T → T → T} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ ⦃ monoid : Monoid{T = T}(_▫_) ⦄ where open Monoid(monoid) import Lvl open import Data.List open import Data.List.Functions open import Structure.Function open import Structure.Operator ∑ : List(I) → (I → T) → T ∑(r) f = foldᵣ(_▫_) id (map f(r))
{ "alphanum_fraction": 0.6783369803, "avg_line_length": 28.5625, "ext": "agda", "hexsha": "826f07c688f7ab8cd76d58b389ed01d5ecdd906f", "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/Oper/Summation.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/Oper/Summation.agda", "max_line_length": 157, "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/Oper/Summation.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": 178, "size": 457 }
------------------------------------------------------------------------ -- Vectors, defined using a recursive function ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Vec {reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where open import Prelude open import Bijection eq using (_↔_) open Derived-definitions-and-properties eq open import Function-universe eq hiding (id; _∘_) open import List eq using (length) open import Surjection eq using (_↠_; ↠-≡) private variable a b c : Level A B : Type a f g : A → B n : ℕ ------------------------------------------------------------------------ -- The type -- Vectors. Vec : Type a → ℕ → Type a Vec A zero = ↑ _ ⊤ Vec A (suc n) = A × Vec A n ------------------------------------------------------------------------ -- Some simple functions -- Finds the element at the given position. index : Vec A n → Fin n → A index {n = suc _} (x , _) fzero = x index {n = suc _} (_ , xs) (fsuc i) = index xs i -- Updates the element at the given position. infix 3 _[_≔_] _[_≔_] : Vec A n → Fin n → A → Vec A n _[_≔_] {n = zero} _ () _ _[_≔_] {n = suc _} (x , xs) fzero y = y , xs _[_≔_] {n = suc _} (x , xs) (fsuc i) y = x , (xs [ i ≔ y ]) -- Applies the function to every element in the vector. map : (A → B) → Vec A n → Vec B n map {n = zero} f _ = _ map {n = suc _} f (x , xs) = f x , map f xs -- Constructs a vector containing a certain number of copies of the -- given element. replicate : A → Vec A n replicate {n = zero} _ = _ replicate {n = suc _} x = x , replicate x -- The head of the vector. head : Vec A (suc n) → A head = proj₁ -- The tail of the vector. tail : Vec A (suc n) → Vec A n tail = proj₂ ------------------------------------------------------------------------ -- Conversions to and from lists -- Vectors can be converted to lists. to-list : Vec A n → List A to-list {n = zero} _ = [] to-list {n = suc n} (x , xs) = x ∷ to-list xs -- Lists can be converted to vectors. from-list : (xs : List A) → Vec A (length xs) from-list [] = _ from-list (x ∷ xs) = x , from-list xs -- ∃ (Vec A) is isomorphic to List A. ∃Vec↔List : ∃ (Vec A) ↔ List A ∃Vec↔List {A = A} = record { surjection = record { logical-equivalence = record { to = to-list ∘ proj₂ ; from = λ xs → length xs , from-list xs } ; right-inverse-of = to∘from } ; left-inverse-of = uncurry from∘to } where to∘from : (xs : List A) → to-list (from-list xs) ≡ xs to∘from [] = refl _ to∘from (x ∷ xs) = cong (x ∷_) (to∘from xs) tail′ : A → ∃ (Vec A) ↠ ∃ (Vec A) tail′ y = record { logical-equivalence = record { to = λ where (suc n , _ , xs) → n , xs xs@(zero , _) → xs ; from = Σ-map suc (y ,_) } ; right-inverse-of = refl } from∘to : ∀ n (xs : Vec A n) → (length (to-list xs) , from-list (to-list xs)) ≡ (n , xs) from∘to zero _ = refl _ from∘to (suc n) (x , xs) = $⟨ from∘to n xs ⟩ (length (to-list xs) , from-list (to-list xs)) ≡ (n , xs) ↝⟨ _↠_.from $ ↠-≡ (tail′ x) ⟩□ (length (to-list (x , xs)) , from-list (to-list (x , xs))) ≡ (suc n , x , xs) □ ------------------------------------------------------------------------ -- Some properties -- The map function satisfies the functor laws. map-id : {A : Type a} {xs : Vec A n} → map id xs ≡ xs map-id {n = zero} = refl _ map-id {n = suc n} = cong (_ ,_) map-id map-∘ : {A : Type a} {B : Type b} {C : Type c} {f : B → C} {g : A → B} {xs : Vec A n} → map (f ∘ g) xs ≡ map f (map g xs) map-∘ {n = zero} = refl _ map-∘ {n = suc n} = cong (_ ,_) map-∘ -- If f and g are pointwise equal, then map f xs and map g xs are -- equal. map-cong : ∀ {n} {xs : Vec A n} → (∀ x → f x ≡ g x) → map f xs ≡ map g xs map-cong {n = zero} _ = refl _ map-cong {n = suc n} hyp = cong₂ _,_ (hyp _) (map-cong hyp)
{ "alphanum_fraction": 0.4735693501, "avg_line_length": 26.1012658228, "ext": "agda", "hexsha": "269773762b5ec3208f2252e16b0ec6dc574205c5", "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/Vec.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/Vec.agda", "max_line_length": 94, "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/Vec.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": 1355, "size": 4124 }
open import Signature import Program module Observations (Σ : Sig) (V : Set) (P : Program.Program Σ V) where open import Terms Σ open import Program Σ V open import Rewrite Σ V P open import Function open import Relation.Nullary open import Relation.Unary open import Data.Product as Prod renaming (Σ to ⨿) open import Streams hiding (_↓_) -- | We will need _properly refining_ substitutions: σ properly refines t ∈ T V, -- if ∀ v ∈ fv(t). σ(v) = f(α) for f ∈ Σ. -- Then an observation step must go along a properly refining substitution, -- which in turn allows us to construct a converging sequence of terms. {- | We can make an observation according to the following rule. t ↓ s fv(s) ≠ ∅ ∃ k, σ. s ~[σ]~ Pₕ(k) -------------------------------------------- t ----> t[σ] -} data _↦_ (t : T V) : T V → Set where obs-step : {s : T V} → t ↓ s → -- ¬ Empty (fv s) → (cl : dom P) {σ : Subst V V} → ProperlyRefining t σ → mgu s (geth P cl) σ → t ↦ app σ t reduct : ∀{t s} → t ↦ s → T V reduct (obs-step {s} _ _ _ _ ) = s refining : ∀{t s} → t ↦ s → Subst V V refining (obs-step _ _ {σ} _ _) = σ is-refining : ∀{t s} (o : t ↦ s) → ProperlyRefining t (refining o) is-refining (obs-step _ _ r _) = r GroundTerm : Pred (T V) _ GroundTerm t = Empty (fv t) -------- -- FLAW: This does not allow us to distinguish between inductive -- and coinductive definitions on the clause level. -- The following definitions are _global_ for a derivation! ------- data IndDerivable (t : T V) : Set where ground : GroundTerm t → Valid t → IndDerivable t der-step : (s : T V) → t ↦ s → IndDerivable s → IndDerivable t record CoindDerivable (t : T V) : Set where coinductive field term-SN : SN t der-obs : ⨿ (T V) λ s → t ↦ s × CoindDerivable s open CoindDerivable public obs-result : ∀{t} → CoindDerivable t → T V obs-result = proj₁ ∘ der-obs get-obs : ∀{t} (d : CoindDerivable t) → t ↦ (obs-result d) get-obs = proj₁ ∘ proj₂ ∘ der-obs -- | This should give us convergence to a term in T∞ V, see Terms.agda coind-deriv-seq : (t : T V) → CoindDerivable t → ProperlyRefiningSeq t hd-ref (coind-deriv-seq t d) = refining (get-obs d) hd-is-ref (coind-deriv-seq t d) = is-refining (get-obs d) tl-ref (coind-deriv-seq t d) with (der-obs d) tl-ref (coind-deriv-seq t d) | ._ , obs-step red cl {σ} ref _ , d' = coind-deriv-seq (app σ t) d'
{ "alphanum_fraction": 0.6227594831, "avg_line_length": 31.9866666667, "ext": "agda", "hexsha": "095f29c47d32664ee592374d6de797ee3b7d2299", "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": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "LP/Observations.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "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": "hbasold/Sandbox", "max_issues_repo_path": "LP/Observations.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "LP/Observations.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 810, "size": 2399 }
module ImportWarnings where open import ImportWarningsB -- A warning in the top-level file {-# REWRITE #-} -- make sure that this file is long enough to detect if we inherit -- also the warning highlighting foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo : Set1 foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo = Set
{ "alphanum_fraction": 0.9845832245, "avg_line_length": 318.9166666667, "ext": "agda", "hexsha": "c68c20a62d1cf8febe61d262adf300ec1ec30e07", "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/ImportWarnings.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/ImportWarnings.agda", "max_line_length": 1808, "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/ImportWarnings.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": 506, "size": 3827 }
open import Type open import Structure.Setoid module Structure.Operator.Lattice {ℓ ℓₑ} (L : Type{ℓ}) ⦃ equiv-L : Equiv{ℓₑ}(L) ⦄ where import Lvl open import Functional import Function.Names as Names open import Logic open import Logic.IntroInstances open import Logic.Propositional open import Logic.Predicate open import Structure.Function.Domain using (Involution ; involution) open import Structure.Function.Multi open import Structure.Function open import Structure.Operator.Monoid open import Structure.Operator.Properties open import Structure.Operator.Proofs open import Structure.Operator open import Structure.Relator.Ordering open import Structure.Relator.Properties open import Syntax.Transitivity record Semilattice (_▫_ : L → L → L) : Stmt{ℓ Lvl.⊔ ℓₑ} where constructor intro field ⦃ operator ⦄ : BinaryOperator(_▫_) ⦃ commutative ⦄ : Commutativity(_▫_) ⦃ associative ⦄ : Associativity(_▫_) ⦃ idempotent ⦄ : Idempotence(_▫_) order : L → L → Stmt order x y = (x ▫ y ≡ y) partialOrder : Weak.PartialOrder(order)(_≡_) Antisymmetry.proof (Weak.PartialOrder.antisymmetry partialOrder) {x}{y} xy yx = x 🝖-[ symmetry(_≡_) yx ] y ▫ x 🝖-[ commutativity(_▫_) ] x ▫ y 🝖-[ xy ] y 🝖-end Transitivity.proof (Weak.PartialOrder.transitivity partialOrder) {x}{y}{z} xy yz = x ▫ z 🝖-[ congruence₂ᵣ(_▫_)(_) (symmetry(_≡_) yz) ] x ▫ (y ▫ z) 🝖-[ symmetry(_≡_) (associativity(_▫_)) ] (x ▫ y) ▫ z 🝖-[ congruence₂ₗ(_▫_)(_) xy ] y ▫ z 🝖-[ yz ] z 🝖-end Reflexivity.proof (Weak.PartialOrder.reflexivity partialOrder) = idempotence(_▫_) record Lattice (_∨_ : L → L → L) (_∧_ : L → L → L) : Stmt{ℓ Lvl.⊔ ℓₑ} where constructor intro field ⦃ [∨]-operator ⦄ : BinaryOperator(_∨_) ⦃ [∧]-operator ⦄ : BinaryOperator(_∧_) ⦃ [∨]-commutativity ⦄ : Commutativity(_∨_) ⦃ [∧]-commutativity ⦄ : Commutativity(_∧_) ⦃ [∨]-associativity ⦄ : Associativity(_∨_) ⦃ [∧]-associativity ⦄ : Associativity(_∧_) ⦃ [∨][∧]-absorptionₗ ⦄ : Absorptionₗ(_∨_)(_∧_) ⦃ [∧][∨]-absorptionₗ ⦄ : Absorptionₗ(_∧_)(_∨_) instance [∨][∧]-absorptionᵣ : Absorptionᵣ(_∨_)(_∧_) [∨][∧]-absorptionᵣ = [↔]-to-[→] OneTypeTwoOp.absorption-equivalence-by-commutativity [∨][∧]-absorptionₗ instance [∨]-idempotence : Idempotence(_∨_) Idempotence.proof [∨]-idempotence {x} = x ∨ x 🝖-[ congruence₂ᵣ(_∨_)(_) (symmetry(_≡_) (absorptionₗ(_∧_)(_∨_))) ] x ∨ (x ∧ (x ∨ x)) 🝖-[ absorptionₗ(_∨_)(_∧_) ] x 🝖-end instance [∨]-semilattice : Semilattice(_∨_) [∨]-semilattice = intro instance [∧][∨]-absorptionᵣ : Absorptionᵣ(_∧_)(_∨_) [∧][∨]-absorptionᵣ = [↔]-to-[→] OneTypeTwoOp.absorption-equivalence-by-commutativity [∧][∨]-absorptionₗ instance [∧]-idempotence : Idempotence(_∧_) Idempotence.proof [∧]-idempotence {x} = x ∧ x 🝖-[ congruence₂ᵣ(_∧_)(_) (symmetry(_≡_) (absorptionₗ(_∨_)(_∧_))) ] x ∧ (x ∨ (x ∧ x)) 🝖-[ absorptionₗ(_∧_)(_∨_) ] x 🝖-end instance [∧]-semilattice : Semilattice(_∧_) [∧]-semilattice = intro record Bounded (𝟎 : L) (𝟏 : L) : Stmt{ℓ Lvl.⊔ ℓₑ} where constructor intro field ⦃ [∨]-identityₗ ⦄ : Identityₗ(_∨_)(𝟎) ⦃ [∧]-identityₗ ⦄ : Identityₗ(_∧_)(𝟏) instance [∨]-identityᵣ : Identityᵣ(_∨_)(𝟎) [∨]-identityᵣ = [↔]-to-[→] One.identity-equivalence-by-commutativity [∨]-identityₗ instance [∧]-identityᵣ : Identityᵣ(_∧_)(𝟏) [∧]-identityᵣ = [↔]-to-[→] One.identity-equivalence-by-commutativity [∧]-identityₗ instance [∨]-identity : Identity(_∨_)(𝟎) [∨]-identity = intro instance [∧]-identity : Identity(_∧_)(𝟏) [∧]-identity = intro instance [∨]-absorberₗ : Absorberₗ(_∨_)(𝟏) [∨]-absorberₗ = OneTypeTwoOp.absorberₗ-by-absorptionₗ-identityₗ instance [∧]-absorberₗ : Absorberₗ(_∧_)(𝟎) [∧]-absorberₗ = OneTypeTwoOp.absorberₗ-by-absorptionₗ-identityₗ instance [∨]-absorberᵣ : Absorberᵣ(_∨_)(𝟏) [∨]-absorberᵣ = [↔]-to-[→] One.absorber-equivalence-by-commutativity [∨]-absorberₗ instance [∧]-absorberᵣ : Absorberᵣ(_∧_)(𝟎) [∧]-absorberᵣ = [↔]-to-[→] One.absorber-equivalence-by-commutativity [∧]-absorberₗ instance [∨]-absorber : Absorber(_∨_)(𝟏) [∨]-absorber = intro instance [∧]-absorber : Absorber(_∧_)(𝟎) [∧]-absorber = intro instance [∧]-monoid : Monoid(_∧_) Monoid.identity-existence [∧]-monoid = [∃]-intro(𝟏) instance [∨]-monoid : Monoid(_∨_) Monoid.identity-existence [∨]-monoid = [∃]-intro(𝟎) record Complemented (¬_ : L → L) : Stmt{ℓ Lvl.⊔ ℓₑ} where constructor intro field ⦃ [¬]-function ⦄ : Function(¬_) ⦃ excluded-middle ⦄ : ComplementFunction(_∨_)(¬_) ⦃ non-contradiction ⦄ : ComplementFunction(_∧_)(¬_) record Distributive : Stmt{ℓ Lvl.⊔ ℓₑ} where constructor intro field ⦃ [∨][∧]-distributivityₗ ⦄ : Distributivityₗ(_∨_)(_∧_) ⦃ [∧][∨]-distributivityₗ ⦄ : Distributivityₗ(_∧_)(_∨_) instance [∨][∧]-distributivityᵣ : Distributivityᵣ(_∨_)(_∧_) [∨][∧]-distributivityᵣ = [↔]-to-[→] OneTypeTwoOp.distributivity-equivalence-by-commutativity [∨][∧]-distributivityₗ instance [∧][∨]-distributivityᵣ : Distributivityᵣ(_∧_)(_∨_) [∧][∨]-distributivityᵣ = [↔]-to-[→] OneTypeTwoOp.distributivity-equivalence-by-commutativity [∧][∨]-distributivityₗ -- TODO: Is a negatable lattice using one of its operators distributed by a negation a lattice? In other words, Lattice(_∧_)(¬_ ∘₂ (_∧_ on ¬_))? record Negatable (¬_ : L → L) : Stmt{ℓ Lvl.⊔ ℓₑ} where constructor intro field ⦃ [¬]-function ⦄ : Function(¬_) ⦃ [¬]-involution ⦄ : Involution(¬_) ⦃ [¬][∧][∨]-distributivity ⦄ : Preserving₂(¬_)(_∧_)(_∨_) instance [¬][∨][∧]-distributivity : Preserving₂(¬_)(_∨_)(_∧_) Preserving.proof [¬][∨][∧]-distributivity {x}{y} = ¬(x ∨ y) 🝖-[ congruence₁(¬_) (congruence₂(_∨_) (symmetry(_≡_) (involution(¬_))) (symmetry(_≡_) (involution(¬_)))) ] ¬((¬(¬ x)) ∨ (¬(¬ y))) 🝖-[ congruence₁(¬_) (symmetry(_≡_) (preserving₂(¬_)(_∧_)(_∨_))) ] ¬(¬((¬ x) ∧ (¬ y))) 🝖-[ involution(¬_) ] (¬ x) ∧ (¬ y) 🝖-end open Lattice using (intro) public {- TODO: ? semilattices-to-lattice : ∀{_∨_ _∧_} → ⦃ _ : Semilattice(_∨_) ⦄ → ⦃ _ : Semilattice(_∧_) ⦄ → Lattice(_∨_)(_∧_) Lattice.[∨]-operator (semilattices-to-lattice ⦃ join ⦄ ⦃ meet ⦄) = Semilattice.operator join Lattice.[∧]-operator (semilattices-to-lattice ⦃ join ⦄ ⦃ meet ⦄) = Semilattice.operator meet Lattice.[∨]-commutativity (semilattices-to-lattice ⦃ join ⦄ ⦃ meet ⦄) = Semilattice.commutative join Lattice.[∧]-commutativity (semilattices-to-lattice ⦃ join ⦄ ⦃ meet ⦄) = Semilattice.commutative meet Lattice.[∨]-associativity (semilattices-to-lattice ⦃ join ⦄ ⦃ meet ⦄) = Semilattice.associative join Lattice.[∧]-associativity (semilattices-to-lattice ⦃ join ⦄ ⦃ meet ⦄) = Semilattice.associative meet Absorptionₗ.proof (Lattice.[∨][∧]-absorptionₗ (semilattices-to-lattice {_∨_}{_∧_} ⦃ join ⦄ ⦃ meet ⦄)) {x} {y} = x ∨ (x ∧ y) 🝖-[ {!!} ] x 🝖-end Absorptionₗ.proof (Lattice.[∧][∨]-absorptionₗ (semilattices-to-lattice {_∨_}{_∧_} ⦃ join ⦄ ⦃ meet ⦄)) {x} {y} = x ∧ (x ∨ y) 🝖-[ {!!} ] x 🝖-end -} -- Also called: De Morgan algebra record MorganicAlgebra (_∨_ : L → L → L) (_∧_ : L → L → L) (¬_ : L → L) (⊥ : L) (⊤ : L) : Stmt{ℓ Lvl.⊔ ℓₑ} where constructor intro field ⦃ lattice ⦄ : Lattice(_∨_)(_∧_) ⦃ boundedLattice ⦄ : Lattice.Bounded(lattice)(⊥)(⊤) ⦃ distributiveLattice ⦄ : Lattice.Distributive(lattice) ⦃ negatableLattice ⦄ : Lattice.Negatable(lattice)(¬_) record BooleanAlgebra (_∨_ : L → L → L) (_∧_ : L → L → L) (¬_ : L → L) (⊥ : L) (⊤ : L) : Stmt{ℓ Lvl.⊔ ℓₑ} where constructor intro field ⦃ lattice ⦄ : Lattice(_∨_)(_∧_) ⦃ boundedLattice ⦄ : Lattice.Bounded(lattice)(⊥)(⊤) ⦃ complementedLattice ⦄ : Lattice.Bounded.Complemented(boundedLattice)(¬_) ⦃ distributiveLattice ⦄ : Lattice.Distributive(lattice) -- TODO: Heyting algebra -- TODO: Import some proofs from SetAlgebra
{ "alphanum_fraction": 0.5992518402, "avg_line_length": 37.4977375566, "ext": "agda", "hexsha": "6a658118430dcf4020ac0928f8ed2ba7822c868b", "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": "Structure/Operator/Lattice.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": "Structure/Operator/Lattice.agda", "max_line_length": 146, "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": "Structure/Operator/Lattice.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": 3489, "size": 8287 }
open import Agda.Primitive open import Agda.Builtin.Nat open import Agda.Builtin.Bool ----------------------------------------------------- -- Σ types ----------------------------------------------------- data Σ {A : Set} (P : A → Set) : Set where Σ_intro : ∀ (a : A) → P a → Σ P ----------------------------------------------------- -- Π type ----------------------------------------------------- data Π {A : Set} (P : A → Set) : Set where Π_intro : (∀ (a : A) → P a) → Π P ----------------------------------------------------- -- constT ----------------------------------------------------- constT : ∀ (X : Set) (Y : Set) → Y → Set constT x _ _ = x ----------------------------------------------------- -- Tuples using Σ types (const) ----------------------------------------------------- Σ-pair : ∀ (A B : Set) → Set Σ-pair a b = Σ (constT b a) Σ-mkPair : ∀ {A : Set} {B : Set} → A → B → Σ-pair A B Σ-mkPair a b = Σ_intro a b Σ-fst : ∀ {A B : Set} → Σ-pair A B → A Σ-fst (Σ_intro a _) = a Σ-snd : ∀ {A B : Set} → Σ-pair A B → B Σ-snd (Σ_intro _ b) = b ----------------------------------------------------- -- Exponential using Π type (const) ----------------------------------------------------- Π-function : ∀ (A B : Set) → Set Π-function a b = Π (constT b a) Π-mkFunction : ∀ {A B : Set} → (A → B) → Π-function A B Π-mkFunction f = Π_intro f Π-apply : ∀ {A B : Set} → Π-function A B → A → B Π-apply (Π_intro f) a = f a ----------------------------------------------------- -- bool ----------------------------------------------------- bool : ∀ (A B : Set) → Bool → Set bool a _ true = a bool _ b false = b ----------------------------------------------------- -- Sum type using Σ types ----------------------------------------------------- Σ-sum : ∀ (A B : Set) → Set Σ-sum a b = Σ (bool a b) Σ-sum_left : ∀ {A : Set} (B : Set) → A → Σ-sum A B Σ-sum_left _ a = Σ_intro true a Σ-sum_right : ∀ {B : Set} (A : Set) → B → Σ-sum A B Σ-sum_right _ b = Σ_intro false b Σ-sum_elim : ∀ {A B R : Set} → (A → R) → (B → R) → Σ-sum A B → R Σ-sum_elim f _ (Σ_intro true a) = f a Σ-sum_elim _ g (Σ_intro false b) = g b ----------------------------------------------------- -- prodPredicate ----------------------------------------------------- prodPredicate : ∀ (A B R : Set) → Set prodPredicate a b r = (a → r) → (b → r) → r ----------------------------------------------------- -- Sum type using Π types ----------------------------------------------------- data Π' {a b} {A : Set a} (P : A → Set b) : Set (a ⊔ b) where Π'_intro : (∀ (a : A) → P a) → Π' P Π-sum : ∀ (A B : Set) → Set₁ Π-sum a b = Π' (prodPredicate a b) Π-sum-left : ∀ {A : Set} (B : Set) → A → Π-sum A B Π-sum-left _ a = Π'_intro (\_ f _ → f a) Π-sum-right : ∀ {A : Set} (B : Set) → B → Π-sum A B Π-sum-right _ b = Π'_intro (\_ _ g → g b) Π-sum-elim : ∀ {A B R : Set} → (A → R) → (B → R) → Π-sum A B → R Π-sum-elim f g (Π'_intro elim) = elim _ f g ----------------------------------------------------- -- Extra: Tuples using Π types ----------------------------------------------------- Π-pair : ∀ (A B : Set) → Set Π-pair a b = Π (bool a b) Π-mkPair : ∀ {A B : Set} → A → B → Π-pair A B Π-mkPair a b = Π_intro f where f : (b : Bool) → bool _ _ b f true = a f false = b Π-fst : ∀ {A B : Set} → Π-pair A B → A Π-fst (Π_intro f) = f true Π-snd : ∀ {A B : Set} → Π-pair A B → B Π-snd (Π_intro f) = f false --- -- ?? -- data Σ' {a b} {A : Set a} (P : A → Set b) : Set (a ⊔ b) where Σ'_intro : ∀ (a : A) → P a → Σ' P id : ∀ {A : Set} → A → A id a = a x : ∀ (A : Set) → Set1 x a = Σ (\(b : Set1) → (a → b)) mk : ∀ (A B : Set) → A → x A B mk _ b a' = Σ'_intro b (\f g → f (g a')) elim : {A B : Set} → (A → B) → x A B → B elim f (Σ'_intro _ g) = g id f -- : ∀ {A : Set} (B : Set) → A → Π-sum A B --Π-sum-left _ a = Π'_intro (\_ f _ → f a) -- --Π-sum-right : ∀ {A : Set} (B : Set) → B → Π-sum A B --Π-sum-right _ b = Π'_intro (\_ _ g → g b) -- --Π-sum-elim : ∀ {A B R : Set} → (A → R) → (B → R) → Π-sum A B → R --Π-sum-elim f g (Π'_intro elim) = elim _ f g
{ "alphanum_fraction": 0.3698798136, "avg_line_length": 28.3125, "ext": "agda", "hexsha": "1538ed2801ef91effa9f149afbf5338d633025b8", "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": "a15eddcc2984f32ffdbe577a1fcf1cbe0d175a8a", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "eviefp/eviefp.github.io", "max_forks_repo_path": "site/content/quantifiers/DT.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "a15eddcc2984f32ffdbe577a1fcf1cbe0d175a8a", "max_issues_repo_issues_event_max_datetime": "2019-02-07T23:19:25.000Z", "max_issues_repo_issues_event_min_datetime": "2019-02-07T15:21:30.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "eviefp/eviefp.github.io", "max_issues_repo_path": "site/content/quantifiers/DT.agda", "max_line_length": 66, "max_stars_count": null, "max_stars_repo_head_hexsha": "a15eddcc2984f32ffdbe577a1fcf1cbe0d175a8a", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "eviefp/eviefp.github.io", "max_stars_repo_path": "site/content/quantifiers/DT.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1441, "size": 4077 }
open import Oscar.Prelude open import Oscar.Class open import Oscar.Class.Leftunit open import Oscar.Class.Reflexivity open import Oscar.Class.Transitivity module Oscar.Class.Transrightidentity where module Transrightidentity {𝔬} {𝔒 : Ø 𝔬} {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯) {ℓ} (_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ) (ε : Reflexivity.type _∼_) (transitivity : Transitivity.type _∼_) = ℭLASS (_∼_ ,, (λ {x y} → _∼̇_ {x} {y}) ,, (λ {x} → ε {x}) ,, (λ {x y z} → transitivity {x} {y} {z})) (∀ {x y} {f : x ∼ y} → Leftunit.type _∼̇_ ε transitivity f) module _ {𝔬} {𝔒 : Ø 𝔬} {𝔯} {_∼_ : 𝔒 → 𝔒 → Ø 𝔯} {ℓ} {_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ} {ε : Reflexivity.type _∼_} {transitivity : Transitivity.type _∼_} where transrightidentity = Transrightidentity.method _∼_ _∼̇_ ε transitivity instance toLeftunitFromTransrightidentity : ⦃ _ : Transrightidentity.class _∼_ _∼̇_ ε transitivity ⦄ → ∀ {x y} {f : x ∼ y} → Leftunit.class _∼̇_ ε transitivity f toLeftunitFromTransrightidentity .⋆ = transrightidentity module Transrightidentity! {𝔬} {𝔒 : Ø 𝔬} {𝔯} (_∼_ : 𝔒 → 𝔒 → Ø 𝔯) {ℓ} (_∼̇_ : ∀ {x y} → x ∼ y → x ∼ y → Ø ℓ) ⦃ _ : Reflexivity.class _∼_ ⦄ ⦃ _ : Transitivity.class _∼_ ⦄ = Transrightidentity (_∼_) (_∼̇_) reflexivity transitivity
{ "alphanum_fraction": 0.5979860573, "avg_line_length": 32.275, "ext": "agda", "hexsha": "1cebd6cc93e3c27beb7afe0a18de1e58ec7c96f2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Transrightidentity.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Transrightidentity.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Transrightidentity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 574, "size": 1291 }
module Types where import Level open import Data.Unit as Unit renaming (tt to ∗) open import Data.List as List open import Data.Product open import Categories.Category using (Category) open import Function open import Relation.Binary.PropositionalEquality as PE hiding ([_]; subst) open import Relation.Binary using (module IsEquivalence; Setoid; module Setoid) open ≡-Reasoning open import Common.Context as Context -- open import Categories.Object.BinaryCoproducts ctx-cat -- Codes mutual data TermCtxCode : Set where emptyC : TermCtxCode cCtxC : (γ : TermCtxCode) → TypeCode γ → TermCtxCode TyCtxCode : Set data TypeCode (δ : TyCtxCode) (γ : TermCtxCode) : Set where closeAppTyC : TypeCode δ γ data TyFormerCode (γ : TermCtxCode) : Set where univ : TyFormerCode γ abs : (A : TypeCode γ) → (TyFormerCode (cCtxC γ A)) → TyFormerCode γ TyCtxCode = Ctx (Σ TermCtxCode TyFormerCode) TyVarCode : TyCtxCode → {γ : TermCtxCode} → TyFormerCode γ → Set TyVarCode δ {γ} T = Var δ (γ , T) emptyTy : TyCtxCode emptyTy = [] {- ctxTyFormer : (γ : TermCtxCode) → TyFormerCode γ → TyFormerCode emptyC ctxTyFormer = ? -} data AppTypeCode (δ : TyCtxCode) (γ : TermCtxCode) : Set where varC : (T : TyFormerCode γ) → (x : TyVarCode δ T) → AppTypeCode δ γ appTyC : (T : TyFormerCode γ) → AppTypeCode δ γ T μC : (γ₁ : TermCtxCode) → (t : TypeCode (ctxTyFormer γ univ ∷ δ) γ₁) → AppTypeCode δ γ {- (T : TyFormerCode) → (A : TypeCode δ γ univ) → (B : TypeCode δ γ (cCtxC γ A T)) → (t : TermCode γ A) → Type Δ Γ (subst B t) -} {- -- Just one constructor/destructor for now μ : (Γ Γ₁ : TermCtx) → (t : Type (ctxTyFormer Γ univ ∷ Δ) Γ₁ univ) → Type Δ Γ (ctxTyFormer Γ univ) ν : (Γ Γ₁ : TermCtx) → (t : Type (ctxTyFormer Γ univ ∷ Δ) Γ₁ univ) → Type Δ Γ (ctxTyFormer Γ univ) -} {- mutual data TermCtx : Set where empty : TermCtx cCtx : (Γ : TermCtx) → TypeCode Γ → TermCtx data TypeCode (Γ : TermCtx) : Set where appTy : TypeCode Γ Type : (Γ : TermCtx) → TypeCode Γ → Set data Term : (Γ : TermCtx) → TypeCode Γ → Set where data TyFormer (Γ : TermCtx) : Set where univ : TyFormer Γ abs : (A : TypeCode Γ) → (TyFormer (cCtx Γ A)) → TyFormer Γ subst : {Γ : TermCtx} → {A : TypeCode Γ} → TyFormer (cCtx Γ A) → Term Γ A → TyFormer Γ subst = {!!} Type Γ appTy = Σ (TypeCode Γ) (λ A → Σ (AppType emptyTy Γ (abs A univ)) (λ B → Term Γ A)) ctxTyFormer : (Γ : TermCtx) → TyFormer Γ → TyFormer ctxTyFormer empty T = T ctxTyFormer (cCtx Γ A) T = ctxTyFormer Γ (abs Γ A) TyCtx : Set TyCtx = Ctx (Σ TermCtx TyFormer) TyVar : TyCtx → {Γ : TermCtx} → TyFormer Γ → Set TyVar Δ {Γ} T = Var Δ (Γ , T) emptyTy : TyCtx emptyTy = [] -- | Type syntax data AppType (Δ : TyCtx) : (Γ : TermCtx) → TyFormer Γ → Set where var : (Γ : TermCtx) → (T : TyFormer Γ) → (x : TyVar Δ T) → AppType Δ Γ T appTy : (Γ : TermCtx) → (T : TyFormer) → (A : Type Δ Γ univ) → (B : Type Δ Γ (cCtx Γ A T)) → (t : Term Γ) → Type Δ Γ (subst B t) -- Just one constructor/destructor for now μ : (Γ Γ₁ : TermCtx) → (t : Type (ctxTyFormer Γ univ ∷ Δ) Γ₁ univ) → Type Δ Γ (ctxTyFormer Γ univ) ν : (Γ Γ₁ : TermCtx) → (t : Type (ctxTyFormer Γ univ ∷ Δ) Γ₁ univ) → Type Δ Γ (ctxTyFormer Γ univ) -} {- succ' : ∀{Δ} (x : TyVar Δ) → TyVar (∗ ∷ Δ) succ' = Context.succ ∗ -} {- -- | Congruence for types data _≅T_ {Γ Γ' : Ctx} : Type Γ → Type Γ' → Set where unit : unit ≅T unit var : ∀{x : TyVar Γ} {x' : TyVar Γ'} → (x ≅V x') → var x ≅T var x' _⊕_ : ∀{t₁ t₂ : Type Γ} {t₁' t₂' : Type Γ'} → (t₁ ≅T t₁') → (t₂ ≅T t₂') → (t₁ ⊕ t₂) ≅T (t₁' ⊕ t₂') _⊗_ : ∀{t₁ t₂ : Type Γ} {t₁' t₂' : Type Γ'} → (t₁ ≅T t₁') → (t₂ ≅T t₂') → (t₁ ⊗ t₂) ≅T (t₁' ⊗ t₂') μ : ∀{t : Type (∗ ∷ Γ)} {t' : Type (∗ ∷ Γ')} → (t ≅T t') → (μ t) ≅T (μ t') _⇒_ : ∀{t₁ t₁' : Type []} {t₂ : Type Γ} {t₂' : Type Γ'} → (t₁ ≅T t₁') → (t₂ ≅T t₂') → (t₁ ⇒ t₂) ≅T (t₁' ⇒ t₂') ν : ∀{t : Type (∗ ∷ Γ)} {t' : Type (∗ ∷ Γ')} → (t ≅T t') → (ν t) ≅T (ν t') Trefl : ∀ {Γ : Ctx} {t : Type Γ} → t ≅T t Trefl {t = unit} = unit Trefl {t = var x} = var e.refl where module s = Setoid module e = IsEquivalence (s.isEquivalence ≅V-setoid) Trefl {t = t₁ ⊕ t₂} = Trefl ⊕ Trefl Trefl {t = μ t} = μ Trefl Trefl {t = t ⊗ t₁} = Trefl ⊗ Trefl Trefl {t = t ⇒ t₁} = Trefl ⇒ Trefl Trefl {t = ν t} = ν Trefl Tsym : ∀ {Γ Γ' : Ctx} {t : Type Γ} {t' : Type Γ'} → t ≅T t' → t' ≅T t Tsym unit = unit Tsym (var u) = var (Vsym u) Tsym (u₁ ⊕ u₂) = Tsym u₁ ⊕ Tsym u₂ Tsym (u₁ ⊗ u₂) = Tsym u₁ ⊗ Tsym u₂ Tsym (μ u) = μ (Tsym u) Tsym (u₁ ⇒ u₂) = Tsym u₁ ⇒ Tsym u₂ Tsym (ν u) = ν (Tsym u) Ttrans : ∀ {Γ₁ Γ₂ Γ₃ : Ctx} {t₁ : Type Γ₁} {t₂ : Type Γ₂} {t₃ : Type Γ₃} → t₁ ≅T t₂ → t₂ ≅T t₃ → t₁ ≅T t₃ Ttrans unit unit = unit Ttrans (var u₁) (var u₂) = var (Vtrans u₁ u₂) Ttrans (u₁ ⊕ u₂) (u₃ ⊕ u₄) = Ttrans u₁ u₃ ⊕ Ttrans u₂ u₄ Ttrans (u₁ ⊗ u₂) (u₃ ⊗ u₄) = Ttrans u₁ u₃ ⊗ Ttrans u₂ u₄ Ttrans (μ u₁) (μ u₂) = μ (Ttrans u₁ u₂) Ttrans (u₁ ⇒ u₂) (u₃ ⇒ u₄) = Ttrans u₁ u₃ ⇒ Ttrans u₂ u₄ Ttrans (ν u₁) (ν u₂) = ν (Ttrans u₁ u₂) ≡→≅T : ∀ {Γ : Ctx} {t₁ t₂ : Type Γ} → t₁ ≡ t₂ → t₁ ≅T t₂ ≡→≅T {Γ} {t₁} {.t₁} refl = Trefl -- Note: makes the equality homogeneous in Γ ≅T-setoid : ∀ {Γ} → Setoid _ _ ≅T-setoid {Γ} = record { Carrier = Type Γ ; _≈_ = _≅T_ ; isEquivalence = record { refl = Trefl ; sym = Tsym ; trans = Ttrans } } -- | Ground type GType = Type [] unit′ : GType unit′ = unit -- | Variable renaming in types rename : {Γ Δ : TyCtx} → (ρ : Γ ▹ Δ) → Type Γ → Type Δ rename ρ unit = unit rename ρ (var x) = var (ρ ∗ x) rename ρ (t₁ ⊕ t₂) = rename ρ t₁ ⊕ rename ρ t₂ rename {Γ} {Δ} ρ (μ t) = μ (rename ρ' t) where ρ' : (∗ ∷ Γ) ▹ (∗ ∷ Δ) ρ' = ctx-id {[ ∗ ]} ⧻ ρ rename ρ (t₁ ⊗ t₂) = rename ρ t₁ ⊗ rename ρ t₂ rename ρ (t₁ ⇒ t₂) = t₁ ⇒ rename ρ t₂ rename {Γ} {Δ} ρ (ν t) = ν (rename ρ' t) where ρ' : (∗ ∷ Γ) ▹ (∗ ∷ Δ) ρ' = ctx-id {[ ∗ ]} ⧻ ρ ------------------------- ---- Generating structure on contexts (derived from renaming) weaken : {Γ : TyCtx} (Δ : TyCtx) → Type Γ -> Type (Δ ∐ Γ) weaken {Γ} Δ = rename {Γ} {Δ ∐ Γ} (i₂ {Δ} {Γ}) exchange : (Γ Δ : TyCtx) → Type (Γ ∐ Δ) -> Type (Δ ∐ Γ) exchange Γ Δ = rename [ i₂ {Δ} {Γ} , i₁ {Δ} {Γ} ] contract : {Γ : TyCtx} → Type (Γ ∐ Γ) -> Type Γ contract = rename [ ctx-id , ctx-id ] -- weaken-id-empty-ctx : (Δ : TyCtx) (t : GType) → weaken {[]} Δ t ≡ t -- weaken-id-empty-ctx = ? Subst : TyCtx → TyCtx → Set Subst Γ Δ = TyVar Γ → Type Δ id-subst : ∀{Γ : TyCtx} → Subst Γ Γ id-subst x = var x update : ∀{Γ Δ : TyCtx} → Subst Γ Δ → Type Δ → (Subst (∗ ∷ Γ) Δ) update σ a zero = a update σ _ (succ′ _ x) = σ x single-subst : ∀{Γ : TyCtx} → Type Γ → (Subst (∗ ∷ Γ) Γ) single-subst a zero = a single-subst _ (succ′ _ x) = var x lift : ∀{Γ Δ} → Subst Γ Δ → Subst (∗ ∷ Γ) (∗ ∷ Δ) lift σ = update (weaken [ ∗ ] ∘ σ) (var zero) -- | Simultaneous substitution subst : {Γ Δ : TyCtx} → (σ : Subst Γ Δ) → Type Γ → Type Δ subst σ unit = unit subst σ (var x) = σ x subst σ (t₁ ⊕ t₂) = subst σ t₁ ⊕ subst σ t₂ subst {Γ} {Δ} σ (μ t) = μ (subst (lift σ) t) subst σ (t₁ ⊗ t₂) = subst σ t₁ ⊗ subst σ t₂ subst σ (t₁ ⇒ t₂) = t₁ ⇒ subst σ t₂ subst {Γ} {Δ} σ (ν t) = ν (subst (lift σ) t) subst₀ : {Γ : TyCtx} → Type Γ → Type (∗ ∷ Γ) → Type Γ subst₀ {Γ} a = subst (update id-subst a) rename′ : {Γ Δ : TyCtx} → (ρ : Γ ▹ Δ) → Type Γ → Type Δ rename′ ρ = subst (var ∘ (ρ ∗)) -- | Unfold lfp unfold-μ : (Type [ ∗ ]) → GType unfold-μ a = subst₀ (μ a) a -- | Unfold gfp unfold-ν : (Type [ ∗ ]) → GType unfold-ν a = subst₀ (ν a) a -------------------------------------------------- ---- Examples Nat : Type [] Nat = μ (unit ⊕ x) where x = var zero Str-Fun : {Γ : TyCtx} → Type Γ → Type (∗ ∷ Γ) Str-Fun a = (weaken [ ∗ ] a ⊗ x) where x = var zero Str : {Γ : TyCtx} → Type Γ → Type Γ Str a = ν (Str-Fun a) lemma : ∀ {Γ : Ctx} {a b : Type Γ} {σ : Subst Γ Γ} → subst (update σ b) (weaken [ ∗ ] a) ≅T subst σ a lemma {a = unit} = unit lemma {a = var x} = Trefl lemma {a = a₁ ⊕ a₂} = lemma {a = a₁} ⊕ lemma {a = a₂} lemma {a = μ a} = μ {!!} lemma {a = a₁ ⊗ a₂} = lemma {a = a₁} ⊗ lemma {a = a₂} lemma {a = a₁ ⇒ a₂} = Trefl ⇒ lemma {a = a₂} lemma {a = ν a} = ν {!!} lift-id-is-id-ext : ∀ {Γ : Ctx} (x : TyVar (∗ ∷ Γ)) → (lift (id-subst {Γ})) x ≡ id-subst x lift-id-is-id-ext zero = refl lift-id-is-id-ext (succ′ ∗ x) = refl lift-id-is-id : ∀ {Γ : Ctx} → lift (id-subst {Γ}) ≡ id-subst lift-id-is-id = η-≡ lift-id-is-id-ext id-subst-id : ∀ {Γ : Ctx} {a : Type Γ} → subst id-subst a ≅T a id-subst-id {a = unit} = unit id-subst-id {a = var x} = var Vrefl id-subst-id {a = a ⊕ a₁} = id-subst-id ⊕ id-subst-id id-subst-id {a = μ a} = μ (Ttrans (≡→≅T (cong (λ u → subst u a) lift-id-is-id)) id-subst-id) id-subst-id {a = a ⊗ a₁} = id-subst-id ⊗ id-subst-id id-subst-id {a = a ⇒ a₁} = Trefl ⇒ id-subst-id id-subst-id {a = ν a} = ν (Ttrans (≡→≅T (cong (λ u → subst u a) lift-id-is-id)) id-subst-id) lemma₂ : ∀ {Γ : Ctx} {a b : Type Γ} → subst (update id-subst b) (weaken [ ∗ ] a) ≅T a lemma₂ {Γ} {a} {b} = Ttrans (lemma {Γ} {a} {b} {σ = id-subst}) id-subst-id unfold-str : ∀{a : Type []} → (unfold-ν (Str-Fun a)) ≅T (a ⊗ Str a) unfold-str {a} = lemma₂ ⊗ Trefl LFair : {Γ : TyCtx} → Type Γ → Type Γ → Type Γ LFair a b = ν (μ ((w a ⊗ x) ⊕ (w b ⊗ y))) where x = var zero y = var (succ zero) Δ = ∗ ∷ [ ∗ ] w = weaken Δ -}
{ "alphanum_fraction": 0.5254718896, "avg_line_length": 30.79375, "ext": "agda", "hexsha": "3d9d0de31464a2482b9e2b691f17ab084ad8c6d1", "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": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hbasold/Sandbox", "max_forks_repo_path": "TypeTheory/FibDataTypes/Types.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "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": "hbasold/Sandbox", "max_issues_repo_path": "TypeTheory/FibDataTypes/Types.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hbasold/Sandbox", "max_stars_repo_path": "TypeTheory/FibDataTypes/Types.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4223, "size": 9854 }
module Structure.OrderedField where import Lvl open import Data.Boolean open import Data.Boolean.Proofs import Data.Either as Either open import Data.Tuple as Tuple open import Functional open import Logic open import Logic.Classical open import Logic.IntroInstances open import Logic.Propositional open import Logic.Predicate open import Numeral.Natural using (ℕ) import Numeral.Natural.Relation.Order as ℕ open import Relator.Ordering import Relator.Ordering.Proofs as OrderingProofs open import Structure.Setoid open import Structure.Function open import Structure.Function.Domain open import Structure.Function.Ordering open import Structure.Operator.Field open import Structure.Operator.Monoid open import Structure.Operator.Group open import Structure.Operator.Proofs open import Structure.Operator.Properties open import Structure.Operator.Ring.Proofs open import Structure.Operator.Ring open import Structure.Operator open import Structure.Relator open import Structure.Relator.Ordering open Structure.Relator.Ordering.Weak.Properties open import Structure.Relator.Properties open import Structure.Relator.Proofs open import Syntax.Implication open import Syntax.Transitivity open import Type private variable ℓ ℓₗ ℓₑ : Lvl.Level private variable F : Type{ℓ} -- TODO: Generalize so that this does not neccessarily need a rng. See linearly ordered groups and partially ordered groups. See also ordered semigroups and monoids where the property is called "compatible". record Ordered ⦃ equiv : Equiv{ℓₑ}(F) ⦄ (_+_ _⋅_ : F → F → F) ⦃ rng : Rng(_+_)(_⋅_) ⦄ (_≤_ : F → F → Stmt{ℓₗ}) : Type{Lvl.of(F) Lvl.⊔ ℓₗ Lvl.⊔ ℓₑ} where open From-[≤] (_≤_) public open Rng(rng) field ⦃ [≤]-totalOrder ⦄ : Weak.TotalOrder(_≤_)(_≡_) [≤][+]ₗ-preserve : ∀{x y z} → (x ≤ y) → ((x + z) ≤ (y + z)) [≤][⋅]-zero : ∀{x y} → (𝟎 ≤ x) → (𝟎 ≤ y) → (𝟎 ≤ (x ⋅ y)) -- TODO: Rename to preserve-sign ⦃ [≤]-binaryRelator ⦄ : BinaryRelator(_≤_) -- TODO: Move this to Structure.Relator.Order or something instance [≡][≤]-sub : (_≡_) ⊆₂ (_≤_) _⊆₂_.proof [≡][≤]-sub p = substitute₂ᵣ(_≤_) p (reflexivity(_≤_)) open Weak.TotalOrder([≤]-totalOrder) public open OrderingProofs.From-[≤] (_≤_) public record NonNegative (x : F) : Stmt{ℓₗ} where constructor intro field proof : (x ≥ 𝟎) record Positive (x : F) : Stmt{ℓₗ} where constructor intro field proof : (x > 𝟎) [≤][+]ᵣ-preserve : ∀{x y z} → (y ≤ z) → ((x + y) ≤ (x + z)) [≤][+]ᵣ-preserve {x}{y}{z} yz = x + y 🝖[ _≡_ ]-[ commutativity(_+_) ]-sub y + x 🝖[ _≤_ ]-[ [≤][+]ₗ-preserve yz ] z + x 🝖[ _≡_ ]-[ commutativity(_+_) ]-sub x + z 🝖-end [≤][+]-preserve : ∀{x₁ x₂ y₁ y₂} → (x₁ ≤ x₂) → (y₁ ≤ y₂) → ((x₁ + y₁) ≤ (x₂ + y₂)) [≤][+]-preserve {x₁}{x₂}{y₁}{y₂} px py = x₁ + y₁ 🝖[ _≤_ ]-[ [≤][+]ₗ-preserve px ] x₂ + y₁ 🝖[ _≤_ ]-[ [≤][+]ᵣ-preserve py ] x₂ + y₂ 🝖[ _≤_ ]-end [≤]-flip-positive : ∀{x} → (𝟎 ≤ x) ↔ ((− x) ≤ 𝟎) [≤]-flip-positive {x} = [↔]-intro l r where l = \p → 𝟎 🝖[ _≡_ ]-[ symmetry(_≡_) (inverseFunctionᵣ(_+_)(−_)) ]-sub x + (− x) 🝖[ _≤_ ]-[ [≤][+]ᵣ-preserve p ] x + 𝟎 🝖[ _≡_ ]-[ identityᵣ(_+_)(𝟎) ]-sub x 🝖-end r = \p → − x 🝖[ _≡_ ]-[ symmetry(_≡_) (identityₗ(_+_)(𝟎)) ]-sub 𝟎 + (− x) 🝖[ _≤_ ]-[ [≤][+]ₗ-preserve p ] x + (− x) 🝖[ _≡_ ]-[ inverseFunctionᵣ(_+_)(−_) ]-sub 𝟎 🝖-end [≤]-non-negative-difference : ∀{x y} → (𝟎 ≤ (y − x)) → (x ≤ y) [≤]-non-negative-difference {x}{y} 𝟎yx = x 🝖[ _≡_ ]-[ symmetry(_≡_) (identityₗ(_+_)(𝟎)) ]-sub 𝟎 + x 🝖[ _≤_ ]-[ [≤][+]ₗ-preserve 𝟎yx ] (y − x) + x 🝖[ _≤_ ]-[] (y + (− x)) + x 🝖[ _≡_ ]-[ associativity(_+_) ]-sub y + ((− x) + x) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(_) (inverseFunctionₗ(_+_)(−_)) ]-sub y + 𝟎 🝖[ _≡_ ]-[ identityᵣ(_+_)(𝟎) ]-sub y 🝖-end [≤]-non-positive-difference : ∀{x y} → ((x − y) ≤ 𝟎) → (x ≤ y) [≤]-non-positive-difference {x}{y} xy𝟎 = x 🝖[ _≡_ ]-[ symmetry(_≡_) (identityᵣ(_+_)(𝟎)) ]-sub x + 𝟎 🝖[ _≡_ ]-[ symmetry(_≡_) (congruence₂ᵣ(_+_)(_) (inverseFunctionₗ(_+_)(−_))) ]-sub x + ((− y) + y) 🝖[ _≡_ ]-[ symmetry(_≡_) (associativity(_+_)) ]-sub (x + (− y)) + y 🝖[ _≤_ ]-[] (x − y) + y 🝖[ _≤_ ]-[ [≤][+]ₗ-preserve xy𝟎 ] 𝟎 + y 🝖[ _≡_ ]-[ identityₗ(_+_)(𝟎) ]-sub y 🝖-end [≤]-with-[−] : ∀{x y} → (x ≤ y) → ((− y) ≤ (− x)) [≤]-with-[−] {x}{y} xy = [≤]-non-positive-difference proof3 where proof3 : (((− y) − (− x)) ≤ 𝟎) proof3 = (− y) − (− x) 🝖[ _≡_ ]-[ congruence₂ᵣ(_+_)(_) (involution(−_)) ]-sub (− y) + x 🝖[ _≡_ ]-[ commutativity(_+_) ]-sub x − y 🝖[ _≤_ ]-[ [≤][+]ₗ-preserve xy ] y − y 🝖[ _≡_ ]-[ inverseFunctionᵣ(_+_)(−_) ]-sub 𝟎 🝖-end [≤]-flip-negative : ∀{x} → (x ≤ 𝟎) ↔ (𝟎 ≤ (− x)) [≤]-flip-negative {x} = [↔]-intro l r where r = \p → 𝟎 🝖[ _≡_ ]-[ symmetry(_≡_) [−]-of-𝟎 ]-sub − 𝟎 🝖[ _≤_ ]-[ [≤]-with-[−] {x}{𝟎} p ] − x 🝖-end l = \p → x 🝖[ _≡_ ]-[ symmetry(_≡_) (involution(−_)) ]-sub −(− x) 🝖[ _≤_ ]-[ [≤]-with-[−] p ] − 𝟎 🝖[ _≡_ ]-[ [−]-of-𝟎 ]-sub 𝟎 🝖-end [≤][−]ₗ-preserve : ∀{x y z} → (x ≤ y) → ((x − z) ≤ (y − z)) [≤][−]ₗ-preserve = [≤][+]ₗ-preserve [≤][−]ᵣ-preserve : ∀{x y z} → (z ≤ y) → ((x − y) ≤ (x − z)) [≤][−]ᵣ-preserve = [≤][+]ᵣ-preserve ∘ [≤]-with-[−] [≤][+]-withoutᵣ : ∀{x₁ x₂ y} → ((x₁ + y) ≤ (x₂ + y)) → (x₁ ≤ x₂) [≤][+]-withoutᵣ {x₁}{x₂}{y} p = x₁ 🝖[ _≡_ ]-[ symmetry(_≡_) (inverseOperᵣ(_+_)(_−_)) ]-sub (x₁ + y) − y 🝖[ _≤_ ]-[ [≤][−]ₗ-preserve p ] (x₂ + y) − y 🝖[ _≡_ ]-[ inverseOperᵣ(_+_)(_−_) ]-sub x₂ 🝖-end [≤][+]-withoutₗ : ∀{x y₁ y₂} → ((x + y₁) ≤ (x + y₂)) → (y₁ ≤ y₂) [≤][+]-withoutₗ {x}{y₁}{y₂} p = y₁ 🝖[ _≡_ ]-[ symmetry(_≡_) (inversePropₗ(_+_)(−_)) ]-sub (− x) + (x + y₁) 🝖[ _≤_ ]-[ [≤][+]ᵣ-preserve p ] (− x) + (x + y₂) 🝖[ _≡_ ]-[ inversePropₗ(_+_)(−_) ]-sub y₂ 🝖-end [<][+]-preserveₗ : ∀{x₁ x₂ y} → (x₁ < x₂) → ((x₁ + y) < (x₂ + y)) [<][+]-preserveₗ {x₁}{x₂}{y} px p = px ([≤][+]-withoutᵣ p) [<][+]-preserveᵣ : ∀{x y₁ y₂} → (y₁ < y₂) → ((x + y₁) < (x + y₂)) [<][+]-preserveᵣ {x₁}{x₂}{y} px p = px ([≤][+]-withoutₗ p) [<][+]-preserve : ∀{x₁ x₂ y₁ y₂} → (x₁ < x₂) → (y₁ < y₂) → ((x₁ + y₁) < (x₂ + y₂)) [<][+]-preserve {x₁}{x₂}{y₁}{y₂} px py = x₁ + y₁ 🝖[ _<_ ]-[ [<][+]-preserveₗ px ] x₂ + y₁ 🝖-semiend x₂ + y₂ 🝖[ _<_ ]-end-from-[ [<][+]-preserveᵣ py ] postulate [<][+]-preserve-subₗ : ∀{x₁ x₂ y₁ y₂} → (x₁ ≤ x₂) → (y₁ < y₂) → ((x₁ + y₁) < (x₂ + y₂)) postulate [<][+]-preserve-subᵣ : ∀{x₁ x₂ y₁ y₂} → (x₁ < x₂) → (y₁ ≤ y₂) → ((x₁ + y₁) < (x₂ + y₂)) -- Theory defining the axioms of an ordered field (a field with a weak total order). record OrderedField ⦃ equiv : Equiv{ℓₑ}(F) ⦄ (_+_ _⋅_ : F → F → F) (_≤_ : F → F → Stmt{ℓₗ}) : Type{Lvl.of(F) Lvl.⊔ ℓₗ Lvl.⊔ ℓₑ} where field ⦃ [+][⋅]-field ⦄ : Field(_+_)(_⋅_) ⦃ ordered ⦄ : Ordered(_+_)(_⋅_)(_≤_) open Field([+][⋅]-field) public open Ordered(ordered) public
{ "alphanum_fraction": 0.5050519031, "avg_line_length": 39.9171270718, "ext": "agda", "hexsha": "1da4b47799c2d9fdafa63a17c47f652b26840505", "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": "Structure/OrderedField.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": "Structure/OrderedField.agda", "max_line_length": 207, "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": "Structure/OrderedField.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": 3340, "size": 7225 }
module Global where open import Data.List open import Data.Maybe open import Data.Product open import Relation.Binary.PropositionalEquality open import Typing -- specific data PosNeg : Set where POS NEG POSNEG : PosNeg -- global session context SEntry = Maybe (STypeF SType × PosNeg) SCtx = List SEntry -- SSplit G G₁ G₂ -- split G into G₁ and G₂ -- length and position preserving data SSplit : SCtx → SCtx → SCtx → Set where ss-[] : SSplit [] [] [] ss-both : ∀ { G G₁ G₂ } → SSplit G G₁ G₂ → SSplit (nothing ∷ G) (nothing ∷ G₁) (nothing ∷ G₂) ss-left : ∀ { spn G G₁ G₂ } → SSplit G G₁ G₂ → SSplit (just spn ∷ G) (just spn ∷ G₁) (nothing ∷ G₂) ss-right : ∀ { spn G G₁ G₂ } → SSplit G G₁ G₂ → SSplit (just spn ∷ G) (nothing ∷ G₁) (just spn ∷ G₂) ss-posneg : ∀ { s G G₁ G₂ } → SSplit G G₁ G₂ → SSplit (just (s , POSNEG) ∷ G) (just (s , POS) ∷ G₁) (just (s , NEG) ∷ G₂) ss-negpos : ∀ { s G G₁ G₂ } → SSplit G G₁ G₂ → SSplit (just (s , POSNEG) ∷ G) (just (s , NEG) ∷ G₁) (just (s , POS) ∷ G₂) ssplit-sym : ∀ {G G₁ G₂} → SSplit G G₁ G₂ → SSplit G G₂ G₁ ssplit-sym ss-[] = ss-[] ssplit-sym (ss-both ss12) = ss-both (ssplit-sym ss12) ssplit-sym (ss-left ss12) = ss-right (ssplit-sym ss12) ssplit-sym (ss-right ss12) = ss-left (ssplit-sym ss12) ssplit-sym (ss-posneg ss12) = ss-negpos (ssplit-sym ss12) ssplit-sym (ss-negpos ss12) = ss-posneg (ssplit-sym ss12) -- tedious but easy to prove ssplit-compose : {G G₁ G₂ G₃ G₄ : SCtx} → (ss : SSplit G G₁ G₂) → (ss₁ : SSplit G₁ G₃ G₄) → ∃ λ Gi → SSplit G G₃ Gi × SSplit Gi G₄ G₂ ssplit-compose ss-[] ss-[] = [] , (ss-[] , ss-[]) ssplit-compose (ss-both ss) (ss-both ss₁) with ssplit-compose ss ss₁ ssplit-compose (ss-both ss) (ss-both ss₁) | Gi , ss₁₃ , ss₂₄ = nothing ∷ Gi , ss-both ss₁₃ , ss-both ss₂₄ ssplit-compose (ss-left ss) (ss-left ss₁) with ssplit-compose ss ss₁ ... | Gi , ss₁₃ , ss₂₄ = nothing ∷ Gi , ss-left ss₁₃ , ss-both ss₂₄ ssplit-compose (ss-left ss) (ss-right ss₁) with ssplit-compose ss ss₁ ... | Gi , ss₁₃ , ss₂₄ = just _ ∷ Gi , ss-right ss₁₃ , ss-left ss₂₄ ssplit-compose (ss-left ss) (ss-posneg ss₁) with ssplit-compose ss ss₁ ... | Gi , ss₁₃ , ss₂₄ = just ( _ , NEG) ∷ Gi , ss-posneg ss₁₃ , ss-left ss₂₄ ssplit-compose (ss-left ss) (ss-negpos ss₁) with ssplit-compose ss ss₁ ... | Gi , ss₁₃ , ss₂₄ = just ( _ , POS) ∷ Gi , ss-negpos ss₁₃ , ss-left ss₂₄ ssplit-compose (ss-right ss) (ss-both ss₁) with ssplit-compose ss ss₁ ... | Gi , ss₁₃ , ss₂₄ = just _ ∷ Gi , ss-right ss₁₃ , ss-right ss₂₄ ssplit-compose (ss-posneg ss) (ss-left ss₁) with ssplit-compose ss ss₁ ... | Gi , ss₁₃ , ss₂₄ = just ( _ , NEG) ∷ Gi , ss-posneg ss₁₃ , ss-right ss₂₄ ssplit-compose (ss-posneg ss) (ss-right ss₁) with ssplit-compose ss ss₁ ... | Gi , ss₁₃ , ss₂₄ = just ( _ , POSNEG) ∷ Gi , ss-right ss₁₃ , ss-posneg ss₂₄ ssplit-compose (ss-negpos ss) (ss-left ss₁) with ssplit-compose ss ss₁ ... | Gi , ss₁₃ , ss₂₄ = just ( _ , POS) ∷ Gi , ss-negpos ss₁₃ , ss-right ss₂₄ ssplit-compose (ss-negpos ss) (ss-right ss₁) with ssplit-compose ss ss₁ ... | Gi , ss₁₃ , ss₂₄ = just ( _ , POSNEG) ∷ Gi , ss-right ss₁₃ , ss-negpos ss₂₄ ssplit-compose2 : {G G₁ G₂ G₂₁ G₂₂ : SCtx} → SSplit G G₁ G₂ → SSplit G₂ G₂₁ G₂₂ → ∃ λ Gi → (SSplit G Gi G₂₁ × SSplit Gi G₁ G₂₂) ssplit-compose2 ss-[] ss-[] = [] , ss-[] , ss-[] ssplit-compose2 (ss-both ss) (ss-both ss₂) with ssplit-compose2 ss ss₂ ... | Gi , ssx , ssy = nothing ∷ Gi , ss-both ssx , ss-both ssy ssplit-compose2 (ss-left ss) (ss-both ss₂) with ssplit-compose2 ss ss₂ ... | Gi , ssx , ssy = just _ ∷ Gi , ss-left ssx , ss-left ssy ssplit-compose2 (ss-right ss) (ss-left ss₂) with ssplit-compose2 ss ss₂ ... | Gi , ssx , ssy = nothing ∷ Gi , ss-right ssx , ss-both ssy ssplit-compose2 (ss-right ss) (ss-right ss₂) with ssplit-compose2 ss ss₂ ... | Gi , ssx , ssy = just _ ∷ Gi , ss-left ssx , ss-right ssy ssplit-compose2 (ss-right ss) (ss-posneg ss₂) with ssplit-compose2 ss ss₂ ... | Gi , ssx , ssy = just (_ , NEG) ∷ Gi , ss-negpos ssx , ss-right ssy ssplit-compose2 (ss-right ss) (ss-negpos ss₂) with ssplit-compose2 ss ss₂ ... | Gi , ssx , ssy = just (_ , POS) ∷ Gi , ss-posneg ssx , ss-right ssy ssplit-compose2 (ss-posneg ss) (ss-left ss₂) with ssplit-compose2 ss ss₂ ... | Gi , ssx , ssy = just (_ , POS) ∷ Gi , ss-posneg ssx , ss-left ssy ssplit-compose2 (ss-posneg ss) (ss-right ss₂) with ssplit-compose2 ss ss₂ ... | Gi , ssx , ssy = just (_ , POSNEG) ∷ Gi , ss-left ssx , ss-posneg ssy ssplit-compose2 (ss-negpos ss) (ss-left ss₂) with ssplit-compose2 ss ss₂ ... | Gi , ssx , ssy = just (_ , NEG) ∷ Gi , ss-negpos ssx , ss-left ssy ssplit-compose2 (ss-negpos ss) (ss-right ss₂) with ssplit-compose2 ss ss₂ ... | Gi , ssx , ssy = just (_ , POSNEG) ∷ Gi , ss-left ssx , ss-negpos ssy ssplit-compose3 : {G G₁ G₂ G₃ G₄ : SCtx} → SSplit G G₁ G₂ → SSplit G₂ G₃ G₄ → ∃ λ Gi → (SSplit G Gi G₄ × SSplit Gi G₁ G₃) ssplit-compose3 ss-[] ss-[] = [] , ss-[] , ss-[] ssplit-compose3 (ss-both ss12) (ss-both ss234) with ssplit-compose3 ss12 ss234 ... | Gi , ssi4 , ssi13 = nothing ∷ Gi , ss-both ssi4 , ss-both ssi13 ssplit-compose3 (ss-left ss12) (ss-both ss234) with ssplit-compose3 ss12 ss234 ... | Gi , ssi4 , ssi13 = just _ ∷ Gi , ss-left ssi4 , ss-left ssi13 ssplit-compose3 (ss-right ss12) (ss-left ss234) with ssplit-compose3 ss12 ss234 ... | Gi , ssi4 , ssi13 = just _ ∷ Gi , ss-left ssi4 , ss-right ssi13 ssplit-compose3 (ss-right ss12) (ss-right ss234) with ssplit-compose3 ss12 ss234 ... | Gi , ssi4 , ssi13 = nothing ∷ Gi , ss-right ssi4 , ss-both ssi13 ssplit-compose3 (ss-right ss12) (ss-posneg ss234) with ssplit-compose3 ss12 ss234 ... | Gi , ssi4 , ssi13 = just ( _ , POS) ∷ Gi , ss-posneg ssi4 , ss-right ssi13 ssplit-compose3 (ss-right ss12) (ss-negpos ss234) with ssplit-compose3 ss12 ss234 ... | Gi , ssi4 , ssi13 = just ( _ , NEG) ∷ Gi , ss-negpos ssi4 , ss-right ssi13 ssplit-compose3 (ss-posneg ss12) (ss-left ss234) with ssplit-compose3 ss12 ss234 ... | Gi , ssi4 , ssi13 = just ( _ , POSNEG) ∷ Gi , ss-left ssi4 , ss-posneg ssi13 ssplit-compose3 (ss-posneg ss12) (ss-right ss234) with ssplit-compose3 ss12 ss234 ... | Gi , ssi4 , ssi13 = just ( _ , POS) ∷ Gi , ss-posneg ssi4 , ss-left ssi13 ssplit-compose3 (ss-negpos ss12) (ss-left ss234) with ssplit-compose3 ss12 ss234 ... | Gi , ssi4 , ssi13 = just ( _ , POSNEG) ∷ Gi , ss-left ssi4 , ss-negpos ssi13 ssplit-compose3 (ss-negpos ss12) (ss-right ss234) with ssplit-compose3 ss12 ss234 ... | Gi , ssi4 , ssi13 = just ( _ , NEG) ∷ Gi , ss-negpos ssi4 , ss-left ssi13 ssplit-compose4 : {G G₁ G₂ G₂₁ G₂₂ : SCtx} → (ss : SSplit G G₁ G₂) → (ss₁ : SSplit G₂ G₂₁ G₂₂) → ∃ λ Gi → SSplit G G₂₁ Gi × SSplit Gi G₁ G₂₂ ssplit-compose4 ss-[] ss-[] = [] , ss-[] , ss-[] ssplit-compose4 (ss-both ss) (ss-both ss₁) with ssplit-compose4 ss ss₁ ... | Gi , ss-21i , ss-122 = nothing ∷ Gi , ss-both ss-21i , ss-both ss-122 ssplit-compose4 (ss-left ss) (ss-both ss₁) with ssplit-compose4 ss ss₁ ... | Gi , ss-21i , ss-122 = just _ ∷ Gi , ss-right ss-21i , ss-left ss-122 ssplit-compose4 (ss-right ss) (ss-left ss₁) with ssplit-compose4 ss ss₁ ... | Gi , ss-21i , ss-122 = nothing ∷ Gi , ss-left ss-21i , ss-both ss-122 ssplit-compose4 (ss-right ss) (ss-right ss₁) with ssplit-compose4 ss ss₁ ... | Gi , ss-21i , ss-122 = just _ ∷ Gi , ss-right ss-21i , ss-right ss-122 ssplit-compose4 (ss-right ss) (ss-posneg ss₁) with ssplit-compose4 ss ss₁ ... | Gi , ss-21i , ss-122 = just (_ , NEG) ∷ Gi , ss-posneg ss-21i , ss-right ss-122 ssplit-compose4 (ss-right ss) (ss-negpos ss₁) with ssplit-compose4 ss ss₁ ... | Gi , ss-21i , ss-122 = just (_ , POS) ∷ Gi , ss-negpos ss-21i , ss-right ss-122 ssplit-compose4 (ss-posneg ss) (ss-left ss₁) with ssplit-compose4 ss ss₁ ... | Gi , ss-21i , ss-122 = just (_ , POS) ∷ Gi , ss-negpos ss-21i , ss-left ss-122 ssplit-compose4 (ss-posneg ss) (ss-right ss₁) with ssplit-compose4 ss ss₁ ... | Gi , ss-21i , ss-122 = just (_ , POSNEG) ∷ Gi , ss-right ss-21i , ss-posneg ss-122 ssplit-compose4 (ss-negpos ss) (ss-left ss₁) with ssplit-compose4 ss ss₁ ... | Gi , ss-21i , ss-122 = just (_ , NEG) ∷ Gi , ss-posneg ss-21i , ss-left ss-122 ssplit-compose4 (ss-negpos ss) (ss-right ss₁) with ssplit-compose4 ss ss₁ ... | Gi , ss-21i , ss-122 = just (_ , POSNEG) ∷ Gi , ss-right ss-21i , ss-negpos ss-122 ssplit-compose5 : ∀ {G G₁ G₂ G₁₁ G₁₂ : SCtx} → (ss : SSplit G G₁ G₂) → (ss₁ : SSplit G₁ G₁₁ G₁₂) → ∃ λ Gi → SSplit G G₁₂ Gi × SSplit Gi G₁₁ G₂ ssplit-compose5 ss-[] ss-[] = [] , ss-[] , ss-[] ssplit-compose5 (ss-both ss) (ss-both ss₁) with ssplit-compose5 ss ss₁ ... | Gi , ss-12i , ss-112 = nothing ∷ Gi , ss-both ss-12i , ss-both ss-112 ssplit-compose5 (ss-left ss) (ss-left ss₁) with ssplit-compose5 ss ss₁ ... | Gi , ss-12i , ss-112 = just _ ∷ Gi , ss-right ss-12i , ss-left ss-112 ssplit-compose5 (ss-left ss) (ss-right ss₁) with ssplit-compose5 ss ss₁ ... | Gi , ss-12i , ss-112 = nothing ∷ Gi , ss-left ss-12i , ss-both ss-112 ssplit-compose5 (ss-left ss) (ss-posneg ss₁) with ssplit-compose5 ss ss₁ ... | Gi , ss-12i , ss-112 = just (_ , POS) ∷ Gi , ss-negpos ss-12i , ss-left ss-112 ssplit-compose5 (ss-left ss) (ss-negpos ss₁) with ssplit-compose5 ss ss₁ ... | Gi , ss-12i , ss-112 = just (_ , NEG) ∷ Gi , ss-posneg ss-12i , ss-left ss-112 ssplit-compose5 (ss-right ss) (ss-both ss₁) with ssplit-compose5 ss ss₁ ... | Gi , ss-12i , ss-112 = just _ ∷ Gi , ss-right ss-12i , ss-right ss-112 ssplit-compose5 (ss-posneg ss) (ss-left ss₁) with ssplit-compose5 ss ss₁ ... | Gi , ss-12i , ss-112 = just (_ , POSNEG) ∷ Gi , ss-right ss-12i , ss-posneg ss-112 ssplit-compose5 (ss-posneg ss) (ss-right ss₁) with ssplit-compose5 ss ss₁ ... | Gi , ss-12i , ss-112 = just (_ , NEG) ∷ Gi , ss-posneg ss-12i , ss-right ss-112 ssplit-compose5 (ss-negpos ss) (ss-left ss₁) with ssplit-compose5 ss ss₁ ... | Gi , ss-12i , ss-112 = just (_ , POSNEG) ∷ Gi , ss-right ss-12i , ss-negpos ss-112 ssplit-compose5 (ss-negpos ss) (ss-right ss₁) with ssplit-compose5 ss ss₁ ... | Gi , ss-12i , ss-112 = just (_ , POS) ∷ Gi , ss-negpos ss-12i , ss-right ss-112 ssplit-compose6 : ∀ {G G₁ G₂ G₁₁ G₁₂ : SCtx} → (ss : SSplit G G₁ G₂) → (ss₁ : SSplit G₁ G₁₁ G₁₂) → ∃ λ Gi → SSplit G G₁₁ Gi × SSplit Gi G₁₂ G₂ ssplit-compose6 ss-[] ss-[] = [] , ss-[] , ss-[] ssplit-compose6 (ss-both ss) (ss-both ss₁) with ssplit-compose6 ss ss₁ ... | Gi , ss-g11i , ss-g122 = nothing ∷ Gi , ss-both ss-g11i , ss-both ss-g122 ssplit-compose6 (ss-left ss) (ss-left ss₁) with ssplit-compose6 ss ss₁ ... | Gi , ss-g11i , ss-g122 = nothing ∷ Gi , ss-left ss-g11i , ss-both ss-g122 ssplit-compose6 (ss-left ss) (ss-right ss₁) with ssplit-compose6 ss ss₁ ... | Gi , ss-g11i , ss-g122 = just _ ∷ Gi , ss-right ss-g11i , ss-left ss-g122 ssplit-compose6 (ss-left ss) (ss-posneg ss₁) with ssplit-compose6 ss ss₁ ... | Gi , ss-g11i , ss-g122 = just (_ , NEG) ∷ Gi , ss-posneg ss-g11i , ss-left ss-g122 ssplit-compose6 (ss-left ss) (ss-negpos ss₁) with ssplit-compose6 ss ss₁ ... | Gi , ss-g11i , ss-g122 = just (_ , POS) ∷ Gi , ss-negpos ss-g11i , ss-left ss-g122 ssplit-compose6 (ss-right ss) (ss-both ss₁) with ssplit-compose6 ss ss₁ ... | Gi , ss-g11i , ss-g122 = just _ ∷ Gi , ss-right ss-g11i , ss-right ss-g122 ssplit-compose6 (ss-posneg ss) (ss-left ss₁) with ssplit-compose6 ss ss₁ ... | Gi , ss-g11i , ss-g122 = just (_ , NEG) ∷ Gi , ss-posneg ss-g11i , ss-right ss-g122 ssplit-compose6 (ss-posneg ss) (ss-right ss₁) with ssplit-compose6 ss ss₁ ... | Gi , ss-g11i , ss-g122 = just (_ , POSNEG) ∷ Gi , ss-right ss-g11i , ss-posneg ss-g122 ssplit-compose6 (ss-negpos ss) (ss-left ss₁) with ssplit-compose6 ss ss₁ ... | Gi , ss-g11i , ss-g122 = just (_ , POS) ∷ Gi , ss-negpos ss-g11i , ss-right ss-g122 ssplit-compose6 (ss-negpos ss) (ss-right ss₁) with ssplit-compose6 ss ss₁ ... | Gi , ss-g11i , ss-g122 = just (_ , POSNEG) ∷ Gi , ss-right ss-g11i , ss-negpos ss-g122 ssplit-join : ∀ {G G₁ G₂ G₁₁ G₁₂ G₂₁ G₂₂} → (ss : SSplit G G₁ G₂) → (ss₁ : SSplit G₁ G₁₁ G₁₂) → (ss₂ : SSplit G₂ G₂₁ G₂₂) → ∃ λ G₁' → ∃ λ G₂' → SSplit G G₁' G₂' × SSplit G₁' G₁₁ G₂₁ × SSplit G₂' G₁₂ G₂₂ ssplit-join ss-[] ss-[] ss-[] = [] , [] , ss-[] , ss-[] , ss-[] ssplit-join (ss-both ss) (ss-both ss₁) (ss-both ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = nothing ∷ G₁' , nothing ∷ G₂' , ss-both ss-12 , ss-both ss-1121 , ss-both ss-2122 ssplit-join (ss-left ss) (ss-left ss₁) (ss-both ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , nothing ∷ G₂' , ss-left ss-12 , ss-left ss-1121 , ss-both ss-2122 ssplit-join (ss-left ss) (ss-right ss₁) (ss-both ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = nothing ∷ G₁' , just _ ∷ G₂' , ss-right ss-12 , ss-both ss-1121 , ss-left ss-2122 ssplit-join (ss-left ss) (ss-posneg ss₁) (ss-both ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , just _ ∷ G₂' , ss-posneg ss-12 , ss-left ss-1121 , ss-left ss-2122 ssplit-join (ss-left ss) (ss-negpos ss₁) (ss-both ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , just _ ∷ G₂' , ss-negpos ss-12 , ss-left ss-1121 , ss-left ss-2122 ssplit-join (ss-right ss) (ss-both ss₁) (ss-left ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , nothing ∷ G₂' , ss-left ss-12 , ss-right ss-1121 , ss-both ss-2122 ssplit-join (ss-right ss) (ss-both ss₁) (ss-right ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = nothing ∷ G₁' , just _ ∷ G₂' , ss-right ss-12 , ss-both ss-1121 , ss-right ss-2122 ssplit-join (ss-right ss) (ss-both ss₁) (ss-posneg ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , just _ ∷ G₂' , ss-posneg ss-12 , ss-right ss-1121 , ss-right ss-2122 ssplit-join (ss-right ss) (ss-both ss₁) (ss-negpos ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , just _ ∷ G₂' , ss-negpos ss-12 , ss-right ss-1121 , ss-right ss-2122 ssplit-join (ss-posneg ss) (ss-left ss₁) (ss-left ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , nothing ∷ G₂' , ss-left ss-12 , ss-posneg ss-1121 , ss-both ss-2122 ssplit-join (ss-posneg ss) (ss-left ss₁) (ss-right ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , just _ ∷ G₂' , ss-posneg ss-12 , ss-left ss-1121 , ss-right ss-2122 ssplit-join (ss-posneg ss) (ss-right ss₁) (ss-left ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , just _ ∷ G₂' , ss-negpos ss-12 , ss-right ss-1121 , ss-left ss-2122 ssplit-join (ss-posneg ss) (ss-right ss₁) (ss-right ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = nothing ∷ G₁' , just (_ , POSNEG) ∷ G₂' , ss-right ss-12 , ss-both ss-1121 , ss-posneg ss-2122 ssplit-join (ss-negpos ss) (ss-left ss₁) (ss-left ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , nothing ∷ G₂' , ss-left ss-12 , ss-negpos ss-1121 , ss-both ss-2122 ssplit-join (ss-negpos ss) (ss-left ss₁) (ss-right ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , just _ ∷ G₂' , ss-negpos ss-12 , ss-left ss-1121 , ss-right ss-2122 ssplit-join (ss-negpos ss) (ss-right ss₁) (ss-left ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = just _ ∷ G₁' , just _ ∷ G₂' , ss-posneg ss-12 , ss-right ss-1121 , ss-left ss-2122 ssplit-join (ss-negpos ss) (ss-right ss₁) (ss-right ss₂) with ssplit-join ss ss₁ ss₂ ... | G₁' , G₂' , ss-12 , ss-1121 , ss-2122 = nothing ∷ G₁' , just (_ , POSNEG) ∷ G₂' , ss-right ss-12 , ss-both ss-1121 , ss-negpos ss-2122 -- another rotation ssplit-rotate : ∀ {G G1 G2 G21 G22 G211 G212 : SCtx} → SSplit G G1 G2 → SSplit G2 G21 G22 → SSplit G21 G211 G212 → ∃ λ G2' → ∃ λ G21' → SSplit G G211 G2' × SSplit G2' G21' G22 × SSplit G21' G1 G212 ssplit-rotate ss-[] ss-[] ss-[] = [] , [] , ss-[] , ss-[] , ss-[] ssplit-rotate (ss-both ss-g12) (ss-both ss-g2122) (ss-both ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = nothing ∷ G2' , nothing ∷ G21' , (ss-both ss-g12') , (ss-both ss-g2122') , (ss-both ss-g211212') ssplit-rotate (ss-left ss-g12) (ss-both ss-g2122) (ss-both ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , (ss-right ss-g12') , ss-left ss-g2122' , ss-left ss-g211212' ssplit-rotate (ss-right ss-g12) (ss-left ss-g2122) (ss-left ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-left ss-g12' , ss-both ss-g2122' , ss-both ss-g211212' ssplit-rotate (ss-right ss-g12) (ss-left ss-g2122) (ss-right ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-right ss-g12' , ss-left ss-g2122' , ss-right ss-g211212' ssplit-rotate (ss-right ss-g12) (ss-left ss-g2122) (ss-posneg ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-posneg ss-g12' , ss-left ss-g2122' , ss-right ss-g211212' ssplit-rotate (ss-right ss-g12) (ss-left ss-g2122) (ss-negpos ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-negpos ss-g12' , ss-left ss-g2122' , ss-right ss-g211212' ssplit-rotate (ss-right ss-g12) (ss-right ss-g2122) (ss-both ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-right ss-g12' , ss-right ss-g2122' , ss-both ss-g211212' ssplit-rotate (ss-right ss-g12) (ss-posneg ss-g2122) (ss-left ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-posneg ss-g12' , ss-right ss-g2122' , ss-both ss-g211212' ssplit-rotate (ss-right ss-g12) (ss-posneg ss-g2122) (ss-right ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-right ss-g12' , ss-posneg ss-g2122' , ss-right ss-g211212' ssplit-rotate (ss-right ss-g12) (ss-negpos ss-g2122) (ss-left ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-negpos ss-g12' , ss-right ss-g2122' , ss-both ss-g211212' ssplit-rotate (ss-right ss-g12) (ss-negpos ss-g2122) (ss-right ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-right ss-g12' , ss-negpos ss-g2122' , ss-right ss-g211212' ssplit-rotate (ss-posneg ss-g12) (ss-left ss-g2122) (ss-left ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-negpos ss-g12' , ss-left ss-g2122' , ss-left ss-g211212' ssplit-rotate (ss-posneg ss-g12) (ss-left ss-g2122) (ss-right ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-right ss-g12' , ss-left ss-g2122' , ss-posneg ss-g211212' ssplit-rotate (ss-posneg ss-g12) (ss-right ss-g2122) (ss-both ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-right ss-g12' , ss-posneg ss-g2122' , ss-left ss-g211212' ssplit-rotate (ss-negpos ss-g12) (ss-left ss-g2122) (ss-left ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-posneg ss-g12' , ss-left ss-g2122' , ss-left ss-g211212' ssplit-rotate (ss-negpos ss-g12) (ss-left ss-g2122) (ss-right ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-right ss-g12' , ss-left ss-g2122' , ss-negpos ss-g211212' ssplit-rotate (ss-negpos ss-g12) (ss-right ss-g2122) (ss-both ss-g211212) with ssplit-rotate ss-g12 ss-g2122 ss-g211212 ... | G2' , G21' , ss-g12' , ss-g2122' , ss-g211212' = _ , _ , ss-right ss-g12' , ss-negpos ss-g2122' , ss-left ss-g211212' -- a session context is inactive if all its entries are void data Inactive : (G : SCtx) → Set where []-inactive : Inactive [] ::-inactive : ∀ {G : SCtx} → Inactive G → Inactive (nothing ∷ G) inactive-ssplit-trivial : ∀ {G} → Inactive G → SSplit G G G inactive-ssplit-trivial []-inactive = ss-[] inactive-ssplit-trivial (::-inactive ina) = ss-both (inactive-ssplit-trivial ina) ssplit-inactive : ∀ {G G₁ G₂} → SSplit G G₁ G₂ → Inactive G₁ → Inactive G₂ → Inactive G ssplit-inactive ss-[] []-inactive []-inactive = []-inactive ssplit-inactive (ss-both ssp) (::-inactive ina1) (::-inactive ina2) = ::-inactive (ssplit-inactive ssp ina1 ina2) ssplit-inactive (ss-left ssp) () ina2 ssplit-inactive (ss-right ssp) ina1 () ssplit-inactive (ss-posneg ssp) () ina2 ssplit-inactive (ss-negpos ssp) ina1 () ssplit-inactive-left : ∀ {G G'} → SSplit G G G' → Inactive G' ssplit-inactive-left ss-[] = []-inactive ssplit-inactive-left (ss-both ssp) = ::-inactive (ssplit-inactive-left ssp) ssplit-inactive-left (ss-left ssp) = ::-inactive (ssplit-inactive-left ssp) ssplit-refl-left : (G : SCtx) → Σ SCtx λ G' → SSplit G G G' ssplit-refl-left [] = [] , ss-[] ssplit-refl-left (just x ∷ G) with ssplit-refl-left G ... | G' , ssp' = nothing ∷ G' , ss-left ssp' ssplit-refl-left (nothing ∷ G) with ssplit-refl-left G ... | G' , ssp' = nothing ∷ G' , ss-both ssp' ssplit-refl-left-inactive : (G : SCtx) → Σ SCtx λ G' → Inactive G' × SSplit G G G' ssplit-refl-left-inactive [] = [] , []-inactive , ss-[] ssplit-refl-left-inactive (x ∷ G) with ssplit-refl-left-inactive G ssplit-refl-left-inactive (just x ∷ G) | G' , ina-G' , ss-GG' = nothing ∷ G' , ::-inactive ina-G' , ss-left ss-GG' ssplit-refl-left-inactive (nothing ∷ G) | G' , ina-G' , ss-GG' = nothing ∷ G' , ::-inactive ina-G' , ss-both ss-GG' ssplit-inactive-right : ∀ {G G'} → SSplit G G' G → Inactive G' ssplit-inactive-right ss-[] = []-inactive ssplit-inactive-right (ss-both ss) = ::-inactive (ssplit-inactive-right ss) ssplit-inactive-right (ss-right ss) = ::-inactive (ssplit-inactive-right ss) ssplit-refl-right : (G : SCtx) → Σ SCtx λ G' → SSplit G G' G ssplit-refl-right [] = [] , ss-[] ssplit-refl-right (just x ∷ G) with ssplit-refl-right G ... | G' , ssp' = nothing ∷ G' , ss-right ssp' ssplit-refl-right (nothing ∷ G) with ssplit-refl-right G ... | G' , ssp' = nothing ∷ G' , ss-both ssp' ssplit-refl-right-inactive : (G : SCtx) → Σ SCtx λ G' → Inactive G' × SSplit G G' G ssplit-refl-right-inactive [] = [] , []-inactive , ss-[] ssplit-refl-right-inactive (x ∷ G) with ssplit-refl-right-inactive G ssplit-refl-right-inactive (just x ∷ G) | G' , ina-G' , ssp' = nothing ∷ G' , ::-inactive ina-G' , ss-right ssp' ssplit-refl-right-inactive (nothing ∷ G) | G' , ina-G' , ssp' = nothing ∷ G' , ::-inactive ina-G' , ss-both ssp' inactive-left-ssplit : ∀ {G G₁ G₂} → SSplit G G₁ G₂ → Inactive G₁ → G ≡ G₂ inactive-left-ssplit ss-[] []-inactive = refl inactive-left-ssplit (ss-both ss) (::-inactive inG₁) = cong (_∷_ nothing) (inactive-left-ssplit ss inG₁) inactive-left-ssplit (ss-right ss) (::-inactive inG₁) = cong (_∷_ (just _)) (inactive-left-ssplit ss inG₁) inactive-right-ssplit : ∀ {G G₁ G₂} → SSplit G G₁ G₂ → Inactive G₂ → G ≡ G₁ inactive-right-ssplit ss-[] []-inactive = refl inactive-right-ssplit (ss-both ssp) (::-inactive ina) = cong (_∷_ nothing) (inactive-right-ssplit ssp ina) inactive-right-ssplit (ss-left ssp) (::-inactive ina) = cong (_∷_ (just _)) (inactive-right-ssplit ssp ina) inactive-right-ssplit-sym : ∀ {G G₁ G₂} → SSplit G G₁ G₂ → Inactive G₂ → G₁ ≡ G inactive-right-ssplit-sym ssp ina = sym (inactive-right-ssplit ssp ina) inactive-right-ssplit-transform : ∀ {G G₁ G₂} → SSplit G G₁ G₂ → Inactive G₂ → SSplit G G G₂ inactive-right-ssplit-transform ss-[] []-inactive = ss-[] inactive-right-ssplit-transform (ss-both ss-GG1G2) (::-inactive ina-G2) = ss-both (inactive-right-ssplit-transform ss-GG1G2 ina-G2) inactive-right-ssplit-transform (ss-left ss-GG1G2) (::-inactive ina-G2) = ss-left (inactive-right-ssplit-transform ss-GG1G2 ina-G2) inactive-right-ssplit-transform (ss-right ss-GG1G2) () inactive-right-ssplit-transform (ss-posneg ss-GG1G2) () inactive-right-ssplit-transform (ss-negpos ss-GG1G2) () ssplit-function : ∀ {G G' G₁ G₂} → SSplit G G₁ G₂ → SSplit G' G₁ G₂ → G ≡ G' ssplit-function ss-[] ss-[] = refl ssplit-function (ss-both ssp-GG1G2) (ss-both ssp-G'G1G2) = cong (_∷_ nothing) (ssplit-function ssp-GG1G2 ssp-G'G1G2) ssplit-function (ss-left ssp-GG1G2) (ss-left ssp-G'G1G2) = cong (_∷_ (just _)) (ssplit-function ssp-GG1G2 ssp-G'G1G2) ssplit-function (ss-right ssp-GG1G2) (ss-right ssp-G'G1G2) = cong (_∷_ (just _)) (ssplit-function ssp-GG1G2 ssp-G'G1G2) ssplit-function (ss-posneg ssp-GG1G2) (ss-posneg ssp-G'G1G2) = cong (_∷_ (just _)) (ssplit-function ssp-GG1G2 ssp-G'G1G2) ssplit-function (ss-negpos ssp-GG1G2) (ss-negpos ssp-G'G1G2) = cong (_∷_ (just _)) (ssplit-function ssp-GG1G2 ssp-G'G1G2) ssplit-function1 : ∀ {G G₁ G₁' G₂} → SSplit G G₁ G₂ → SSplit G G₁' G₂ → G₁ ≡ G₁' ssplit-function1 ss-[] ss-[] = refl ssplit-function1 (ss-both ssp-GG1G2) (ss-both ssp-GG1'G2) = cong (_∷_ nothing) (ssplit-function1 ssp-GG1G2 ssp-GG1'G2) ssplit-function1 (ss-left ssp-GG1G2) (ss-left ssp-GG1'G2) = cong (_∷_ (just _)) (ssplit-function1 ssp-GG1G2 ssp-GG1'G2) ssplit-function1 (ss-right ssp-GG1G2) (ss-right ssp-GG1'G2) = cong (_∷_ nothing) (ssplit-function1 ssp-GG1G2 ssp-GG1'G2) ssplit-function1 (ss-posneg ssp-GG1G2) (ss-posneg ssp-GG1'G2) = cong (_∷_ (just _)) (ssplit-function1 ssp-GG1G2 ssp-GG1'G2) ssplit-function1 (ss-negpos ssp-GG1G2) (ss-negpos ssp-GG1'G2) = cong (_∷_ (just _)) (ssplit-function1 ssp-GG1G2 ssp-GG1'G2) ssplit-function2 : ∀ {G G₁ G₂ G₂'} → SSplit G G₁ G₂ → SSplit G G₁ G₂' → G₂ ≡ G₂' ssplit-function2 ss-[] ss-[] = refl ssplit-function2 (ss-both ssp-GG1G2) (ss-both ssp-GG1G2') = cong (_∷_ nothing) (ssplit-function2 ssp-GG1G2 ssp-GG1G2') ssplit-function2 (ss-left ssp-GG1G2) (ss-left ssp-GG1G2') = cong (_∷_ nothing) (ssplit-function2 ssp-GG1G2 ssp-GG1G2') ssplit-function2 (ss-right ssp-GG1G2) (ss-right ssp-GG1G2') = cong (_∷_ (just _)) (ssplit-function2 ssp-GG1G2 ssp-GG1G2') ssplit-function2 (ss-posneg ssp-GG1G2) (ss-posneg ssp-GG1G2') = cong (_∷_ (just _)) (ssplit-function2 ssp-GG1G2 ssp-GG1G2') ssplit-function2 (ss-negpos ssp-GG1G2) (ss-negpos ssp-GG1G2') = cong (_∷_ (just _)) (ssplit-function2 ssp-GG1G2 ssp-GG1G2')
{ "alphanum_fraction": 0.6349885634, "avg_line_length": 62.0274599542, "ext": "agda", "hexsha": "68eb5a576ca668da3cbce596e44868e3a18f48f3", "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": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "peterthiemann/definitional-session", "max_forks_repo_path": "src/Global.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "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": "peterthiemann/definitional-session", "max_issues_repo_path": "src/Global.agda", "max_line_length": 131, "max_stars_count": 9, "max_stars_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "peterthiemann/definitional-session", "max_stars_repo_path": "src/Global.agda", "max_stars_repo_stars_event_max_datetime": "2021-01-18T08:10:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-01-19T16:33:27.000Z", "num_tokens": 10943, "size": 27106 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Products of nullary relations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Nullary.Product where open import Data.Product open import Function open import Relation.Nullary -- Some properties which are preserved by _×_. infixr 2 _×-dec_ _×-dec_ : ∀ {p q} {P : Set p} {Q : Set q} → Dec P → Dec Q → Dec (P × Q) yes p ×-dec yes q = yes (p , q) no ¬p ×-dec _ = no (¬p ∘ proj₁) _ ×-dec no ¬q = no (¬q ∘ proj₂)
{ "alphanum_fraction": 0.4666666667, "avg_line_length": 25.625, "ext": "agda", "hexsha": "f5e3611b4b0e679defc773371a288ca1bd3d040c", "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/Nullary/Product.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/Nullary/Product.agda", "max_line_length": 72, "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/Nullary/Product.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 158, "size": 615 }
module Impure.STLCRef.Readme where open import Impure.STLCRef.Syntax open import Impure.STLCRef.Welltyped open import Impure.STLCRef.Eval open import Impure.STLCRef.Properties.Soundness
{ "alphanum_fraction": 0.8556149733, "avg_line_length": 26.7142857143, "ext": "agda", "hexsha": "4d0b752d0a46f7e30b8485ca8551087eb9c447f5", "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/Impure/STLCRef/Readme.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/Impure/STLCRef/Readme.agda", "max_line_length": 47, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Impure/STLCRef/Readme.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 51, "size": 187 }
-- You can omit the right hand side if you pattern match on an empty type. But -- you have to do the matching. module NoRHSRequiresAbsurdPattern where data Zero : Set where good : {A : Set} -> Zero -> A good () bad : {A : Set} -> Zero -> A bad h
{ "alphanum_fraction": 0.668, "avg_line_length": 19.2307692308, "ext": "agda", "hexsha": "5408053efaef86fb8a7fad8646e976f599719090", "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/NoRHSRequiresAbsurdPattern.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/NoRHSRequiresAbsurdPattern.agda", "max_line_length": 78, "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/NoRHSRequiresAbsurdPattern.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": 72, "size": 250 }
open import FRP.JS.Maybe using ( Maybe ; just ; nothing ) open import FRP.JS.Bool using ( Bool ; true ; false ; _∨_ ; _∧_ ) open import FRP.JS.True using ( True ; tt ; contradiction ; ∧-intro ; ∧-elim₁ ; ∧-elim₂ ) open import FRP.JS.Nat using ( ℕ ; _+_ ; _∸_ ) open import FRP.JS.Keys using ( Keys ; IKeys ; _<?_ ; sorted ; head ; _∈i_ ; _∈_ ) renaming ( keys to kkeys ; ikeys to ikeysk ; ikeys✓ to ikeysk✓ ; [] to []k ; _∷_ to _∷k_ ) open import FRP.JS.String using ( String ; _<_ ; _≟_ ) open import FRP.JS.String.Properties using ( <-trans ) module FRP.JS.Object where infixr 4 _↦_∷_ data IObject {α} (A : Set α) : ∀ ks → True (sorted ks) → Set α where [] : IObject A []k tt _↦_∷_ : ∀ k (a : A) {ks k∷ks✓} → (as : IObject A ks (∧-elim₂ {k <? head ks} k∷ks✓)) → IObject A (k ∷k ks) k∷ks✓ {-# COMPILED_JS IObject function(x,v) { if ((x.array.length) <= (x.offset)) { return v["[]"](); } else { return v["_↦_∷_"](x.key(),x.value(),x.tail(),null,x.tail()); } } #-} {-# COMPILED_JS [] require("agda.object").iempty() #-} {-# COMPILED_JS _↦_∷_ function(k) { return function(a) { return function () { return function() { return function(as) { return as.set(k,a); }; }; }; }; } #-} ikeys : ∀ {α A ks ks✓} → IObject {α} A ks ks✓ → IKeys ikeys {ks = ks} as = ks ikeys✓ : ∀ {α A ks ks✓} as → True (sorted (ikeys {α} {A} {ks} {ks✓} as)) ikeys✓ {ks✓ = ks✓} as = ks✓ record Object {α} (A : Set α) : Set α where constructor object field {keys} : Keys iobject : IObject A (ikeysk keys) (ikeysk✓ keys) open Object public {-# COMPILED_JS Object function(x,v) { return v.object(require("agda.object").keys(x),require("agda.object").iobject(x)); } #-} {-# COMPILED_JS object function() { return function(as) { return as.object(); }; } #-} {-# COMPILED_JS keys function() { return function() { return require("agda.object").keys; }; } #-} {-# COMPILED_JS iobject function() { return function() { return require("agda.object").iobject; }; } #-} open Object public ⟪⟫ : ∀ {α A} → Object {α} A ⟪⟫ = object [] {-# COMPILED_JS ⟪⟫ function() { return function() { return {}; }; } #-} ilookup? : ∀ {α A ks ks✓} → IObject {α} A ks ks✓ → String → Maybe A ilookup? [] l = nothing ilookup? (k ↦ a ∷ as) l with k ≟ l ... | true = just a ... | false with k < l ... | true = ilookup? as l ... | false = nothing lookup? : ∀ {α A} → Object {α} A → String → Maybe A lookup? (object as) l = ilookup? as l {-# COMPILED_JS lookup? function() { return function() { return function(as) { return function(l) { return require("agda.box").box(require("agda.object").lookup(as,l)); }; }; }; } #-} ilookup : ∀ {α A ks ks✓} → IObject {α} A ks ks✓ → ∀ l → {l∈ks : True (l ∈i ks)} → A ilookup [] l {l∈[]} = contradiction l∈[] ilookup (k ↦ a ∷ as) l {l∈k∷ks} with k ≟ l ... | true = a ... | false with k < l ... | true = ilookup as l {l∈k∷ks} ... | false = contradiction l∈k∷ks lookup : ∀ {α A} as l → {l∈ks : True (l ∈ keys {α} {A} as)} → A lookup (object as) l {l∈ks} = ilookup as l {l∈ks} {-# COMPILED_JS lookup function() { return function() { return function(as) { return function(l) { return function() { return require("agda.object").lookup(as,l); }; }; }; }; } #-} imap : ∀ {α β A B} → (String → A → B) → ∀ {ks ks✓} → IObject {α} A ks ks✓ → IObject {β} B ks ks✓ imap f [] = [] imap f (k ↦ a ∷ as) = (k ↦ f k a ∷ imap f as) mapi : ∀ {α β A B} → (String → A → B) → Object {α} A → Object {β} B mapi f (object as) = object (imap f as) map : ∀ {α β A B} → (A → B) → Object {α} A → Object {β} B map f = mapi (λ s → f) {-# COMPILED_JS mapi function() { return function() { return function() { return function() { return function(f) { return function(as) { return require("agda.object").map(function(a,s) { return f(s)(a); },as); }; }; }; }; }; } #-} {-# COMPILED_JS map function() { return function() { return function() { return function() { return function(f) { return function(as) { return require("agda.object").map(f,as); }; }; }; }; }; } #-} iall : ∀ {α A} → (String → A → Bool) → ∀ {ks ks✓} → IObject {α} A ks ks✓ → Bool iall f [] = true iall f (k ↦ a ∷ as) = f k a ∧ iall f as alli : ∀ {α A} → (String → A → Bool) → Object {α} A → Bool alli f (object as) = iall f as all : ∀ {α A} → (A → Bool) → Object {α} A → Bool all f = alli (λ s → f) {-# COMPILED_JS alli function() { return function() { return function(f) { return function(as) { return require("agda.object").all(function(a,s) { return f(s)(a); },as); }; }; }; } #-} {-# COMPILED_JS all function() { return function() { return function(f) { return function(as) { return require("agda.object").all(f,as); }; }; }; } #-} must : ∀ {α A} → (A → Bool) → (Maybe {α} A → Bool) must p nothing = false must p (just a) = p a _⊆[_]_ : ∀ {α β A B} → Object {α} A → (A → B → Bool) → Object {β} B → Bool as ⊆[ p ] bs = alli (λ k a → must (p a) (lookup? bs k)) as _≟[_]_ : ∀ {α β A B} → Object {α} A → (A → B → Bool) → Object {β} B → Bool as ≟[ p ] bs = (as ⊆[ p ] bs) ∧ (bs ⊆[(λ a b → true)] as) kfilter : ∀ {α A} → (String → A → Bool) → ∀ {ks ks✓} → IObject {α} A ks ks✓ → IKeys kfilter f [] = []k kfilter f (k ↦ a ∷ as) with f k a ... | true = k ∷k kfilter f as ... | false = kfilter f as <?-trans : ∀ {k l m} → True (k < l) → True (l <? m) → True (k <? m) <?-trans {k} {l} {nothing} k<l l<m = tt <?-trans {k} {l} {just m} k<l l<m = <-trans {k} {l} {m} k<l l<m kfilter-<? : ∀ {α A} f {ks ks✓} as k → True (k <? head ks) → True (k <? head (kfilter {α} {A} f {ks} {ks✓} as)) kfilter-<? f [] k tt = tt kfilter-<? f {ks✓ = l∷ls✓} (l ↦ a ∷ as) k k<l with f l a ... | true = k<l ... | false = kfilter-<? f as k (<?-trans {m = head (ikeys as)} k<l (∧-elim₁ l∷ls✓)) kfilter✓ : ∀ {α A} f {ks ks✓} as → True (sorted (kfilter {α} {A} f {ks} {ks✓} as)) kfilter✓ f [] = tt kfilter✓ f {ks✓ = k∷ks✓} (k ↦ a ∷ as) with f k a ... | true = ∧-intro (kfilter-<? f as k (∧-elim₁ k∷ks✓)) (kfilter✓ f as) ... | false = kfilter✓ f as ifilter : ∀ {α A} f {ks ks✓} as → ∀ {ls✓} → IObject A (kfilter {α} {A} f {ks} {ks✓} as) ls✓ ifilter f [] = [] ifilter f (k ↦ a ∷ as) with f k a ... | true = (k ↦ a ∷ ifilter f as) ... | false = ifilter f as filteri : ∀ {α} {A} → (String → A → Bool) → Object {α} A → Object A filteri f (object as) = object (ifilter f as {kfilter✓ f as}) filter : ∀ {α} {A} → (A → Bool) → Object {α} A → Object A filter f = filteri (λ k → f) {-# COMPILED_JS filteri function() { return function() { return function(p) { return function(as) { return require("agda.object").filter(function(a,s) { return p(s)(a); },as); }; }; }; } #-} {-# COMPILED_JS filter function() { return function() { return function(p) { return function(as) { return require("agda.object").filter(p,as); }; }; }; } #-} -- Syntax sugar, e.g. ⟪ "a" ↦ 1 , "b" ↦ 2 , "c" ↦ 3 ⟫ : Object ℕ infix 3 ⟪_ infixr 4 _↦_,_ _↦_⟫ data Sugar {α} (A : Set α) : Set α where ε : Sugar A _↦_,_ : String → A → Sugar A → Sugar A _↦_⟫ : ∀ {α A} → String → A → Sugar {α} A k ↦ a ⟫ = (k ↦ a , ε) skeys : ∀ {α A} → Sugar {α} A → IKeys skeys ε = []k skeys (k ↦ a , as) = k ∷k skeys as desugar : ∀ {α A} as {ks✓} → IObject A (skeys {α} {A} as) ks✓ desugar ε = [] desugar (k ↦ a , as) = k ↦ a ∷ desugar as ⟪_ : ∀ {α A} as → {ks✓ : True (sorted (skeys {α} {A} as))} → Object A ⟪_ as {ks✓} = object {keys = kkeys (skeys as) {ks✓}} (desugar as)
{ "alphanum_fraction": 0.541109761, "avg_line_length": 33.8219178082, "ext": "agda", "hexsha": "3cacc533d2c42bc58201c3583e140f0b2484da9c", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "src/agda/FRP/JS/Object.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "src/agda/FRP/JS/Object.agda", "max_line_length": 118, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "src/agda/FRP/JS/Object.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 2908, "size": 7407 }
open import Web.Semantic.DL.ABox.Interp using ( _*_ ) open import Web.Semantic.DL.Category.Object using ( Object ) open import Web.Semantic.DL.Category.Morphism using ( _⇒_ ; _≣_ ; _⊑_ ; _,_ ) open import Web.Semantic.DL.Category.Composition using ( _∙_ ) open import Web.Semantic.DL.Category.Properties.Composition.Lemmas using ( compose-left ; compose-mid ; compose-right ; compose-resp-⊨b ) open import Web.Semantic.DL.Signature using ( Signature ) open import Web.Semantic.DL.TBox using ( TBox ) open import Web.Semantic.Util using ( left ; right ) module Web.Semantic.DL.Category.Properties.Composition.RespectsEquiv {Σ : Signature} {S T : TBox Σ} where compose-resp-⊑ : ∀ {A B C : Object S T} (F₁ F₂ : A ⇒ B) (G₁ G₂ : B ⇒ C) → (F₁ ⊑ F₂) → (G₁ ⊑ G₂) → (F₁ ∙ G₁ ⊑ F₂ ∙ G₂) compose-resp-⊑ F₁ F₂ G₁ G₂ F₁⊑F₂ G₁⊑G₂ I I⊨STA I⊨F₁⟫G₁ = compose-resp-⊨b F₂ G₂ I (F₁⊑F₂ (left * I) I⊨STA (compose-left F₁ G₁ I I⊨F₁⟫G₁)) (G₁⊑G₂ (right * I) (compose-mid F₁ G₁ I I⊨STA I⊨F₁⟫G₁) (compose-right F₁ G₁ I I⊨F₁⟫G₁)) compose-resp-≣ : ∀ {A B C : Object S T} {F₁ F₂ : A ⇒ B} {G₁ G₂ : B ⇒ C} → (F₁ ≣ F₂) → (G₁ ≣ G₂) → (F₁ ∙ G₁ ≣ F₂ ∙ G₂) compose-resp-≣ {A} {B} {C} {F₁} {F₂} {G₁} {G₂} (F₁⊑F₂ , F₂⊑F₁) (G₁⊑G₂ , G₂⊑G₁) = ( compose-resp-⊑ F₁ F₂ G₁ G₂ F₁⊑F₂ G₁⊑G₂ , compose-resp-⊑ F₂ F₁ G₂ G₁ F₂⊑F₁ G₂⊑G₁ )
{ "alphanum_fraction": 0.626497006, "avg_line_length": 46.0689655172, "ext": "agda", "hexsha": "aad546d1aac1e19ba00396afd48e0a6491cf56b5", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:40:03.000Z", "max_forks_repo_forks_event_min_datetime": "2017-12-03T14:52:09.000Z", "max_forks_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bblfish/agda-web-semantic", "max_forks_repo_path": "src/Web/Semantic/DL/Category/Properties/Composition/RespectsEquiv.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "38fbc3af7062ba5c3d7d289b2b4bcfb995d99057", "max_issues_repo_issues_event_max_datetime": "2021-01-04T20:57:19.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T02:32:28.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bblfish/agda-web-semantic", "max_issues_repo_path": "src/Web/Semantic/DL/Category/Properties/Composition/RespectsEquiv.agda", "max_line_length": 77, "max_stars_count": 9, "max_stars_repo_head_hexsha": "8ddbe83965a616bff6fc7a237191fa261fa78bab", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-semantic", "max_stars_repo_path": "src/Web/Semantic/DL/Category/Properties/Composition/RespectsEquiv.agda", "max_stars_repo_stars_event_max_datetime": "2020-03-14T14:21:08.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-13T17:46:41.000Z", "num_tokens": 639, "size": 1336 }
module Issue328 where mutual postulate D : Set -- An internal error has occurred. Please report this as a bug. -- Location of the error: src/full/Agda/Syntax/Concrete/Definitions.hs:398
{ "alphanum_fraction": 0.7591623037, "avg_line_length": 21.2222222222, "ext": "agda", "hexsha": "18a83aaca243a5165f4043cd961ce5df2ec2e057", "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/Issue328.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/Issue328.agda", "max_line_length": 74, "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/Issue328.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": 50, "size": 191 }
module Elem where open import Prelude open import Star Elem : {X : Set}(R : Rel X) -> Rel X Elem R x y = Star (LeqBool [×] R) (false , x) (true , y)
{ "alphanum_fraction": 0.6118421053, "avg_line_length": 16.8888888889, "ext": "agda", "hexsha": "508e38845d32c5b56d554073e7579509129b55df", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/AIM6/Path/Elem.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/AIM6/Path/Elem.agda", "max_line_length": 56, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/AIM6/Path/Elem.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": 54, "size": 152 }
module Test where open import LF open import IID -- r←→gArgs-subst eliminates the identity proof stored in the rArgs. If this proof is -- by reflexivity r←→gArgs-subst is a definitional identity. This is the case -- when a = g→rArgs a' r←→gArgs-subst-identity : {I : Set}(γ : OPg I)(U : I -> Set) (C : (i : I) -> rArgs (ε γ) U i -> Set) (a' : Args γ U) -> let a = g→rArgs γ U a' i = index γ U a' in (h : C (index γ U (r→gArgs γ U i a)) (g→rArgs γ U (r→gArgs γ U i a)) ) -> r←→gArgs-subst γ U C i a h ≡ h r←→gArgs-subst-identity (ι i) U C _ h = refl-≡ r←→gArgs-subst-identity (σ A γ) U C arg h = r←→gArgs-subst-identity (γ (π₀ arg)) U C' (π₁ arg) h where C' = \i c -> C i (π₀ arg , c) r←→gArgs-subst-identity (δ H i γ) U C arg h = r←→gArgs-subst-identity γ U C' (π₁ arg) h where C' = \i c -> C i (π₀ arg , c)
{ "alphanum_fraction": 0.5817535545, "avg_line_length": 33.76, "ext": "agda", "hexsha": "79bd755db2a5e4d0a40ba0e05e47ae6e3452eb6f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/iird/Test.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/iird/Test.agda", "max_line_length": 98, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/outdated-and-incorrect/iird/Test.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": 354, "size": 844 }
{-# OPTIONS --safe --without-K #-} module Erased-cubical.Without-K where data D : Set where c : D
{ "alphanum_fraction": 0.6470588235, "avg_line_length": 14.5714285714, "ext": "agda", "hexsha": "6f74c7bda45957f2a6970f680e7076524981a3b3", "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/Erased-cubical/Without-K.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/Erased-cubical/Without-K.agda", "max_line_length": 37, "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/Erased-cubical/Without-K.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": 30, "size": 102 }
open import Everything module Test.Functor where List = List⟨_⟩ module _ {a b} {A : Set a} {B : Set b} where map-list : (A → B) → List A → List B map-list f ∅ = ∅ map-list f (x , xs) = f x , map-list f xs instance SurjtranscommutativityList : ∀ {ℓ} → Surjtranscommutativity.class Function⟦ ℓ ⟧ (MFunction List) _≡̇_ map-list transitivity transitivity SurjtranscommutativityList .⋆ f g ∅ = ∅ SurjtranscommutativityList .⋆ f g (x , xs) rewrite SurjtranscommutativityList .⋆ f g xs = ∅ SurjextensionalityList : ∀ {ℓ} → Surjextensionality.class Function⟦ ℓ ⟧ _≡̇_ (MFunction List) _≡̇_ _ map-list SurjextensionalityList .⋆ _ _ f₁ f₂ f₁≡̇f₂ ∅ = ∅ SurjextensionalityList .⋆ _ _ f₁ f₂ f₁≡̇f₂ (x , xs) rewrite SurjextensionalityList .⋆ _ _ f₁ f₂ f₁≡̇f₂ xs | f₁≡̇f₂ x = ∅ SurjidentityList : ∀ {ℓ} → Surjidentity.class Function⟦ ℓ ⟧ (MFunction List) _≡̇_ map-list ε ε SurjidentityList .⋆ ∅ = ∅ SurjidentityList .⋆ (x , xs) rewrite SurjidentityList .⋆ xs = ∅ test-isprecategory-1 : ∀ {ℓ} → IsPrecategory {𝔒 = Ø ℓ} Function⟦ ℓ ⟧ _≡̇_ (flip _∘′_) test-isprecategory-1 {ℓ} = IsPrecategoryExtension {A = Ø ℓ} {B = ¡} test-isprecategory-2 : ∀ {ℓ} → IsPrecategory {𝔒 = Ø ℓ} Function⟦ ℓ ⟧ _≡̇_ (flip _∘′_) test-isprecategory-2 {ℓ} = IsPrecategoryFunction {𝔬 = ℓ} test-isprecategory-1a : ∀ {ℓ} → IsPrecategory {𝔒 = Ø ℓ} (Extension (¡ {𝔒 = Ø ℓ})) _≡̇_ (flip _∘′_) test-isprecategory-1a {ℓ} = IsPrecategoryExtension {A = Ø ℓ} {B = ¡} test-isprecategory-2a : ∀ {ℓ} → IsPrecategory {𝔒 = Ø ℓ} (Extension (¡ {𝔒 = Ø ℓ})) _≡̇_ (flip _∘′_) test-isprecategory-2a {ℓ} = IsPrecategoryFunction {𝔬 = ℓ} test-isprecategory-1b : IsPrecategory {𝔒 = ¶} (Extension (Term.Term ¶)) _≡̇_ (flip _∘′_) test-isprecategory-1b = IsPrecategoryExtension {A = ¶} {B = Term.Term ¶} -- test-isprecategory-2b : IsPrecategory {𝔒 = ¶} (Extension (Term.Term ¶)) _≡̇_ (flip _∘′_) -- test-isprecategory-2b = {!!} -- IsPrecategoryFunction {𝔬 = ?} instance HmapList : ∀ {a} → Hmap.class Function⟦ a ⟧ (MFunction List) HmapList = ∁ λ _ _ → map-list instance isPrefunctorList : ∀ {ℓ} → IsPrefunctor (λ (x y : Ø ℓ) → x → y) Proposextensequality transitivity (λ (x y : Ø ℓ) → List x → List y) Proposextensequality transitivity smap isPrefunctorList = ∁ isFunctorList : ∀ {ℓ} → IsFunctor (λ (x y : Ø ℓ) → x → y) Proposextensequality ε transitivity (λ (x y : Ø ℓ) → List x → List y) Proposextensequality ε transitivity smap isFunctorList = ∁ instance FmapList : ∀ {ℓ} → Fmap (List {ℓ}) FmapList = ∁ smap module _ {a} {A : Set a} {B : Set a} where test-smap-list : (A → B) → List A → List B test-smap-list = smap module _ {a} {A : Set a} {B : Set a} where test-fmap-list : (A → B) → List A → List B test-fmap-list = fmap -- the intention here is to try to say "I want to invoke a functoral mapping, so that I can be sure that, for example, that `test-map-list ε₁ ≡ ε₂`.
{ "alphanum_fraction": 0.5443407235, "avg_line_length": 37.6703296703, "ext": "agda", "hexsha": "5448916d148731eee88721db252dfa137ee3ae38", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Test/Functor.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Test/Functor.agda", "max_line_length": 172, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Test/Functor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1223, "size": 3428 }
module Imports.Test where open import Common.Level record Foo (ℓ : Level) : Set ℓ where
{ "alphanum_fraction": 0.7282608696, "avg_line_length": 11.5, "ext": "agda", "hexsha": "66e42e4fd2a207c32883f3c93d0fe974cd33e7e1", "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/Imports/Test.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/Imports/Test.agda", "max_line_length": 36, "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/Imports/Test.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": 25, "size": 92 }
-- {-# OPTIONS -v scope:10 -v scope.inverse:100 #-} open import Common.Equality open import A.Issue1635 Set test : ∀ x → x ≡ foo test x = refl -- ERROR: -- x != .#A.Issue1635-225351734.foo of type Foo -- when checking that the expression refl has type x ≡ foo -- SLIGHTLY BETTER: -- x != .A.Issue1635.Foo.foo of type Foo -- when checking that the expression refl has type x ≡ foo -- WANT: x != foo ...
{ "alphanum_fraction": 0.6609336609, "avg_line_length": 22.6111111111, "ext": "agda", "hexsha": "b6013421988baa5ce50cbd8517256ab0e9362bbd", "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/Issue1635.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/Issue1635.agda", "max_line_length": 58, "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/Issue1635.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": 126, "size": 407 }
{-# OPTIONS --safe --without-K #-} open import Generics.Prelude hiding (lookup) open import Generics.Telescope open import Generics.Desc open import Generics.HasDesc module Generics.Constructions.Case {P I ℓ} {A : Indexed P I ℓ} (H : HasDesc A) (open HasDesc H) {p c} (Pr : Pred′ I λ i → A′ (p , i) → Set c) where private variable V : ExTele P i : ⟦ I ⟧tel p v : ⟦ V ⟧tel p Pr′ : A′ (p , i) → Set c Pr′ {i} = unpred′ I _ Pr i -------------------------- -- Types of motives levelCase : ConDesc P V I → Level levelCase (var x) = c levelCase (π {ℓ′} _ _ C) = ℓ′ ⊔ levelCase C levelCase (A ⊗ B) = levelIndArg A ℓ ⊔ levelCase B MotiveCon : (C : ConDesc P V I) → (∀ {i} → ⟦ C ⟧Con A′ (p , v , i) → Set c) → Set (levelCase C) MotiveCon (var γ) X = X refl MotiveCon (π ia S C) X = Π< ia > (S _) λ s → MotiveCon C (X ∘ (s ,_)) MotiveCon (A ⊗ B) X = (x : ⟦ A ⟧IndArg A′ (p , _)) → MotiveCon B (X ∘ (x ,_)) Motives : ∀ k → Set (levelCase (lookupCon D k)) Motives k = MotiveCon (lookupCon D k) (λ x → Pr′ (constr (k , x))) -------------------------- -- Case-analysis principle module _ (methods : Els Motives) where caseData : ∀ {i} → (x : ⟦ D ⟧Data A′ (p , i)) → Pr′ (constr x) caseData (k , x) = caseCon (lookupCon D k) (methods k) x where caseCon : (C : ConDesc P V I) {mk : ∀ {i} → ⟦ C ⟧Con A′ (p , v , i) → ⟦ D ⟧Data A′ (p , i)} (mot : MotiveCon C λ x → Pr′ (constr (mk x))) (x : ⟦ C ⟧Con A′ (p , v , i)) → Pr′ (constr (mk x)) caseCon (var γ) mot refl = mot caseCon (π ia _ C) mot (s , x) = caseCon C (app< ia > mot s) x caseCon (A ⊗ B) mot (a , b) = caseCon B (mot a) b case : (x : A′ (p , i)) → Pr′ x case x = subst Pr′ (constr∘split x) (caseData (split x)) deriveCase : Arrows Motives (Pred′ I (λ i → (x : A′ (p , i)) → Pr′ x)) deriveCase = curryₙ (λ m → pred′ I _ λ i → case m)
{ "alphanum_fraction": 0.5141825683, "avg_line_length": 28.9402985075, "ext": "agda", "hexsha": "9e3fec579fadfb24105570fa3c2dcfd89be6f957", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2022-01-14T10:35:16.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-08T08:32:42.000Z", "max_forks_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "flupe/generics", "max_forks_repo_path": "src/Generics/Constructions/Case.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_issues_repo_issues_event_max_datetime": "2022-01-14T10:48:30.000Z", "max_issues_repo_issues_event_min_datetime": "2021-09-13T07:33:50.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "flupe/generics", "max_issues_repo_path": "src/Generics/Constructions/Case.agda", "max_line_length": 72, "max_stars_count": 11, "max_stars_repo_head_hexsha": "db764f858d908aa39ea4901669a6bbce1525f757", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "flupe/generics", "max_stars_repo_path": "src/Generics/Constructions/Case.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T09:35:17.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-08T15:10:20.000Z", "num_tokens": 758, "size": 1939 }
open import Agda.Builtin.Bool open import Agda.Builtin.List open import Agda.Builtin.Reflection open import Agda.Builtin.Unit P : Bool → Set P true = Bool P false = Bool f : (b : Bool) → P b f true = true f false = false pattern varg x = arg (arg-info visible relevant) x create-constraint : TC Set create-constraint = unquoteTC (def (quote P) (varg (def (quote f) (varg unknown ∷ [])) ∷ [])) macro should-fail : Term → TC ⊤ should-fail _ = bindTC (noConstraints create-constraint) λ _ → returnTC tt test : ⊤ test = should-fail
{ "alphanum_fraction": 0.6625441696, "avg_line_length": 18.8666666667, "ext": "agda", "hexsha": "1a3a9be22febf536859dc98d2bd10fe202d93ccc", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-01T18:30:09.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/NoConstraints.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/NoConstraints.agda", "max_line_length": 63, "max_stars_count": 2, "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/NoConstraints.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 177, "size": 566 }
module Numeric.Nat.LCM.Properties where open import Prelude open import Numeric.Nat.Divide open import Numeric.Nat.Divide.Properties open import Numeric.Nat.LCM is-lcm-unique : ∀ {m m₁ a b} → IsLCM m a b → IsLCM m₁ a b → m ≡ m₁ is-lcm-unique {m} {m₁} (is-lcm a|m b|m lm) (is-lcm a|m₁ b|m₁ lm₁) = divides-antisym (lm m₁ a|m₁ b|m₁) (lm₁ m a|m b|m) lcm-unique : ∀ {m a b} → IsLCM m a b → lcm! a b ≡ m lcm-unique {a = a} {b} lm with lcm a b ... | lcm-res m₁ lm₁ = is-lcm-unique lm₁ lm is-lcm-commute : ∀ {m a b} → IsLCM m a b → IsLCM m b a is-lcm-commute (is-lcm a|m b|m g) = is-lcm b|m a|m (flip ∘ g) lcm-commute : ∀ {a b} → lcm! a b ≡ lcm! b a lcm-commute {a} {b} with lcm b a ... | lcm-res m lm = lcm-unique (is-lcm-commute lm) private _|>_ = divides-trans lcm-assoc : ∀ a b c → lcm! a (lcm! b c) ≡ lcm! (lcm! a b) c lcm-assoc a b c with lcm a b | lcm b c ... | lcm-res ab (is-lcm a|ab b|ab lab) | lcm-res bc (is-lcm b|bc c|bc lbc) with lcm ab c ... | lcm-res ab-c (is-lcm ab|abc c|abc labc) = lcm-unique {ab-c} {a} {bc} (is-lcm (a|ab |> ab|abc) (lbc ab-c (b|ab |> ab|abc) c|abc) λ k a|k bc|k → labc k (lab k a|k (b|bc |> bc|k)) (c|bc |> bc|k))
{ "alphanum_fraction": 0.5808885163, "avg_line_length": 33.1388888889, "ext": "agda", "hexsha": "da4296f5142b70dda3eeb4dc6984234d45c78541", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_path": "src/Numeric/Nat/LCM/Properties.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "t-more/agda-prelude", "max_issues_repo_path": "src/Numeric/Nat/LCM/Properties.agda", "max_line_length": 76, "max_stars_count": 111, "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_path": "src/Numeric/Nat/LCM/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 513, "size": 1193 }
{-# OPTIONS --without-K #-} module function.extensionality.computation where open import equality open import function.isomorphism open import function.core open import function.extensionality.core open import function.extensionality.proof open import function.extensionality.strong funext-inv-hom : ∀ {i j}{X : Set i}{Y : X → Set j} → {f₁ f₂ f₃ : (x : X) → Y x} → (p₁ : f₁ ≡ f₂) → (p₂ : f₂ ≡ f₃) → funext-inv (p₁ · p₂) ≡ (λ x → funext-inv p₁ x · funext-inv p₂ x) funext-inv-hom refl p₂ = refl funext-hom : ∀ {i j}{X : Set i}{Y : X → Set j} → {f₁ f₂ f₃ : (x : X) → Y x} → (h₁ : (x : X) → f₁ x ≡ f₂ x) → (h₂ : (x : X) → f₂ x ≡ f₃ x) → funext (λ x → h₁ x · h₂ x) ≡ funext h₁ · funext h₂ funext-hom h₁ h₂ = begin funext (λ x → h₁ x · h₂ x) ≡⟨ sym (ap funext (ap₂ (λ u v x → u x · v x) (_≅_.iso₁ strong-funext-iso h₁) (_≅_.iso₁ strong-funext-iso h₂))) ⟩ funext (λ x → funext-inv (funext h₁) x · funext-inv (funext h₂) x) ≡⟨ sym (ap funext (funext-inv-hom (funext h₁) (funext h₂))) ⟩ funext (funext-inv (funext h₁ · funext h₂)) ≡⟨ _≅_.iso₂ strong-funext-iso (funext h₁ · funext h₂) ⟩ funext h₁ · funext h₂ ∎ where open ≡-Reasoning funext-inv-ap : ∀ {i j k}{X : Set i}{Y : X → Set j}{Z : X → Set k} → (g : {x : X} → Y x → Z x) → {f₁ f₂ : (x : X) → Y x} → (p : f₁ ≡ f₂) → funext-inv (ap (_∘'_ g) p) ≡ ((λ x → ap g (funext-inv p x))) funext-inv-ap g refl = refl funext-ap : ∀ {i j k}{X : Set i}{Y : X → Set j}{Z : X → Set k} → (g : {x : X} → Y x → Z x) → {f₁ f₂ : (x : X) → Y x} → (h : (x : X) → f₁ x ≡ f₂ x) → funext (λ x → ap g (h x)) ≡ ap (_∘'_ g) (funext h) funext-ap g h = begin funext (λ x → ap g (h x)) ≡⟨ sym (ap funext (ap (λ h x → ap g (h x)) (_≅_.iso₁ strong-funext-iso h))) ⟩ funext (λ x → ap g (funext-inv (funext h) x)) ≡⟨ ap funext (sym (funext-inv-ap g (funext h))) ⟩ funext (funext-inv (ap (_∘'_ g) (funext h))) ≡⟨ _≅_.iso₂ strong-funext-iso _ ⟩ ap (_∘'_ g) (funext h) ∎ where open ≡-Reasoning
{ "alphanum_fraction": 0.4828947368, "avg_line_length": 36.1904761905, "ext": "agda", "hexsha": "15ea5fee86f3115c94d90d78b9f94fd6b086c1c5", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_path": "function/extensionality/computation.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_path": "function/extensionality/computation.agda", "max_line_length": 70, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "function/extensionality/computation.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 901, "size": 2280 }
module trie where open import string open import maybe open import trie-core public open import empty trie-lookup : ∀{A : Set} → trie A → string → maybe A trie-lookup t s = trie-lookup-h t (string-to-𝕃char s) trie-insert : ∀{A : Set} → trie A → string → A → trie A trie-insert t s x = trie-insert-h t (string-to-𝕃char s) x trie-remove : ∀{A : Set} → trie A → string → trie A trie-remove t s = trie-remove-h t (string-to-𝕃char s) open import trie-functions trie-lookup trie-insert trie-remove public
{ "alphanum_fraction": 0.697029703, "avg_line_length": 28.0555555556, "ext": "agda", "hexsha": "5fad0fe538e79172db9b86d8369d46eae967a980", "lang": "Agda", "max_forks_count": 17, "max_forks_repo_forks_event_max_datetime": "2021-11-28T20:13:21.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-03T22:38:15.000Z", "max_forks_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rfindler/ial", "max_forks_repo_path": "trie.agda", "max_issues_count": 8, "max_issues_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_issues_repo_issues_event_max_datetime": "2022-03-22T03:43:34.000Z", "max_issues_repo_issues_event_min_datetime": "2018-07-09T22:53:38.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rfindler/ial", "max_issues_repo_path": "trie.agda", "max_line_length": 69, "max_stars_count": 29, "max_stars_repo_head_hexsha": "f3f0261904577e930bd7646934f756679a6cbba6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rfindler/ial", "max_stars_repo_path": "trie.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T15:05:12.000Z", "max_stars_repo_stars_event_min_datetime": "2019-02-06T13:09:31.000Z", "num_tokens": 155, "size": 505 }
module Everything where -- Categories import Categories.Category -- 2-categories -- XXX need to finish the last 3 laws import Categories.2-Category -- The strict 2-category of categories -- XXX laws not proven yet -- import Categories.2-Category.Categories -- Adjunctions between functors import Categories.Adjunction -- The Agda Set category import Categories.Agda -- The fact that one version of it is cocomplete import Categories.Agda.ISetoids.Cocomplete -- The arrow category construction on any category import Categories.Arrow -- Bifunctors (functors from a product category) import Categories.Bifunctor -- Natural transformations between bifunctors import Categories.Bifunctor.NaturalTransformation -- The category of (small) categories import Categories.Categories -- Cat has products import Categories.Categories.Products -- Closed categories import Categories.Closed -- Cocones import Categories.Cocone -- The category of cocones under a diagram (functor) import Categories.Cocones -- Coends import Categories.Coend -- Coequalizers import Categories.Coequalizer -- Colimits import Categories.Colimit -- Comma categories import Categories.Comma -- Comonads, defined directly (not as monads on the opposite category) import Categories.Comonad -- The cofree construction that gives a comonad for any functor import Categories.Comonad.Cofree -- Cones import Categories.Cone -- The category of cones over a diagram (functor) import Categories.Cones -- A coherent equivalence relation over the objects of a category import Categories.Congruence -- Discrete categories (they only have objects and identity morphisms) import Categories.Discrete -- Ends import Categories.End -- Enriched categories import Categories.Enriched -- Equalizers import Categories.Equalizer -- Strong equivalence import Categories.Equivalence.Strong -- Fibrations import Categories.Fibration -- Free category on a graph import Categories.Free -- The free category construction is a functor from Gph to Cat import Categories.Free.Functor -- Functors import Categories.Functor -- F-algebra (TODO: maybe the module should be renamed) import Categories.Functor.Algebra -- The category of F-algebras of a functor import Categories.Functor.Algebras -- An F-coalgebra import Categories.Functor.Coalgebra -- Constant functor import Categories.Functor.Constant -- The category of F-coalgebras of a functor import Categories.Functor.Coalgebras -- The diagonal functor (C → C × C, or same thing with an arbitrary indexed product) import Categories.Functor.Diagonal -- Strong functor equivalence -- XXX doesn't seem to work because of the double negative in Full? -- import Categories.Functor.Equivalence.Strong -- The hom functor, mapping pairs of objects to the morphisms between them import Categories.Functor.Hom -- Monoidal functors (similar to Haskell's Applicative class) import Categories.Functor.Monoidal -- Products as functors import Categories.Functor.Product -- Properties of general functors import Categories.Functor.Properties -- Representable functors import Categories.Functor.Representable -- Functor categories (of functors between two categories and natural transformations between them) import Categories.FunctorCategory -- The category of graphs and graph homomorphisms (Gph) import Categories.Graphs -- The underlying graph of a category (forgetful functor Cat ⇒ Gph) import Categories.Graphs.Underlying -- The Grothendieck construction on categories (taking a Sets-valued functor and building a category containing all values) import Categories.Grothendieck -- The globe category, used for defining globular sets (with a presheaf on it) import Categories.Globe -- Globular sets import Categories.GlobularSet -- Left Kan extensions import Categories.Lan -- Small categories exist as large categories too import Categories.Lift -- Limits import Categories.Limit -- Monads, defined as simple triples of a functor and two natural transformations import Categories.Monad -- A monad algebra import Categories.Monad.Algebra -- The category of all algebras of a monad import Categories.Monad.Algebras -- The Eilenberg-Moore category for any monad import Categories.Monad.EilenbergMoore -- The Kleisli category for any monad import Categories.Monad.Kleisli -- Strong monads import Categories.Monad.Strong -- Monoidal categories, with an associative bi(endo)functor and an identity object import Categories.Monoidal -- A braided monoidal category (one that gives you a swap operation, but isn't quite commutative) import Categories.Monoidal.Braided -- A cartesian monoidal category (monoidal category whose monoid is the product with a terminal object) import Categories.Monoidal.Cartesian -- Closed monoidal categories, which are simply monoidal categories that are -- also closed, such that the laws "fit" import Categories.Monoidal.Closed -- Both of the above. Separated into its own module because we can do many -- interesting things with them. import Categories.Monoidal.CartesianClosed -- Simple definitions about morphisms, such as mono, epi, and iso import Categories.Morphisms -- Cartesian morphisms (used mostly for fibrations) import Categories.Morphism.Cartesian -- Families of morphisms indexed by a set import Categories.Morphism.Indexed -- Natural isomorphisms, defined as an isomorphism of natural transformations import Categories.NaturalIsomorphism -- Natural transformations import Categories.NaturalTransformation import Categories.DinaturalTransformation -- Properties of the opposite category import Categories.Opposite -------------------------------------------------------------------------------- -- Objects -------------------------------------------------------------------------------- -- The coproduct of two objects import Categories.Object.Coproduct -- A category has all binary coproducts import Categories.Object.BinaryCoproducts -- A category has all finite coproducts import Categories.Object.Coproducts -- An exponential object import Categories.Object.Exponential -- A choice of B^A for a given B and any A import Categories.Object.Exponentiating -- B^— is adjoint to its opposite import Categories.Object.Exponentiating.Adjunction -- B^— as a functor import Categories.Object.Exponentiating.Functor -- A family of objects indexed by a set import Categories.Object.Indexed -- An initial object import Categories.Object.Initial -- The product of two objects import Categories.Object.Product -- The usual nice constructions on products, conditionalized on existence import Categories.Object.Product.Morphisms -- All binary products import Categories.Object.BinaryProducts -- Products of a nonempty list of objects and the ability to reassociate them massively import Categories.Object.BinaryProducts.N-ary -- All finite products import Categories.Object.Products import Categories.Object.Products.Properties -- Products of a list of objects and the ability to reassociate them massively import Categories.Object.Products.N-ary -- The product of a family of objects import Categories.Object.IndexedProduct -- All products of indexed families import Categories.Object.IndexedProducts -- Subobject classifiers (for topoi) import Categories.Object.SubobjectClassifier -- Terminal object import Categories.Object.Terminal -- A^1 and 1^A always exist import Categories.Object.Terminal.Exponentials -- A chosen 1^A exists import Categories.Object.Terminal.Exponentiating -- A×1 always exists import Categories.Object.Terminal.Products -- Zero object (initial and terminal) import Categories.Object.Zero -- A category containing n copies of objects/morphisms/equalities of another category import Categories.Power -- Demonstrations that Power categories are the same as functors from discrete categories import Categories.Power.Functorial -- Natural transformations for functors to/from power categories import Categories.Power.NaturalTransformation -- A preorder gives rise to a category import Categories.Preorder -- A presheaf (functor from C^op to V) import Categories.Presheaf -- The category of presheaves (a specific functor category) import Categories.Presheaves -- The product of two categories import Categories.Product import Categories.Product.Properties -- Projection functors from a product category to its factors import Categories.Product.Projections -- Profunctors import Categories.Profunctor -- Pullbacks in a category import Categories.Pullback -- Pushouts in a category import Categories.Pushout -- All categories can have a slice category defined on them import Categories.Slice -- Utilities for gluing together commutative squares (and triangles) -- (and other common patterns of equational reasoning) import Categories.Square -- The terminal category (a terminal object in the category of small categories) import Categories.Terminal -- A topos import Categories.Topos -- The Yoneda lemma import Categories.Yoneda
{ "alphanum_fraction": 0.7939502177, "avg_line_length": 26.1195335277, "ext": "agda", "hexsha": "c0120227d70a9a8a078ee6a0451c937e8cf42cf6", "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": "Everything.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": "Everything.agda", "max_line_length": 123, "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": "Everything.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": 1908, "size": 8959 }
open import Common.Prelude module TestHarness where record ⊤ : Set where data ⊥ : Set where T : Bool → Set T true = ⊤ T false = ⊥ infixr 4 _,_ data Asserts : Set where ε : Asserts _,_ : Asserts → Asserts → Asserts assert : (b : Bool) → {b✓ : T b} → String → Asserts Tests : Set Tests = ⊤ → Asserts
{ "alphanum_fraction": 0.6282051282, "avg_line_length": 14.1818181818, "ext": "agda", "hexsha": "1c784558a6fe9352bc4444ee45edc81b84b59aca", "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/js/TestHarness.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/js/TestHarness.agda", "max_line_length": 53, "max_stars_count": 1, "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/js/TestHarness.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": 112, "size": 312 }
open import Agda.Builtin.Coinduction open import Agda.Builtin.Equality open import Agda.Builtin.List open import Agda.Builtin.Nat infixr 5 _∷_ data Stream (A : Set) : Set where _∷_ : (x : A) (xs : ∞ (Stream A)) → Stream A head : ∀ {A} → Stream A → A head (x ∷ xs) = x tail : ∀ {A} → Stream A → Stream A tail (x ∷ xs) = ♭ xs take : ∀ {A} n → Stream A → List A take zero xs = [] take (suc n) (x ∷ xs) = x ∷ take n (♭ xs) accepted : ∀ {A} {n} (xs : Stream A) → take (suc n) xs ≡ take (suc n) (head xs ∷ ♯ tail xs) accepted (x ∷ xs) = refl private rejected : ∀ {A} {n} (xs : Stream A) → take (suc n) xs ≡ take (suc n) (head xs ∷ ♯ tail xs) rejected (x ∷ xs) = refl
{ "alphanum_fraction": 0.5544554455, "avg_line_length": 24.3793103448, "ext": "agda", "hexsha": "febfc6685ecf314ff948dc264dbaec51468e40b7", "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": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pthariensflame/agda", "max_forks_repo_path": "test/Succeed/Issue2321.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pthariensflame/agda", "max_issues_repo_path": "test/Succeed/Issue2321.agda", "max_line_length": 65, "max_stars_count": 3, "max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pthariensflame/agda", "max_stars_repo_path": "test/Succeed/Issue2321.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": 281, "size": 707 }
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Pi open import lib.types.TwoSemiCategory open import lib.two-semi-categories.Functor module lib.two-semi-categories.FunCategory where module _ {i j k} (A : Type i) (G : TwoSemiCategory j k) where private module G = TwoSemiCategory G fun-El : Type (lmax i j) fun-El = A → G.El fun-Arr : fun-El → fun-El → Type (lmax i k) fun-Arr F G = ∀ a → G.Arr (F a) (G a) fun-Arr-level : (F G : fun-El) → has-level 1 (fun-Arr F G) fun-Arr-level F G = Π-level (λ a → G.Arr-level (F a) (G a)) fun-comp : {F G H : fun-El} (α : fun-Arr F G) (β : fun-Arr G H) → fun-Arr F H fun-comp α β a = G.comp (α a) (β a) fun-assoc : {F G H I : fun-El} (α : fun-Arr F G) (β : fun-Arr G H) (γ : fun-Arr H I) → fun-comp (fun-comp α β) γ == fun-comp α (fun-comp β γ) fun-assoc α β γ = λ= (λ a → G.assoc (α a) (β a) (γ a)) abstract fun-pentagon : {F G H I J : fun-El} (α : fun-Arr F G) (β : fun-Arr G H) (γ : fun-Arr H I) (δ : fun-Arr I J) → fun-assoc (fun-comp α β) γ δ ◃∙ fun-assoc α β (fun-comp γ δ) ◃∎ =ₛ ap (λ s → fun-comp s δ) (fun-assoc α β γ) ◃∙ fun-assoc α (fun-comp β γ) δ ◃∙ ap (fun-comp α) (fun-assoc β γ δ) ◃∎ fun-pentagon α β γ δ = fun-assoc (fun-comp α β) γ δ ◃∙ fun-assoc α β (fun-comp γ δ) ◃∎ =ₛ⟨ ∙-λ= (λ a → G.assoc (G.comp (α a) (β a)) (γ a) (δ a)) (λ a → G.assoc (α a) (β a) (G.comp (γ a) (δ a))) ⟩ λ= (λ a → G.assoc (G.comp (α a) (β a)) (γ a) (δ a) ∙ G.assoc (α a) (β a) (G.comp (γ a) (δ a))) ◃∎ =ₛ₁⟨ ap λ= (λ= (λ a → =ₛ-out (G.pentagon-identity (α a) (β a) (γ a) (δ a)))) ⟩ λ= (λ a → ap (λ s → G.comp s (δ a)) (G.assoc (α a) (β a) (γ a)) ∙ G.assoc (α a) (G.comp (β a) (γ a)) (δ a) ∙ ap (G.comp (α a)) (G.assoc (β a) (γ a) (δ a))) ◃∎ =ₛ⟨ λ=-∙∙ (λ a → ap (λ s → G.comp s (δ a)) (G.assoc (α a) (β a) (γ a))) (λ a → G.assoc (α a) (G.comp (β a) (γ a)) (δ a)) (λ a → ap (G.comp (α a)) (G.assoc (β a) (γ a) (δ a))) ⟩ λ= (λ a → ap (λ s → G.comp s (δ a)) (G.assoc (α a) (β a) (γ a))) ◃∙ fun-assoc α (fun-comp β γ) δ ◃∙ λ= (λ a → ap (G.comp (α a)) (G.assoc (β a) (γ a) (δ a))) ◃∎ =ₛ₁⟨ 0 & 1 & ! (λ=-ap (λ a s → G.comp s (δ a)) (λ a → G.assoc (α a) (β a) (γ a))) ⟩ ap (λ s → fun-comp s δ) (fun-assoc α β γ) ◃∙ fun-assoc α (fun-comp β γ) δ ◃∙ λ= (λ a → ap (G.comp (α a)) (G.assoc (β a) (γ a) (δ a))) ◃∎ =ₛ₁⟨ 2 & 1 & ! (λ=-ap (λ a → G.comp (α a)) (λ a → G.assoc (β a) (γ a) (δ a))) ⟩ ap (λ s → fun-comp s δ) (fun-assoc α β γ) ◃∙ fun-assoc α (fun-comp β γ) δ ◃∙ ap (fun-comp α) (fun-assoc β γ δ) ◃∎ ∎ₛ fun-cat : TwoSemiCategory (lmax i j) (lmax i k) fun-cat = record { El = fun-El ; Arr = fun-Arr ; Arr-level = fun-Arr-level ; two-semi-cat-struct = record { comp = fun-comp ; assoc = fun-assoc ; pentagon-identity = fun-pentagon } } module _ {i j₁ k₁ j₂ k₂} (A : Type i) {G : TwoSemiCategory j₁ k₁} {H : TwoSemiCategory j₂ k₂} (F : TwoSemiFunctor G H) where private module G = TwoSemiCategory G module H = TwoSemiCategory H module F = TwoSemiFunctor F module fun-G = TwoSemiCategory (fun-cat A G) module fun-H = TwoSemiCategory (fun-cat A H) fun-F₀ : fun-G.El → fun-H.El fun-F₀ I = λ a → F.F₀ (I a) fun-F₁ : {I J : fun-G.El} → fun-G.Arr I J → fun-H.Arr (fun-F₀ I) (fun-F₀ J) fun-F₁ α = λ a → F.F₁ (α a) fun-pres-comp : {I J K : fun-G.El} (α : fun-G.Arr I J) (β : fun-G.Arr J K) → fun-F₁ (fun-G.comp α β) == fun-H.comp (fun-F₁ α) (fun-F₁ β) fun-pres-comp α β = λ= (λ a → F.pres-comp (α a) (β a)) abstract fun-pres-comp-coh : {I J K L : fun-G.El} (α : fun-G.Arr I J) (β : fun-G.Arr J K) (γ : fun-G.Arr K L) → fun-pres-comp (fun-G.comp α β) γ ◃∙ ap (λ s → fun-H.comp s (fun-F₁ γ)) (fun-pres-comp α β) ◃∙ fun-H.assoc (fun-F₁ α) (fun-F₁ β) (fun-F₁ γ) ◃∎ =ₛ ap fun-F₁ (fun-G.assoc α β γ) ◃∙ fun-pres-comp α (fun-G.comp β γ) ◃∙ ap (fun-H.comp (fun-F₁ α)) (fun-pres-comp β γ) ◃∎ fun-pres-comp-coh α β γ = fun-pres-comp (fun-G.comp α β) γ ◃∙ ap (λ s → fun-H.comp s (fun-F₁ γ)) (fun-pres-comp α β) ◃∙ fun-H.assoc (fun-F₁ α) (fun-F₁ β) (fun-F₁ γ) ◃∎ =ₛ₁⟨ 1 & 1 & λ=-ap (λ a s → H.comp s (fun-F₁ γ a) ) (λ a → F.pres-comp (α a) (β a)) ⟩ fun-pres-comp (fun-G.comp α β) γ ◃∙ λ= (λ a → ap (λ s → H.comp s (fun-F₁ γ a)) (F.pres-comp (α a) (β a))) ◃∙ fun-H.assoc (fun-F₁ α) (fun-F₁ β) (fun-F₁ γ) ◃∎ =ₛ⟨ ∙∙-λ= (λ a → F.pres-comp (G.comp (α a) (β a)) (γ a)) (λ a → ap (λ s → H.comp s (fun-F₁ γ a)) (F.pres-comp (α a) (β a))) (λ a → H.assoc (fun-F₁ α a) (fun-F₁ β a) (fun-F₁ γ a)) ⟩ λ= (λ a → F.pres-comp (G.comp (α a) (β a)) (γ a) ∙ ap (λ s → H.comp s (fun-F₁ γ a)) (F.pres-comp (α a) (β a)) ∙ H.assoc (fun-F₁ α a) (fun-F₁ β a) (fun-F₁ γ a)) ◃∎ =ₛ₁⟨ ap λ= (λ= (λ a → =ₛ-out (F.pres-comp-coh (α a) (β a) (γ a)))) ⟩ λ= (λ a → ap F.F₁ (G.assoc (α a) (β a) (γ a)) ∙ F.pres-comp (α a) (G.comp (β a) (γ a)) ∙ ap (H.comp (fun-F₁ α a)) (F.pres-comp (β a) (γ a))) ◃∎ =ₛ⟨ λ=-∙∙ (λ a → ap F.F₁ (G.assoc (α a) (β a) (γ a))) (λ a → F.pres-comp (α a) (G.comp (β a) (γ a))) (λ a → ap (H.comp (fun-F₁ α a)) (F.pres-comp (β a) (γ a))) ⟩ λ= (λ a → ap F.F₁ (G.assoc (α a) (β a) (γ a))) ◃∙ fun-pres-comp α (fun-G.comp β γ) ◃∙ λ= (λ a → ap (H.comp (fun-F₁ α a)) (F.pres-comp (β a) (γ a))) ◃∎ =ₛ₁⟨ 0 & 1 & ! $ λ=-ap (λ _ → F.F₁) (λ a → G.assoc (α a) (β a) (γ a)) ⟩ ap fun-F₁ (fun-G.assoc α β γ) ◃∙ fun-pres-comp α (fun-G.comp β γ) ◃∙ λ= (λ a → ap (H.comp (fun-F₁ α a)) (F.pres-comp (β a) (γ a))) ◃∎ =ₛ₁⟨ 2 & 1 & ! $ λ=-ap (λ a → H.comp (fun-F₁ α a)) (λ a → F.pres-comp (β a) (γ a)) ⟩ ap fun-F₁ (fun-G.assoc α β γ) ◃∙ fun-pres-comp α (fun-G.comp β γ) ◃∙ ap (fun-H.comp (fun-F₁ α)) (fun-pres-comp β γ) ◃∎ ∎ₛ fun-functor-map : TwoSemiFunctor (fun-cat A G) (fun-cat A H) fun-functor-map = record { F₀ = fun-F₀ ; F₁ = fun-F₁ ; pres-comp = fun-pres-comp ; pres-comp-coh = fun-pres-comp-coh }
{ "alphanum_fraction": 0.4702399501, "avg_line_length": 42.2236842105, "ext": "agda", "hexsha": "c9c144804f109bca09dbdd99f00bd6274f0a666d", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "AntoineAllioux/HoTT-Agda", "max_forks_repo_path": "core/lib/two-semi-categories/FunCategory.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "AntoineAllioux/HoTT-Agda", "max_issues_repo_path": "core/lib/two-semi-categories/FunCategory.agda", "max_line_length": 93, "max_stars_count": 294, "max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "AntoineAllioux/HoTT-Agda", "max_stars_repo_path": "core/lib/two-semi-categories/FunCategory.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 2851, "size": 6418 }
module Prelude.Sum where open import Agda.Primitive open import Prelude.Empty open import Prelude.Unit open import Prelude.List open import Prelude.Functor open import Prelude.Applicative open import Prelude.Monad open import Prelude.Equality open import Prelude.Decidable open import Prelude.Product open import Prelude.Function data Either {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where left : A → Either A B right : B → Either A B {-# FOREIGN GHC type AgdaEither a b = Either #-} {-# COMPILE GHC Either = data MAlonzo.Code.Prelude.Sum.AgdaEither (Left | Right) #-} either : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (A → C) → (B → C) → Either A B → C either f g (left x) = f x either f g (right x) = g x lefts : ∀ {a b} {A : Set a} {B : Set b} → List (Either A B) → List A lefts = concatMap λ { (left x) → [ x ]; (right _) → [] } rights : ∀ {a b} {A : Set a} {B : Set b} → List (Either A B) → List B rights = concatMap λ { (left _) → []; (right x) → [ x ] } mapEither : ∀ {a₁ a₂ b₁ b₂} {A₁ : Set a₁} {A₂ : Set a₂} {B₁ : Set b₁} {B₂ : Set b₂} → (A₁ → A₂) → (B₁ → B₂) → Either A₁ B₁ → Either A₂ B₂ mapEither f g = either (left ∘ f) (right ∘ g) mapLeft : ∀ {a₁ a₂ b} {A₁ : Set a₁} {A₂ : Set a₂} {B : Set b} → (A₁ → A₂) → Either A₁ B → Either A₂ B mapLeft f = either (left ∘ f) right mapRight : ∀ {a b₁ b₂} {A : Set a} {B₁ : Set b₁} {B₂ : Set b₂} → (B₁ → B₂) → Either A B₁ → Either A B₂ mapRight f = either left (right ∘ f) partitionMap : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (A → Either B C) → List A → List B × List C partitionMap f [] = [] , [] partitionMap f (x ∷ xs) = either (first ∘ _∷_) (λ y → second (_∷_ y)) -- second ∘ _∷_ doesn't work for some reason (f x) (partitionMap f xs) --- Equality --- left-inj : ∀ {a} {A : Set a} {x y : A} {b} {B : Set b} → left {B = B} x ≡ left y → x ≡ y left-inj refl = refl right-inj : ∀ {b} {B : Set b} {x y : B} {a} {A : Set a} → right {A = A} x ≡ right y → x ≡ y right-inj refl = refl private eqEither : ∀ {a b} {A : Set a} {B : Set b} {{EqA : Eq A}} {{EqB : Eq B}} (x y : Either A B) → Dec (x ≡ y) eqEither (left x) (right y) = no (λ ()) eqEither (right x) (left y) = no (λ ()) eqEither (left x) (left y) with x == y ... | yes eq = yes (left $≡ eq) ... | no neq = no λ eq → neq (left-inj eq) eqEither (right x) (right y) with x == y ... | yes eq = yes (right $≡ eq) ... | no neq = no λ eq → neq (right-inj eq) instance EqEither : ∀ {a b} {A : Set a} {B : Set b} {{EqA : Eq A}} {{EqB : Eq B}} → Eq (Either A B) _==_ {{EqEither}} = eqEither --- Monad instance --- module _ {a b} {A : Set a} where instance FunctorEither : Functor (Either {b = b} A) fmap {{FunctorEither}} f (left x) = left x fmap {{FunctorEither}} f (right x) = right (f x) ApplicativeEither : Applicative (Either {b = b} A) pure {{ApplicativeEither}} = right _<*>_ {{ApplicativeEither}} (right f) (right x) = right (f x) _<*>_ {{ApplicativeEither}} (right _) (left e) = left e _<*>_ {{ApplicativeEither}} (left e) _ = left e MonadEither : Monad (Either {b = b} A) _>>=_ {{MonadEither}} m f = either left f m
{ "alphanum_fraction": 0.5367978372, "avg_line_length": 34.6770833333, "ext": "agda", "hexsha": "f2cb1cefa7bd94c6d53b96ae9113c75afc889c46", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "t-more/agda-prelude", "max_forks_repo_path": "src/Prelude/Sum.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "t-more/agda-prelude", "max_issues_repo_path": "src/Prelude/Sum.agda", "max_line_length": 101, "max_stars_count": 111, "max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "t-more/agda-prelude", "max_stars_repo_path": "src/Prelude/Sum.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 1221, "size": 3329 }
module snoc where open import unit open import empty open import bool open import product data Snoc (A : Set) : Set where [] : Snoc A _::_ : Snoc A → A → Snoc A infixl 6 _::_ _++_ [_] : {A : Set} → A → Snoc A [ x ] = [] :: x _++_ : {A : Set} → Snoc A → Snoc A → Snoc A [] ++ l₂ = l₂ (l₁ :: x) ++ l₂ = (l₁ ++ l₂) :: x member : {A : Set} → (A → A → 𝔹) → A → Snoc A → 𝔹 member _=A_ x (l :: y) with x =A y ... | tt = tt ... | ff = ff member _=A_ x _ = ff inPairSnocFst : {A B : Set} → (A → A → 𝔹) → A → Snoc (A × B) → Set inPairSnocFst _=A_ x [] = ⊥ inPairSnocFst _=A_ x (l :: (a , _)) with x =A a ... | tt = ⊤ ... | ff = inPairSnocFst _=A_ x l
{ "alphanum_fraction": 0.504601227, "avg_line_length": 20.375, "ext": "agda", "hexsha": "1a22659c24196e266f3d4e01ee2fe52740ea1beb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "heades/AUGL", "max_forks_repo_path": "snoc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "heades/AUGL", "max_issues_repo_path": "snoc.agda", "max_line_length": 66, "max_stars_count": null, "max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "heades/AUGL", "max_stars_repo_path": "snoc.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 304, "size": 652 }
{-# OPTIONS --allow-unsolved-metas #-} module nat where open import Data.Nat open import Data.Nat.Properties open import Data.Empty open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Relation.Binary.Core open import Relation.Binary.Definitions open import logic open import Level hiding ( zero ; suc ) nat-<> : { x y : ℕ } → x < y → y < x → ⊥ nat-<> (s≤s x<y) (s≤s y<x) = nat-<> x<y y<x nat-≤> : { x y : ℕ } → x ≤ y → y < x → ⊥ nat-≤> (s≤s x<y) (s≤s y<x) = nat-≤> x<y y<x nat-<≡ : { x : ℕ } → x < x → ⊥ nat-<≡ (s≤s lt) = nat-<≡ lt nat-≡< : { x y : ℕ } → x ≡ y → x < y → ⊥ nat-≡< refl lt = nat-<≡ lt ¬a≤a : {la : ℕ} → suc la ≤ la → ⊥ ¬a≤a (s≤s lt) = ¬a≤a lt a<sa : {la : ℕ} → la < suc la a<sa {zero} = s≤s z≤n a<sa {suc la} = s≤s a<sa =→¬< : {x : ℕ } → ¬ ( x < x ) =→¬< {zero} () =→¬< {suc x} (s≤s lt) = =→¬< lt >→¬< : {x y : ℕ } → (x < y ) → ¬ ( y < x ) >→¬< (s≤s x<y) (s≤s y<x) = >→¬< x<y y<x <-∨ : { x y : ℕ } → x < suc y → ( (x ≡ y ) ∨ (x < y) ) <-∨ {zero} {zero} (s≤s z≤n) = case1 refl <-∨ {zero} {suc y} (s≤s lt) = case2 (s≤s z≤n) <-∨ {suc x} {zero} (s≤s ()) <-∨ {suc x} {suc y} (s≤s lt) with <-∨ {x} {y} lt <-∨ {suc x} {suc y} (s≤s lt) | case1 eq = case1 (cong (λ k → suc k ) eq) <-∨ {suc x} {suc y} (s≤s lt) | case2 lt1 = case2 (s≤s lt1) max : (x y : ℕ) → ℕ max zero zero = zero max zero (suc x) = (suc x) max (suc x) zero = (suc x) max (suc x) (suc y) = suc ( max x y ) -- _*_ : ℕ → ℕ → ℕ -- _*_ zero _ = zero -- _*_ (suc n) m = m + ( n * m ) -- x ^ y exp : ℕ → ℕ → ℕ exp _ zero = 1 exp n (suc m) = n * ( exp n m ) div2 : ℕ → (ℕ ∧ Bool ) div2 zero = ⟪ 0 , false ⟫ div2 (suc zero) = ⟪ 0 , true ⟫ div2 (suc (suc n)) = ⟪ suc (proj1 (div2 n)) , proj2 (div2 n) ⟫ where open _∧_ div2-rev : (ℕ ∧ Bool ) → ℕ div2-rev ⟪ x , true ⟫ = suc (x + x) div2-rev ⟪ x , false ⟫ = x + x div2-eq : (x : ℕ ) → div2-rev ( div2 x ) ≡ x div2-eq zero = refl div2-eq (suc zero) = refl div2-eq (suc (suc x)) with div2 x | inspect div2 x ... | ⟪ x1 , true ⟫ | record { eq = eq1 } = begin -- eq1 : div2 x ≡ ⟪ x1 , true ⟫ div2-rev ⟪ suc x1 , true ⟫ ≡⟨⟩ suc (suc (x1 + suc x1)) ≡⟨ cong (λ k → suc (suc k )) (+-comm x1 _ ) ⟩ suc (suc (suc (x1 + x1))) ≡⟨⟩ suc (suc (div2-rev ⟪ x1 , true ⟫)) ≡⟨ cong (λ k → suc (suc (div2-rev k ))) (sym eq1) ⟩ suc (suc (div2-rev (div2 x))) ≡⟨ cong (λ k → suc (suc k)) (div2-eq x) ⟩ suc (suc x) ∎ where open ≡-Reasoning ... | ⟪ x1 , false ⟫ | record { eq = eq1 } = begin div2-rev ⟪ suc x1 , false ⟫ ≡⟨⟩ suc (x1 + suc x1) ≡⟨ cong (λ k → (suc k )) (+-comm x1 _ ) ⟩ suc (suc (x1 + x1)) ≡⟨⟩ suc (suc (div2-rev ⟪ x1 , false ⟫)) ≡⟨ cong (λ k → suc (suc (div2-rev k ))) (sym eq1) ⟩ suc (suc (div2-rev (div2 x))) ≡⟨ cong (λ k → suc (suc k)) (div2-eq x) ⟩ suc (suc x) ∎ where open ≡-Reasoning sucprd : {i : ℕ } → 0 < i → suc (pred i) ≡ i sucprd {suc i} 0<i = refl 0<s : {x : ℕ } → zero < suc x 0<s {_} = s≤s z≤n px<py : {x y : ℕ } → pred x < pred y → x < y px<py {zero} {suc y} lt = 0<s px<py {suc zero} {suc (suc y)} (s≤s lt) = s≤s 0<s px<py {suc (suc x)} {suc (suc y)} (s≤s lt) = s≤s (px<py {suc x} {suc y} lt) minus : (a b : ℕ ) → ℕ minus a zero = a minus zero (suc b) = zero minus (suc a) (suc b) = minus a b _-_ = minus m+= : {i j m : ℕ } → m + i ≡ m + j → i ≡ j m+= {i} {j} {zero} refl = refl m+= {i} {j} {suc m} eq = m+= {i} {j} {m} ( cong (λ k → pred k ) eq ) +m= : {i j m : ℕ } → i + m ≡ j + m → i ≡ j +m= {i} {j} {m} eq = m+= ( subst₂ (λ j k → j ≡ k ) (+-comm i _ ) (+-comm j _ ) eq ) less-1 : { n m : ℕ } → suc n < m → n < m less-1 {zero} {suc (suc _)} (s≤s (s≤s z≤n)) = s≤s z≤n less-1 {suc n} {suc m} (s≤s lt) = s≤s (less-1 {n} {m} lt) sa=b→a<b : { n m : ℕ } → suc n ≡ m → n < m sa=b→a<b {0} {suc zero} refl = s≤s z≤n sa=b→a<b {suc n} {suc (suc n)} refl = s≤s (sa=b→a<b refl) minus+n : {x y : ℕ } → suc x > y → minus x y + y ≡ x minus+n {x} {zero} _ = trans (sym (+-comm zero _ )) refl minus+n {zero} {suc y} (s≤s ()) minus+n {suc x} {suc y} (s≤s lt) = begin minus (suc x) (suc y) + suc y ≡⟨ +-comm _ (suc y) ⟩ suc y + minus x y ≡⟨ cong ( λ k → suc k ) ( begin y + minus x y ≡⟨ +-comm y _ ⟩ minus x y + y ≡⟨ minus+n {x} {y} lt ⟩ x ∎ ) ⟩ suc x ∎ where open ≡-Reasoning <-minus-0 : {x y z : ℕ } → z + x < z + y → x < y <-minus-0 {x} {suc _} {zero} lt = lt <-minus-0 {x} {y} {suc z} (s≤s lt) = <-minus-0 {x} {y} {z} lt <-minus : {x y z : ℕ } → x + z < y + z → x < y <-minus {x} {y} {z} lt = <-minus-0 ( subst₂ ( λ j k → j < k ) (+-comm x _) (+-comm y _ ) lt ) x≤x+y : {z y : ℕ } → z ≤ z + y x≤x+y {zero} {y} = z≤n x≤x+y {suc z} {y} = s≤s (x≤x+y {z} {y}) x≤y+x : {z y : ℕ } → z ≤ y + z x≤y+x {z} {y} = subst (λ k → z ≤ k ) (+-comm _ y ) x≤x+y <-plus : {x y z : ℕ } → x < y → x + z < y + z <-plus {zero} {suc y} {z} (s≤s z≤n) = s≤s (subst (λ k → z ≤ k ) (+-comm z _ ) x≤x+y ) <-plus {suc x} {suc y} {z} (s≤s lt) = s≤s (<-plus {x} {y} {z} lt) <-plus-0 : {x y z : ℕ } → x < y → z + x < z + y <-plus-0 {x} {y} {z} lt = subst₂ (λ j k → j < k ) (+-comm _ z) (+-comm _ z) ( <-plus {x} {y} {z} lt ) ≤-plus : {x y z : ℕ } → x ≤ y → x + z ≤ y + z ≤-plus {0} {y} {zero} z≤n = z≤n ≤-plus {0} {y} {suc z} z≤n = subst (λ k → z < k ) (+-comm _ y ) x≤x+y ≤-plus {suc x} {suc y} {z} (s≤s lt) = s≤s ( ≤-plus {x} {y} {z} lt ) ≤-plus-0 : {x y z : ℕ } → x ≤ y → z + x ≤ z + y ≤-plus-0 {x} {y} {zero} lt = lt ≤-plus-0 {x} {y} {suc z} lt = s≤s ( ≤-plus-0 {x} {y} {z} lt ) x+y<z→x<z : {x y z : ℕ } → x + y < z → x < z x+y<z→x<z {zero} {y} {suc z} (s≤s lt1) = s≤s z≤n x+y<z→x<z {suc x} {y} {suc z} (s≤s lt1) = s≤s ( x+y<z→x<z {x} {y} {z} lt1 ) *≤ : {x y z : ℕ } → x ≤ y → x * z ≤ y * z *≤ lt = *-mono-≤ lt ≤-refl *< : {x y z : ℕ } → x < y → x * suc z < y * suc z *< {zero} {suc y} lt = s≤s z≤n *< {suc x} {suc y} (s≤s lt) = <-plus-0 (*< lt) <to<s : {x y : ℕ } → x < y → x < suc y <to<s {zero} {suc y} (s≤s lt) = s≤s z≤n <to<s {suc x} {suc y} (s≤s lt) = s≤s (<to<s {x} {y} lt) <tos<s : {x y : ℕ } → x < y → suc x < suc y <tos<s {zero} {suc y} (s≤s z≤n) = s≤s (s≤s z≤n) <tos<s {suc x} {suc y} (s≤s lt) = s≤s (<tos<s {x} {y} lt) <to≤ : {x y : ℕ } → x < y → x ≤ y <to≤ {zero} {suc y} (s≤s z≤n) = z≤n <to≤ {suc x} {suc y} (s≤s lt) = s≤s (<to≤ {x} {y} lt) refl-≤s : {x : ℕ } → x ≤ suc x refl-≤s {zero} = z≤n refl-≤s {suc x} = s≤s (refl-≤s {x}) refl-≤ : {x : ℕ } → x ≤ x refl-≤ {zero} = z≤n refl-≤ {suc x} = s≤s (refl-≤ {x}) x<y→≤ : {x y : ℕ } → x < y → x ≤ suc y x<y→≤ {zero} {.(suc _)} (s≤s z≤n) = z≤n x<y→≤ {suc x} {suc y} (s≤s lt) = s≤s (x<y→≤ {x} {y} lt) ≤→= : {i j : ℕ} → i ≤ j → j ≤ i → i ≡ j ≤→= {0} {0} z≤n z≤n = refl ≤→= {suc i} {suc j} (s≤s i<j) (s≤s j<i) = cong suc ( ≤→= {i} {j} i<j j<i ) px≤x : {x : ℕ } → pred x ≤ x px≤x {zero} = refl-≤ px≤x {suc x} = refl-≤s px≤py : {x y : ℕ } → x ≤ y → pred x ≤ pred y px≤py {zero} {zero} lt = refl-≤ px≤py {zero} {suc y} lt = z≤n px≤py {suc x} {suc y} (s≤s lt) = lt open import Data.Product i-j=0→i=j : {i j : ℕ } → j ≤ i → i - j ≡ 0 → i ≡ j i-j=0→i=j {zero} {zero} _ refl = refl i-j=0→i=j {zero} {suc j} () refl i-j=0→i=j {suc i} {zero} z≤n () i-j=0→i=j {suc i} {suc j} (s≤s lt) eq = cong suc (i-j=0→i=j {i} {j} lt eq) m*n=0⇒m=0∨n=0 : {i j : ℕ} → i * j ≡ 0 → (i ≡ 0) ∨ ( j ≡ 0 ) m*n=0⇒m=0∨n=0 {zero} {j} refl = case1 refl m*n=0⇒m=0∨n=0 {suc i} {zero} eq = case2 refl minus+1 : {x y : ℕ } → y ≤ x → suc (minus x y) ≡ minus (suc x) y minus+1 {zero} {zero} y≤x = refl minus+1 {suc x} {zero} y≤x = refl minus+1 {suc x} {suc y} (s≤s y≤x) = minus+1 {x} {y} y≤x minus+yz : {x y z : ℕ } → z ≤ y → x + minus y z ≡ minus (x + y) z minus+yz {zero} {y} {z} _ = refl minus+yz {suc x} {y} {z} z≤y = begin suc x + minus y z ≡⟨ cong suc ( minus+yz z≤y ) ⟩ suc (minus (x + y) z) ≡⟨ minus+1 {x + y} {z} (≤-trans z≤y (subst (λ g → y ≤ g) (+-comm y x) x≤x+y) ) ⟩ minus (suc x + y) z ∎ where open ≡-Reasoning minus<=0 : {x y : ℕ } → x ≤ y → minus x y ≡ 0 minus<=0 {0} {zero} z≤n = refl minus<=0 {0} {suc y} z≤n = refl minus<=0 {suc x} {suc y} (s≤s le) = minus<=0 {x} {y} le minus>0 : {x y : ℕ } → x < y → 0 < minus y x minus>0 {zero} {suc _} (s≤s z≤n) = s≤s z≤n minus>0 {suc x} {suc y} (s≤s lt) = minus>0 {x} {y} lt minus>0→x<y : {x y : ℕ } → 0 < minus y x → x < y minus>0→x<y {x} {y} lt with <-cmp x y ... | tri< a ¬b ¬c = a ... | tri≈ ¬a refl ¬c = ⊥-elim ( nat-≡< (sym (minus<=0 {x} ≤-refl)) lt ) ... | tri> ¬a ¬b c = ⊥-elim ( nat-≡< (sym (minus<=0 {y} (≤-trans refl-≤s c ))) lt ) minus+y-y : {x y : ℕ } → (x + y) - y ≡ x minus+y-y {zero} {y} = minus<=0 {zero + y} {y} ≤-refl minus+y-y {suc x} {y} = begin (suc x + y) - y ≡⟨ sym (minus+1 {_} {y} x≤y+x) ⟩ suc ((x + y) - y) ≡⟨ cong suc (minus+y-y {x} {y}) ⟩ suc x ∎ where open ≡-Reasoning minus+yx-yz : {x y z : ℕ } → (y + x) - (y + z) ≡ x - z minus+yx-yz {x} {zero} {z} = refl minus+yx-yz {x} {suc y} {z} = minus+yx-yz {x} {y} {z} minus+xy-zy : {x y z : ℕ } → (x + y) - (z + y) ≡ x - z minus+xy-zy {x} {y} {z} = subst₂ (λ j k → j - k ≡ x - z ) (+-comm y x) (+-comm y z) (minus+yx-yz {x} {y} {z}) y-x<y : {x y : ℕ } → 0 < x → 0 < y → y - x < y y-x<y {x} {y} 0<x 0<y with <-cmp x (suc y) ... | tri< a ¬b ¬c = +-cancelʳ-< {x} (y - x) y ( begin suc ((y - x) + x) ≡⟨ cong suc (minus+n {y} {x} a ) ⟩ suc y ≡⟨ +-comm 1 _ ⟩ y + suc 0 ≤⟨ +-mono-≤ ≤-refl 0<x ⟩ y + x ∎ ) where open ≤-Reasoning ... | tri≈ ¬a refl ¬c = subst ( λ k → k < y ) (sym (minus<=0 {y} {x} refl-≤s )) 0<y ... | tri> ¬a ¬b c = subst ( λ k → k < y ) (sym (minus<=0 {y} {x} (≤-trans (≤-trans refl-≤s refl-≤s) c))) 0<y -- suc (suc y) ≤ x → y ≤ x open import Relation.Binary.Definitions distr-minus-* : {x y z : ℕ } → (minus x y) * z ≡ minus (x * z) (y * z) distr-minus-* {x} {zero} {z} = refl distr-minus-* {x} {suc y} {z} with <-cmp x y distr-minus-* {x} {suc y} {z} | tri< a ¬b ¬c = begin minus x (suc y) * z ≡⟨ cong (λ k → k * z ) (minus<=0 {x} {suc y} (x<y→≤ a)) ⟩ 0 * z ≡⟨ sym (minus<=0 {x * z} {z + y * z} le ) ⟩ minus (x * z) (z + y * z) ∎ where open ≡-Reasoning le : x * z ≤ z + y * z le = ≤-trans lemma (subst (λ k → y * z ≤ k ) (+-comm _ z ) (x≤x+y {y * z} {z} ) ) where lemma : x * z ≤ y * z lemma = *≤ {x} {y} {z} (<to≤ a) distr-minus-* {x} {suc y} {z} | tri≈ ¬a refl ¬c = begin minus x (suc y) * z ≡⟨ cong (λ k → k * z ) (minus<=0 {x} {suc y} refl-≤s ) ⟩ 0 * z ≡⟨ sym (minus<=0 {x * z} {z + y * z} (lt {x} {z} )) ⟩ minus (x * z) (z + y * z) ∎ where open ≡-Reasoning lt : {x z : ℕ } → x * z ≤ z + x * z lt {zero} {zero} = z≤n lt {suc x} {zero} = lt {x} {zero} lt {x} {suc z} = ≤-trans lemma refl-≤s where lemma : x * suc z ≤ z + x * suc z lemma = subst (λ k → x * suc z ≤ k ) (+-comm _ z) (x≤x+y {x * suc z} {z}) distr-minus-* {x} {suc y} {z} | tri> ¬a ¬b c = +m= {_} {_} {suc y * z} ( begin minus x (suc y) * z + suc y * z ≡⟨ sym (proj₂ *-distrib-+ z (minus x (suc y) ) _) ⟩ ( minus x (suc y) + suc y ) * z ≡⟨ cong (λ k → k * z) (minus+n {x} {suc y} (s≤s c)) ⟩ x * z ≡⟨ sym (minus+n {x * z} {suc y * z} (s≤s (lt c))) ⟩ minus (x * z) (suc y * z) + suc y * z ∎ ) where open ≡-Reasoning lt : {x y z : ℕ } → suc y ≤ x → z + y * z ≤ x * z lt {x} {y} {z} le = *≤ le distr-minus-*' : {z x y : ℕ } → z * (minus x y) ≡ minus (z * x) (z * y) distr-minus-*' {z} {x} {y} = begin z * (minus x y) ≡⟨ *-comm _ (x - y) ⟩ (minus x y) * z ≡⟨ distr-minus-* {x} {y} {z} ⟩ minus (x * z) (y * z) ≡⟨ cong₂ (λ j k → j - k ) (*-comm x z ) (*-comm y z) ⟩ minus (z * x) (z * y) ∎ where open ≡-Reasoning minus- : {x y z : ℕ } → suc x > z + y → minus (minus x y) z ≡ minus x (y + z) minus- {x} {y} {z} gt = +m= {_} {_} {z} ( begin minus (minus x y) z + z ≡⟨ minus+n {_} {z} lemma ⟩ minus x y ≡⟨ +m= {_} {_} {y} ( begin minus x y + y ≡⟨ minus+n {_} {y} lemma1 ⟩ x ≡⟨ sym ( minus+n {_} {z + y} gt ) ⟩ minus x (z + y) + (z + y) ≡⟨ sym ( +-assoc (minus x (z + y)) _ _ ) ⟩ minus x (z + y) + z + y ∎ ) ⟩ minus x (z + y) + z ≡⟨ cong (λ k → minus x k + z ) (+-comm _ y ) ⟩ minus x (y + z) + z ∎ ) where open ≡-Reasoning lemma1 : suc x > y lemma1 = x+y<z→x<z (subst (λ k → k < suc x ) (+-comm z _ ) gt ) lemma : suc (minus x y) > z lemma = <-minus {_} {_} {y} ( subst ( λ x → z + y < suc x ) (sym (minus+n {x} {y} lemma1 )) gt ) minus-* : {M k n : ℕ } → n < k → minus k (suc n) * M ≡ minus (minus k n * M ) M minus-* {zero} {k} {n} lt = begin minus k (suc n) * zero ≡⟨ *-comm (minus k (suc n)) zero ⟩ zero * minus k (suc n) ≡⟨⟩ 0 * minus k n ≡⟨ *-comm 0 (minus k n) ⟩ minus (minus k n * 0 ) 0 ∎ where open ≡-Reasoning minus-* {suc m} {k} {n} lt with <-cmp k 1 minus-* {suc m} {.0} {zero} lt | tri< (s≤s z≤n) ¬b ¬c = refl minus-* {suc m} {.0} {suc n} lt | tri< (s≤s z≤n) ¬b ¬c = refl minus-* {suc zero} {.1} {zero} lt | tri≈ ¬a refl ¬c = refl minus-* {suc (suc m)} {.1} {zero} lt | tri≈ ¬a refl ¬c = minus-* {suc m} {1} {zero} lt minus-* {suc m} {.1} {suc n} (s≤s ()) | tri≈ ¬a refl ¬c minus-* {suc m} {k} {n} lt | tri> ¬a ¬b c = begin minus k (suc n) * M ≡⟨ distr-minus-* {k} {suc n} {M} ⟩ minus (k * M ) ((suc n) * M) ≡⟨⟩ minus (k * M ) (M + n * M ) ≡⟨ cong (λ x → minus (k * M) x) (+-comm M _ ) ⟩ minus (k * M ) ((n * M) + M ) ≡⟨ sym ( minus- {k * M} {n * M} (lemma lt) ) ⟩ minus (minus (k * M ) (n * M)) M ≡⟨ cong (λ x → minus x M ) ( sym ( distr-minus-* {k} {n} )) ⟩ minus (minus k n * M ) M ∎ where M = suc m lemma : {n k m : ℕ } → n < k → suc (k * suc m) > suc m + n * suc m lemma {zero} {suc k} {m} (s≤s lt) = s≤s (s≤s (subst (λ x → x ≤ m + k * suc m) (+-comm 0 _ ) x≤x+y )) lemma {suc n} {suc k} {m} lt = begin suc (suc m + suc n * suc m) ≡⟨⟩ suc ( suc (suc n) * suc m) ≤⟨ ≤-plus-0 {_} {_} {1} (*≤ lt ) ⟩ suc (suc k * suc m) ∎ where open ≤-Reasoning open ≡-Reasoning x=y+z→x-z=y : {x y z : ℕ } → x ≡ y + z → x - z ≡ y x=y+z→x-z=y {x} {zero} {.x} refl = minus<=0 {x} {x} refl-≤ -- x ≡ suc (y + z) → (x ≡ y + z → x - z ≡ y) → (x - z) ≡ suc y x=y+z→x-z=y {suc x} {suc y} {zero} eq = begin -- suc x ≡ suc (y + zero) → (suc x - zero) ≡ suc y suc x - zero ≡⟨ refl ⟩ suc x ≡⟨ eq ⟩ suc y + zero ≡⟨ +-comm _ zero ⟩ suc y ∎ where open ≡-Reasoning x=y+z→x-z=y {suc x} {suc y} {suc z} eq = x=y+z→x-z=y {x} {suc y} {z} ( begin x ≡⟨ cong pred eq ⟩ pred (suc y + suc z) ≡⟨ +-comm _ (suc z) ⟩ suc z + y ≡⟨ cong suc ( +-comm _ y ) ⟩ suc y + z ∎ ) where open ≡-Reasoning m*1=m : {m : ℕ } → m * 1 ≡ m m*1=m {zero} = refl m*1=m {suc m} = cong suc m*1=m record Finduction {n m : Level} (P : Set n ) (Q : P → Set m ) (f : P → ℕ) : Set (n Level.⊔ m) where field fzero : {p : P} → f p ≡ zero → Q p pnext : (p : P ) → P decline : {p : P} → 0 < f p → f (pnext p) < f p ind : {p : P} → Q (pnext p) → Q p y<sx→y≤x : {x y : ℕ} → y < suc x → y ≤ x y<sx→y≤x (s≤s lt) = lt fi0 : (x : ℕ) → x ≤ zero → x ≡ zero fi0 .0 z≤n = refl f-induction : {n m : Level} {P : Set n } → {Q : P → Set m } → (f : P → ℕ) → Finduction P Q f → (p : P ) → Q p f-induction {n} {m} {P} {Q} f I p with <-cmp 0 (f p) ... | tri> ¬a ¬b () ... | tri≈ ¬a b ¬c = Finduction.fzero I (sym b) ... | tri< lt _ _ = f-induction0 p (f p) (<to≤ (Finduction.decline I lt)) where f-induction0 : (p : P) → (x : ℕ) → (f (Finduction.pnext I p)) ≤ x → Q p f-induction0 p zero le = Finduction.ind I (Finduction.fzero I (fi0 _ le)) where f-induction0 p (suc x) le with <-cmp (f (Finduction.pnext I p)) (suc x) ... | tri< (s≤s a) ¬b ¬c = f-induction0 p x a ... | tri≈ ¬a b ¬c = Finduction.ind I (f-induction0 (Finduction.pnext I p) x (y<sx→y≤x f1)) where f1 : f (Finduction.pnext I (Finduction.pnext I p)) < suc x f1 = subst (λ k → f (Finduction.pnext I (Finduction.pnext I p)) < k ) b ( Finduction.decline I {Finduction.pnext I p} (subst (λ k → 0 < k ) (sym b) (s≤s z≤n ) )) ... | tri> ¬a ¬b c = ⊥-elim ( nat-≤> le c ) record Ninduction {n m : Level} (P : Set n ) (Q : P → Set m ) (f : P → ℕ) : Set (n Level.⊔ m) where field pnext : (p : P ) → P fzero : {p : P} → f (pnext p) ≡ zero → Q p decline : {p : P} → 0 < f p → f (pnext p) < f p ind : {p : P} → Q (pnext p) → Q p s≤s→≤ : { i j : ℕ} → suc i ≤ suc j → i ≤ j s≤s→≤ (s≤s lt) = lt n-induction : {n m : Level} {P : Set n } → {Q : P → Set m } → (f : P → ℕ) → Ninduction P Q f → (p : P ) → Q p n-induction {n} {m} {P} {Q} f I p = f-induction0 p (f (Ninduction.pnext I p)) ≤-refl where f-induction0 : (p : P) → (x : ℕ) → (f (Ninduction.pnext I p)) ≤ x → Q p f-induction0 p zero lt = Ninduction.fzero I {p} (fi0 _ lt) f-induction0 p (suc x) le with <-cmp (f (Ninduction.pnext I p)) (suc x) ... | tri< (s≤s a) ¬b ¬c = f-induction0 p x a ... | tri≈ ¬a b ¬c = Ninduction.ind I (f-induction0 (Ninduction.pnext I p) x (s≤s→≤ nle) ) where f>0 : 0 < f (Ninduction.pnext I p) f>0 = subst (λ k → 0 < k ) (sym b) ( s≤s z≤n ) nle : suc (f (Ninduction.pnext I (Ninduction.pnext I p))) ≤ suc x nle = subst (λ k → suc (f (Ninduction.pnext I (Ninduction.pnext I p))) ≤ k) b (Ninduction.decline I {Ninduction.pnext I p} f>0 ) ... | tri> ¬a ¬b c = ⊥-elim ( nat-≤> le c )
{ "alphanum_fraction": 0.4259694798, "avg_line_length": 38.1691022965, "ext": "agda", "hexsha": "e4c7a928c285f2a9dbf69c84a9fe41c86b1cd5aa", "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/nat.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/nat.agda", "max_line_length": 136, "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/nat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 8949, "size": 18283 }
-- Andreas, 2021-04-21, issue #5334 -- Improve sorting of constructors to data for interleaved mutual blocks. {-# OPTIONS --allow-unsolved-metas #-} module Issue5334 where module Works where data Nat : Set where zero : Nat data Fin : Nat → Set where zero : Fin {!!} interleaved mutual data Nat : Set data Fin : Nat → Set data _ where zero : Nat data _ where zero : Fin {!!} -- should work -- Error was: -- Could not find a matching data signature for constructor zero -- There was no candidate.
{ "alphanum_fraction": 0.6685499058, "avg_line_length": 19.6666666667, "ext": "agda", "hexsha": "7c9e0252a98b78ae3c4e70a38aebf8acf8ecf44d", "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/Issue5334.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/Issue5334.agda", "max_line_length": 73, "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/Issue5334.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": 143, "size": 531 }
module Metaprog2016 where open import Data.List using (List) renaming ([] to ⌀) open import Data.Maybe using (Maybe) open import Data.Product using (_×_) open import Data.Unit using () renaming (⊤ to 𝟙) -- TOWARDS INTENSIONAL ANALYSIS OF SYNTAX -- -- Miëtek Bak -- [email protected] -- -- http://github.com/mietek/metaprog2016 -- -- International Summer School on Metaprogramming -- Robinson College, Cambridge, 8th to 12th August 2016 -- Consider a basic fragment of intuitionistic modal logic S4 (IS4). data Type : Set where _▻_ : Type → Type → Type _∧_ : Type → Type → Type ⊤ : Type □_ : Type → Type postulate _⊢_ : List Type → Type → Set -- IS4 provides the logical foundations for MetaML. -- Sheard (2001) reminds us that MetaML only allows syntax to be constructed -- and executed at runtime. Observation and decomposition is not supported. -- -- “Accomplishments and research challenges in meta-programming” -- http://dx.doi.org/10.1007/3-540-44806-3_2 postulate • : Type yes : ∀ {Γ} → Γ ⊢ • no : ∀ {Γ} → Γ ⊢ • isApp : ∀ {Γ A} → Γ ⊢ ((□ A) ▻ •) -- Has anyone built a typed system supporting intensional analysis of syntax? -- I don’t know, but Gabbay and Nanevski (2012) come close. They give a -- Tarski-style semantics for IS4, reading “□ A” as “closed syntax of type A”. -- -- “Denotation of contextual modal type theory: Syntax and meta-programming” -- http://dx.doi.org/10.1016/j.jal.2012.07.002 module GabbayNanevski2012 where ⊨_ : Type → Set ⊨ (A ▻ B) = ⊨ A → ⊨ B ⊨ (A ∧ B) = (⊨ A) × (⊨ B) ⊨ ⊤ = 𝟙 ⊨ (□ A) = (⌀ ⊢ A) × (⊨ A) -- Can we construct a proof of completeness with respect to this semantics -- and obtain normalisation by evaluation (NbE) for IS4? -- Yes, we can! As long as we also take from Coquand and Dybjer (1997). -- -- “Intuitionistic model constructions and normalization proofs” -- http://dx.doi.org/10.1017/S0960129596002150 module CoquandDybjer1997GabbayNanevski2012 where ⊨_ : Type → Set ⊨ (A ▻ B) = (⌀ ⊢ (A ▻ B)) × (⊨ A → ⊨ B) ⊨ (A ∧ B) = (⊨ A) × (⊨ B) ⊨ ⊤ = 𝟙 ⊨ (□ A) = (⌀ ⊢ A) × (⊨ A) -- Could we perhaps read “□ A” as “open syntax of type A”? -- I don’t know, but I’ve had an idea about that... postulate _⊆_ : List Type → List Type → Set module ??? where _⊨_ : List Type → Type → Set Δ ⊨ (A ▻ B) = ∀ {Δ′} → Δ ⊆ Δ′ → Δ′ ⊨ A → Δ′ ⊨ B Δ ⊨ (A ∧ B) = (Δ ⊨ A) × (Δ ⊨ B) Δ ⊨ ⊤ = 𝟙 Δ ⊨ (□ A) = ∀ {Δ′} → Δ ⊆ Δ′ → (Δ′ ⊢ A) × (Δ′ ⊨ A) -- Does this look suspiciously like a Kripke-style possible worlds semantics? -- Yes, it does! We can find one of these in Alechina et al. (2001). -- -- “Categorical and Kripke semantics for constructive S4 modal logic” -- http://dx.doi.org/10.1007/3-540-44802-0_21 postulate World : Set _≤_ : World → World → Set _R_ : World → World → Set module AlechinaMendlerDePaivaRitter2001 where _⊩_ : World → Type → Set w ⊩ (A ▻ B) = ∀ {w′} → w ≤ w′ → w′ ⊩ A → w′ ⊩ B w ⊩ (A ∧ B) = (w ⊩ A) × (w ⊩ B) w ⊩ ⊤ = 𝟙 w ⊩ (□ A) = ∀ {w′} → w ≤ w′ → ∀ {v′} → w′ R v′ → v′ ⊩ A -- Has anyone constructed a proof of completeness with respect to a -- Kripke-style semantics for IS4? -- I haven’t found one, and I’ve tried five. -- v′ w″ → v″ w″ -- ◌───R───● → ◌───────R───────● -- │ → │ -- ≤ ξ′,ζ′ → │ -- v │ → │ -- ◌───R───● → ≤ -- │ w′ → │ -- ≤ ξ,ζ → │ -- │ → │ -- ● → ● -- w → w -- How do we go from being able to talk about open syntax to being able -- to intensionally analyse syntax at runtime? -- I don’t know, but I’ve noticed a funny coincidence... -- -- Work in progress: -- http://github.com/mietek/hilbert-gentzen -- FIN
{ "alphanum_fraction": 0.5553830228, "avg_line_length": 23.8518518519, "ext": "agda", "hexsha": "dbfe319067060c8fc3e57f1b7f2873b43caf80a0", "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": "2c74cfd2d23d7eddea1774a1d8a5916ad4b23380", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/metaprog2016", "max_forks_repo_path": "Metaprog2016.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2c74cfd2d23d7eddea1774a1d8a5916ad4b23380", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/metaprog2016", "max_issues_repo_path": "Metaprog2016.agda", "max_line_length": 78, "max_stars_count": 2, "max_stars_repo_head_hexsha": "2c74cfd2d23d7eddea1774a1d8a5916ad4b23380", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/metaprog2016", "max_stars_repo_path": "Metaprog2016.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:10:19.000Z", "max_stars_repo_stars_event_min_datetime": "2016-08-13T21:42:22.000Z", "num_tokens": 1443, "size": 3864 }
module _ where record Structure : Set1 where infixl 20 _×_ infix 8 _⟶_ infixl 20 _,_ infixr 40 _∘_ infix 5 _~_ field Type : Set _×_ : Type → Type → Type _⟶_ : Type → Type → Set _∘_ : ∀ {X Y Z} → Y ⟶ Z → X ⟶ Y → X ⟶ Z _,_ : ∀ {X A B} → X ⟶ A → X ⟶ B → X ⟶ A × B π₁ : ∀ {A B} → A × B ⟶ A π₂ : ∀ {A B} → A × B ⟶ B Op3 : ∀ {X} → X × X × X ⟶ X _~_ : ∀ {X Y} → X ⟶ Y → X ⟶ Y → Set record Map {{C : Structure}} {{D : Structure}} : Set1 where open Structure {{...}} field Ty⟦_⟧ : Structure.Type C → Structure.Type D Tm⟦_⟧ : ∀ {X A} → X ⟶ A → Ty⟦ X ⟧ ⟶ Ty⟦ A ⟧ ×-inv : ∀ {X A} → Ty⟦ X ⟧ × Ty⟦ A ⟧ ⟶ Ty⟦ X × A ⟧ ⟦Op3⟧ : ∀ {X} → Tm⟦ Op3 {X = X} ⟧ ∘ ×-inv ∘ (×-inv ∘ (π₁ ∘ π₁ , π₂ ∘ π₁) , π₂) ~ Op3
{ "alphanum_fraction": 0.4187256177, "avg_line_length": 22.6176470588, "ext": "agda", "hexsha": "0d1dd1d921c8d0957b3eae149425ffc660d8ec8e", "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/Issue1952.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/Issue1952.agda", "max_line_length": 88, "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/Issue1952.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": 391, "size": 769 }
-- Andreas, 2016-01-19, issue raised by Twey -- {-# OPTIONS -v 10 #-} {-# OPTIONS --allow-unsolved-metas #-} Rel : Set → Set₁ Rel A = A → A → Set record Category : Set₁ where field Obj : Set _⇒_ : Rel Obj -- unfolding the definition of Rel removes the error record Product (C : Category) (A B : Category.Obj C) : Set where field A×B : Category.Obj C postulate anything : ∀{a}{A : Set a} → A trivial : ∀ {C} → Category.Obj C → Set trivial _ = anything map-obj : ∀ {P : _} → trivial (Product.A×B P) -- Note: hole _ cannot be filled map-obj = anything {- Error thrown during printing open metas: piApply t = Rel _24 Def Issue1783.Rel [Apply []r(MetaV (MetaId 24) [])]} args = @0 [[]r{Var 0 []}] An internal error has occurred. Please report this as a bug. Location of the error: src/full/Agda/TypeChecking/Substitute.hs:382 -}
{ "alphanum_fraction": 0.6397228637, "avg_line_length": 25.4705882353, "ext": "agda", "hexsha": "36ebcec936f5bc8501c9b996726730703d471900", "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/Issue1783.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/Issue1783.agda", "max_line_length": 78, "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/Issue1783.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": 277, "size": 866 }
{- This file introduces the "powerset" of a type in the style of Escardó's lecture notes: https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#propositionalextensionality -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Foundations.Powerset where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Structure open import Cubical.Foundations.Function open import Cubical.Foundations.Univalence using (hPropExt) open import Cubical.Data.Sigma private variable ℓ : Level X : Type ℓ ℙ : Type ℓ → Type (ℓ-suc ℓ) ℙ X = X → hProp _ infix 5 _∈_ _∈_ : {X : Type ℓ} → X → ℙ X → Type ℓ x ∈ A = ⟨ A x ⟩ _⊆_ : {X : Type ℓ} → ℙ X → ℙ X → Type ℓ A ⊆ B = ∀ x → x ∈ A → x ∈ B ∈-isProp : (A : ℙ X) (x : X) → isProp (x ∈ A) ∈-isProp A = snd ∘ A ⊆-isProp : (A B : ℙ X) → isProp (A ⊆ B) ⊆-isProp A B = isPropΠ2 (λ x _ → ∈-isProp B x) ⊆-refl : (A : ℙ X) → A ⊆ A ⊆-refl A x = idfun (x ∈ A) ⊆-refl-consequence : (A B : ℙ X) → A ≡ B → (A ⊆ B) × (B ⊆ A) ⊆-refl-consequence A B p = subst (A ⊆_) p (⊆-refl A) , subst (B ⊆_) (sym p) (⊆-refl B) ⊆-extensionality : (A B : ℙ X) → (A ⊆ B) × (B ⊆ A) → A ≡ B ⊆-extensionality A B (φ , ψ) = funExt (λ x → TypeOfHLevel≡ 1 (hPropExt (A x .snd) (B x .snd) (φ x) (ψ x))) powersets-are-sets : isSet (ℙ X) powersets-are-sets = isSetΠ (λ _ → isSetHProp) ⊆-extensionalityEquiv : (A B : ℙ X) → (A ⊆ B) × (B ⊆ A) ≃ (A ≡ B) ⊆-extensionalityEquiv A B = isoToEquiv (iso (⊆-extensionality A B) (⊆-refl-consequence A B) (λ _ → powersets-are-sets A B _ _) (λ _ → isPropΣ (⊆-isProp A B) (λ _ → ⊆-isProp B A) _ _))
{ "alphanum_fraction": 0.5699893955, "avg_line_length": 29.9365079365, "ext": "agda", "hexsha": "6ce7c884b5c612cb05330f991ffd423d43b1261b", "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/Foundations/Powerset.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Foundations/Powerset.agda", "max_line_length": 106, "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/Foundations/Powerset.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 764, "size": 1886 }
{-# OPTIONS --safe #-} module Issue2792.Safe where
{ "alphanum_fraction": 0.6730769231, "avg_line_length": 13, "ext": "agda", "hexsha": "eb13d9b247790a9891eff3283178bbf6cbaea7ad", "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/Issue2792/Safe.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/Issue2792/Safe.agda", "max_line_length": 27, "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/Issue2792/Safe.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": 12, "size": 52 }
{-# OPTIONS --without-K --exact-split --safe #-} open import Fragment.Algebra.Signature module Fragment.Algebra.Algebra (Σ : Signature) where open import Level using (Level; _⊔_; suc) open import Data.Vec using (Vec) open import Data.Vec.Relation.Binary.Pointwise.Inductive using (Pointwise) open import Relation.Binary using (Setoid; Rel; IsEquivalence) private variable a ℓ : Level module _ (S : Setoid a ℓ) where open import Data.Vec.Relation.Binary.Equality.Setoid S using (_≋_) open Setoid S renaming (Carrier to A) Interpretation : Set a Interpretation = ∀ {arity} → (f : ops Σ arity) → Vec A arity → A Congruence : Interpretation → Set (a ⊔ ℓ) Congruence ⟦_⟧ = ∀ {arity} → (f : ops Σ arity) → ∀ {xs ys} → Pointwise _≈_ xs ys → ⟦ f ⟧ xs ≈ ⟦ f ⟧ ys record IsAlgebra : Set (a ⊔ ℓ) where field ⟦_⟧ : Interpretation ⟦⟧-cong : Congruence ⟦_⟧ record Algebra : Set (suc a ⊔ suc ℓ) where constructor algebra field ∥_∥/≈ : Setoid a ℓ ∥_∥/≈-isAlgebra : IsAlgebra ∥_∥/≈ ∥_∥ : Set a ∥_∥ = Setoid.Carrier ∥_∥/≈ infix 10 _⟦_⟧_ _⟦_⟧_ : Interpretation (∥_∥/≈) _⟦_⟧_ = IsAlgebra.⟦_⟧ ∥_∥/≈-isAlgebra _⟦_⟧-cong : Congruence (∥_∥/≈) (_⟦_⟧_) _⟦_⟧-cong = IsAlgebra.⟦⟧-cong ∥_∥/≈-isAlgebra ≈[_] : Rel ∥_∥ ℓ ≈[_] = Setoid._≈_ ∥_∥/≈ ≈[_]-isEquivalence : IsEquivalence ≈[_] ≈[_]-isEquivalence = Setoid.isEquivalence ∥_∥/≈ open Algebra public infix 5 ≈-syntax ≈-syntax : (A : Algebra {a} {ℓ}) → ∥ A ∥ → ∥ A ∥ → Set ℓ ≈-syntax A x y = Setoid._≈_ ∥ A ∥/≈ x y syntax ≈-syntax A x y = x =[ A ] y
{ "alphanum_fraction": 0.5978934325, "avg_line_length": 24.4545454545, "ext": "agda", "hexsha": "ca3b4764d5839912a046027ff6147b038f81c38c", "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/Algebra/Algebra.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/Algebra/Algebra.agda", "max_line_length": 74, "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/Algebra/Algebra.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": 680, "size": 1614 }
{- This type ℕ₋₂ was originally used as the index to n-truncation in order to be consistent with the notation in the HoTT book. However, ℕ was already being used as an analogous index in Foundations.HLevels, and it became clear that having two different indexing schemes for truncation levels was very inconvenient. In the end, having slightly nicer notation was not worth the hassle of having to use this type everywhere where truncation levels were needed. So for this library, use the type `HLevel = ℕ` instead. See the discussions below for more context: - https://github.com/agda/cubical/issues/266 - https://github.com/agda/cubical/pull/238 -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Experiments.NatMinusTwo where open import Cubical.Experiments.NatMinusTwo.Base public open import Cubical.Experiments.NatMinusTwo.Properties public open import Cubical.Experiments.NatMinusTwo.ToNatMinusOne using (1+_; ℕ₋₁→ℕ₋₂; -1+Path) public
{ "alphanum_fraction": 0.7699293643, "avg_line_length": 45.0454545455, "ext": "agda", "hexsha": "ab4d034b278456249d6c43968fa4bfdbe633d4d2", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Experiments/NatMinusTwo.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Experiments/NatMinusTwo.agda", "max_line_length": 94, "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/NatMinusTwo.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 253, "size": 991 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category -- Mainly *properties* of isomorphisms, and a lot of other things too -- TODO: split things up more semantically? module Categories.Morphism.Isomorphism {o ℓ e} (𝒞 : Category o ℓ e) where open import Level using (_⊔_) open import Function using (flip) open import Data.Product using (_,_) open import Relation.Binary using (Rel; _Preserves_⟶_; IsEquivalence) open import Relation.Binary.Construct.Closure.Transitive open import Relation.Binary.PropositionalEquality as ≡ using (_≡_) import Categories.Category.Construction.Core as Core open import Categories.Category.Groupoid using (IsGroupoid) import Categories.Category.Groupoid.Properties as GroupoidProps import Categories.Morphism as Morphism import Categories.Morphism.Properties as MorphismProps import Categories.Morphism.IsoEquiv as IsoEquiv import Categories.Category.Construction.Path as Path open Core 𝒞 using (Core; Core-isGroupoid; CoreGroupoid) open Morphism 𝒞 open MorphismProps 𝒞 open IsoEquiv 𝒞 using (_≃_; ⌞_⌟) open Path 𝒞 import Categories.Morphism.Reasoning as MR open Category 𝒞 private module MCore where open IsGroupoid Core-isGroupoid public open GroupoidProps CoreGroupoid public open MorphismProps Core public open Morphism Core public open Path Core public variable A B C D E F : Obj open MCore using () renaming (_∘_ to _∘ᵢ_) public CommutativeIso = IsGroupoid.CommutativeSquare Core-isGroupoid -------------------- -- Also stuff about transitive closure ∘ᵢ-tc : A [ _≅_ ]⁺ B → A ≅ B ∘ᵢ-tc = MCore.∘-tc infix 4 _≃⁺_ _≃⁺_ : Rel (A [ _≅_ ]⁺ B) _ _≃⁺_ = MCore._≈⁺_ TransitiveClosure : Category _ _ _ TransitiveClosure = MCore.Path -------------------- -- some infrastructure setup in order to say something about morphisms and isomorphisms module _ where private data IsoPlus : A [ _⇒_ ]⁺ B → Set (o ⊔ ℓ ⊔ e) where [_] : {f : A ⇒ B} {g : B ⇒ A} → Iso f g → IsoPlus [ f ] _∼⁺⟨_⟩_ : ∀ A {f⁺ : A [ _⇒_ ]⁺ B} {g⁺ : B [ _⇒_ ]⁺ C} → IsoPlus f⁺ → IsoPlus g⁺ → IsoPlus (_ ∼⁺⟨ f⁺ ⟩ g⁺) open _≅_ ≅⁺⇒⇒⁺ : A [ _≅_ ]⁺ B → A [ _⇒_ ]⁺ B ≅⁺⇒⇒⁺ [ f ] = [ from f ] ≅⁺⇒⇒⁺ (_ ∼⁺⟨ f⁺ ⟩ f⁺′) = _ ∼⁺⟨ ≅⁺⇒⇒⁺ f⁺ ⟩ ≅⁺⇒⇒⁺ f⁺′ reverse : A [ _≅_ ]⁺ B → B [ _≅_ ]⁺ A reverse [ f ] = [ ≅.sym f ] reverse (_ ∼⁺⟨ f⁺ ⟩ f⁺′) = _ ∼⁺⟨ reverse f⁺′ ⟩ reverse f⁺ reverse⇒≅-sym : (f⁺ : A [ _≅_ ]⁺ B) → ∘ᵢ-tc (reverse f⁺) ≡ ≅.sym (∘ᵢ-tc f⁺) reverse⇒≅-sym [ f ] = ≡.refl reverse⇒≅-sym (_ ∼⁺⟨ f⁺ ⟩ f⁺′) = ≡.cong₂ (Morphism.≅.trans 𝒞) (reverse⇒≅-sym f⁺′) (reverse⇒≅-sym f⁺) TransitiveClosure-groupoid : IsGroupoid TransitiveClosure TransitiveClosure-groupoid = record { _⁻¹ = reverse ; iso = λ {_ _ f⁺} → record { isoˡ = isoˡ′ f⁺ ; isoʳ = isoʳ′ f⁺ } } where open MCore.HomReasoning isoˡ′ : (f⁺ : A [ _≅_ ]⁺ B) → ∘ᵢ-tc (reverse f⁺) ∘ᵢ ∘ᵢ-tc f⁺ ≃ ≅.refl isoˡ′ f⁺ = begin ∘ᵢ-tc (reverse f⁺) ∘ᵢ ∘ᵢ-tc f⁺ ≡⟨ ≡.cong (_∘ᵢ ∘ᵢ-tc f⁺) (reverse⇒≅-sym f⁺) ⟩ ≅.sym (∘ᵢ-tc f⁺) ∘ᵢ ∘ᵢ-tc f⁺ ≈⟨ MCore.iso.isoˡ ⟩ ≅.refl ∎ isoʳ′ : (f⁺ : A [ _≅_ ]⁺ B) → ∘ᵢ-tc f⁺ ∘ᵢ ∘ᵢ-tc (reverse f⁺) ≃ ≅.refl isoʳ′ f⁺ = begin ∘ᵢ-tc f⁺ ∘ᵢ ∘ᵢ-tc (reverse f⁺) ≡⟨ ≡.cong (∘ᵢ-tc f⁺ ∘ᵢ_) (reverse⇒≅-sym f⁺) ⟩ ∘ᵢ-tc f⁺ ∘ᵢ ≅.sym (∘ᵢ-tc f⁺) ≈⟨ MCore.iso.isoʳ ⟩ ≅.refl ∎ from-∘ᵢ-tc : (f⁺ : A [ _≅_ ]⁺ B) → from (∘ᵢ-tc f⁺) ≡ ∘-tc (≅⁺⇒⇒⁺ f⁺) from-∘ᵢ-tc [ f ] = ≡.refl from-∘ᵢ-tc (_ ∼⁺⟨ f⁺ ⟩ f⁺′) = ≡.cong₂ _∘_ (from-∘ᵢ-tc f⁺′) (from-∘ᵢ-tc f⁺) ≅*⇒⇒*-cong : ≅⁺⇒⇒⁺ {A} {B} Preserves _≃⁺_ ⟶ _≈⁺_ ≅*⇒⇒*-cong {_} {_} {f⁺} {g⁺} f⁺≃⁺g⁺ = begin ∘-tc (≅⁺⇒⇒⁺ f⁺) ≡˘⟨ from-∘ᵢ-tc f⁺ ⟩ from (∘ᵢ-tc f⁺) ≈⟨ _≃_.from-≈ f⁺≃⁺g⁺ ⟩ from (∘ᵢ-tc g⁺) ≡⟨ from-∘ᵢ-tc g⁺ ⟩ ∘-tc (≅⁺⇒⇒⁺ g⁺) ∎ where open HomReasoning ≅-shift : ∀ {f⁺ : A [ _≅_ ]⁺ B} {g⁺ : B [ _≅_ ]⁺ C} {h⁺ : A [ _≅_ ]⁺ C} → (_ ∼⁺⟨ f⁺ ⟩ g⁺) ≃⁺ h⁺ → g⁺ ≃⁺ (_ ∼⁺⟨ reverse f⁺ ⟩ h⁺) ≅-shift {f⁺ = f⁺} {g⁺ = g⁺} {h⁺ = h⁺} eq = begin ∘ᵢ-tc g⁺ ≈⟨ introʳ (I.isoʳ f⁺) ⟩ ∘ᵢ-tc g⁺ ∘ᵢ (∘ᵢ-tc f⁺ ∘ᵢ ∘ᵢ-tc (reverse f⁺)) ≈⟨ pullˡ eq ⟩ ∘ᵢ-tc h⁺ ∘ᵢ ∘ᵢ-tc (reverse f⁺) ∎ where open MCore.HomReasoning open MR Core module I {A B} (f⁺ : A [ _≅_ ]⁺ B) = Morphism.Iso (IsGroupoid.iso TransitiveClosure-groupoid {f = f⁺}) lift : ∀ {f⁺ : A [ _⇒_ ]⁺ B} → IsoPlus f⁺ → A [ _≅_ ]⁺ B lift [ iso ] = [ record { from = _ ; to = _ ; iso = iso } ] lift (_ ∼⁺⟨ iso ⟩ iso′) = _ ∼⁺⟨ lift iso ⟩ lift iso′ reduce-lift : ∀ {f⁺ : A [ _⇒_ ]⁺ B} (f′ : IsoPlus f⁺) → from (∘ᵢ-tc (lift f′)) ≡ ∘-tc f⁺ reduce-lift [ f ] = ≡.refl reduce-lift (_ ∼⁺⟨ f′ ⟩ f″) = ≡.cong₂ _∘_ (reduce-lift f″) (reduce-lift f′) lift-cong : ∀ {f⁺ g⁺ : A [ _⇒_ ]⁺ B} (f′ : IsoPlus f⁺) (g′ : IsoPlus g⁺) → f⁺ ≈⁺ g⁺ → lift f′ ≃⁺ lift g′ lift-cong {_} {_} {f⁺} {g⁺} f′ g′ eq = ⌞ from-≈′ ⌟ where open HomReasoning from-≈′ : from (∘ᵢ-tc (lift f′)) ≈ from (∘ᵢ-tc (lift g′)) from-≈′ = begin from (∘ᵢ-tc (lift f′)) ≡⟨ reduce-lift f′ ⟩ ∘-tc f⁺ ≈⟨ eq ⟩ ∘-tc g⁺ ≡˘⟨ reduce-lift g′ ⟩ from (∘ᵢ-tc (lift g′)) ∎ lift-triangle : {f : A ⇒ B} {g : C ⇒ A} {h : C ⇒ B} {k : B ⇒ C} {i : B ⇒ A} {j : A ⇒ C} → f ∘ g ≈ h → (f′ : Iso f i) → (g′ : Iso g j) → (h′ : Iso h k) → lift (_ ∼⁺⟨ [ g′ ] ⟩ [ f′ ]) ≃⁺ lift [ h′ ] lift-triangle eq f′ g′ h′ = lift-cong (_ ∼⁺⟨ [ g′ ] ⟩ [ f′ ]) [ h′ ] eq lift-square : {f : A ⇒ B} {g : C ⇒ A} {h : D ⇒ B} {i : C ⇒ D} {j : D ⇒ C} {a : B ⇒ A} {b : A ⇒ C} {c : B ⇒ D} → f ∘ g ≈ h ∘ i → (f′ : Iso f a) → (g′ : Iso g b) → (h′ : Iso h c) → (i′ : Iso i j) → lift (_ ∼⁺⟨ [ g′ ] ⟩ [ f′ ]) ≃⁺ lift (_ ∼⁺⟨ [ i′ ] ⟩ [ h′ ]) lift-square eq f′ g′ h′ i′ = lift-cong (_ ∼⁺⟨ [ g′ ] ⟩ [ f′ ]) (_ ∼⁺⟨ [ i′ ] ⟩ [ h′ ]) eq lift-pentagon : {f : A ⇒ B} {g : C ⇒ A} {h : D ⇒ C} {i : E ⇒ B} {j : D ⇒ E} {l : E ⇒ D} {a : B ⇒ A} {b : A ⇒ C} {c : C ⇒ D} {d : B ⇒ E} → f ∘ g ∘ h ≈ i ∘ j → (f′ : Iso f a) → (g′ : Iso g b) → (h′ : Iso h c) → (i′ : Iso i d) → (j′ : Iso j l) → lift (_ ∼⁺⟨ _ ∼⁺⟨ [ h′ ] ⟩ [ g′ ] ⟩ [ f′ ]) ≃⁺ lift (_ ∼⁺⟨ [ j′ ] ⟩ [ i′ ]) lift-pentagon eq f′ g′ h′ i′ j′ = lift-cong (_ ∼⁺⟨ _ ∼⁺⟨ [ h′ ] ⟩ [ g′ ] ⟩ [ f′ ]) (_ ∼⁺⟨ [ j′ ] ⟩ [ i′ ]) eq module _ where open _≅_ -- projecting isomorphism commutations to morphism commutations project-triangle : {g : A ≅ B} {f : C ≅ A} {h : C ≅ B} → g ∘ᵢ f ≃ h → from g ∘ from f ≈ from h project-triangle = _≃_.from-≈ project-square : {g : A ≅ B} {f : C ≅ A} {i : D ≅ B} {h : C ≅ D} → g ∘ᵢ f ≃ i ∘ᵢ h → from g ∘ from f ≈ from i ∘ from h project-square = _≃_.from-≈ -- direct lifting from morphism commutations to isomorphism commutations lift-triangle′ : {f : A ≅ B} {g : C ≅ A} {h : C ≅ B} → from f ∘ from g ≈ from h → f ∘ᵢ g ≃ h lift-triangle′ = ⌞_⌟ lift-square′ : {f : A ≅ B} {g : C ≅ A} {h : D ≅ B} {i : C ≅ D} → from f ∘ from g ≈ from h ∘ from i → f ∘ᵢ g ≃ h ∘ᵢ i lift-square′ = ⌞_⌟ lift-pentagon′ : {f : A ≅ B} {g : C ≅ A} {h : D ≅ C} {i : E ≅ B} {j : D ≅ E} → from f ∘ from g ∘ from h ≈ from i ∘ from j → f ∘ᵢ g ∘ᵢ h ≃ i ∘ᵢ j lift-pentagon′ = ⌞_⌟ open MR Core open MCore using (_⁻¹) open MCore.HomReasoning open MR.GroupoidR _ Core-isGroupoid squares×≃⇒≃ : {f f′ : A ≅ B} {g : A ≅ C} {h : B ≅ D} {i i′ : C ≅ D} → CommutativeIso f g h i → CommutativeIso f′ g h i′ → i ≃ i′ → f ≃ f′ squares×≃⇒≃ sq₁ sq₂ eq = MCore.isos×≈⇒≈ eq helper₁ (MCore.≅.sym helper₂) sq₁ sq₂ where helper₁ = record { iso = MCore.iso } helper₂ = record { iso = MCore.iso } -- imagine a triangle prism, if all the sides and the top face commute, the bottom face commute. triangle-prism : {i′ : A ≅ B} {f′ : C ≅ A} {h′ : C ≅ B} {i : D ≅ E} {j : D ≅ A} {k : E ≅ B} {f : F ≅ D} {g : F ≅ C} {h : F ≅ E} → i′ ∘ᵢ f′ ≃ h′ → CommutativeIso i j k i′ → CommutativeIso f g j f′ → CommutativeIso h g k h′ → i ∘ᵢ f ≃ h triangle-prism {i′ = i′} {f′} {_} {i} {_} {k} {f} {g} {_} eq sq₁ sq₂ sq₃ = squares×≃⇒≃ glued sq₃ eq where glued : CommutativeIso (i ∘ᵢ f) g k (i′ ∘ᵢ f′) glued = sym (glue (sym sq₁) (sym sq₂)) elim-triangleˡ : {f : A ≅ B} {g : C ≅ A} {h : D ≅ C} {i : D ≅ B} {j : D ≅ A} → f ∘ᵢ g ∘ᵢ h ≃ i → f ∘ᵢ j ≃ i → g ∘ᵢ h ≃ j elim-triangleˡ perim tri = MCore.mono _ _ (perim ○ ⟺ tri) elim-triangleˡ′ : {f : A ≅ B} {g : C ≅ A} {h : D ≅ C} {i : D ≅ B} {j : C ≅ B} → f ∘ᵢ g ∘ᵢ h ≃ i → j ∘ᵢ h ≃ i → f ∘ᵢ g ≃ j elim-triangleˡ′ {f = f} {g} {h} {i} {j} perim tri = MCore.epi _ _ ( begin (f ∘ᵢ g) ∘ᵢ h ≈⟨ MCore.assoc ⟩ f ∘ᵢ g ∘ᵢ h ≈⟨ perim ⟩ i ≈˘⟨ tri ⟩ j ∘ᵢ h ∎ ) cut-squareʳ : {g : A ≅ B} {f : A ≅ C} {h : B ≅ D} {i : C ≅ D} {j : B ≅ C} → CommutativeIso g f h i → i ∘ᵢ j ≃ h → j ∘ᵢ g ≃ f cut-squareʳ {g = g} {f = f} {h = h} {i = i} {j = j} sq tri = begin j ∘ᵢ g ≈⟨ switch-fromtoˡ′ {f = i} {h = j} {k = h} tri ⟩∘⟨ refl ⟩ (i ⁻¹ ∘ᵢ h) ∘ᵢ g ≈⟨ MCore.assoc ⟩ i ⁻¹ ∘ᵢ h ∘ᵢ g ≈˘⟨ switch-fromtoˡ′ {f = i} {h = f} {k = h ∘ᵢ g} (sym sq) ⟩ f ∎
{ "alphanum_fraction": 0.4737914032, "avg_line_length": 38.3909465021, "ext": "agda", "hexsha": "30247f1c71fc41f4646ba2b2580197b6d419e987", "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/Morphism/Isomorphism.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/Morphism/Isomorphism.agda", "max_line_length": 120, "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/Morphism/Isomorphism.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4802, "size": 9329 }
module Generic.Test.Data.Lift where open import Generic.Main as Main hiding (Lift; lift; lower) Lift : ∀ {α} β -> Set α -> Set (α ⊔ β) Lift = readData Main.Lift pattern lift x = !#₀ (relv x , lrefl) lower : ∀ {α} {A : Set α} β -> Lift β A -> A lower β (lift x) = x
{ "alphanum_fraction": 0.6133828996, "avg_line_length": 22.4166666667, "ext": "agda", "hexsha": "f7328a080f08b6349548eb1a3cf218663798a113", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z", "max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z", "max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "turion/Generic", "max_forks_repo_path": "src/Generic/Test/Data/Lift.agda", "max_issues_count": 9, "max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z", "max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "turion/Generic", "max_issues_repo_path": "src/Generic/Test/Data/Lift.agda", "max_line_length": 59, "max_stars_count": 30, "max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "turion/Generic", "max_stars_repo_path": "src/Generic/Test/Data/Lift.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z", "num_tokens": 96, "size": 269 }
------------------------------------------------------------------------ -- Extra lemmas about substitutions ------------------------------------------------------------------------ {-# OPTIONS --safe --without-K #-} module Data.Fin.Substitution.ExtraLemmas where open import Data.Fin using (Fin; zero; suc) open import Data.Fin.Substitution open import Data.Fin.Substitution.Lemmas open import Data.Nat using (ℕ; zero; suc; _+_) open import Data.Vec using (Vec; _∷_; lookup; map) open import Data.Vec.Properties using (map-cong; map-∘; lookup-map) open import Data.Vec.Relation.Unary.All hiding (lookup; map) open import Function using (_∘_; _$_; flip) open import Level using (_⊔_) renaming (zero to lzero; suc to lsuc) open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (Star; ε; _◅_; _▻_) open import Relation.Binary.PropositionalEquality as PropEq hiding (subst) open PropEq.≡-Reasoning open import Relation.Unary using (Pred) -- Simple extension of substitutions. -- -- FIXME: this should go into Data.Fin.Substitution. record Extension {ℓ} (T : Pred ℕ ℓ) : Set ℓ where infixr 5 _/∷_ field weaken : ∀ {n} → T n → T (suc n) -- Weakens Ts. -- Iterated weakening of types. weaken⋆ : ∀ m {n} → T n → T (m + n) weaken⋆ zero t = t weaken⋆ (suc m) t = weaken (weaken⋆ m t) -- Extension. _/∷_ : ∀ {m n} → T (suc n) → Sub T m n → Sub T (suc m) (suc n) t /∷ ρ = t ∷ map weaken ρ -- Helper module module SimpleExt {ℓ} {T : Pred ℕ ℓ} (simple : Simple T) where open Simple simple public extension : Extension T extension = record { weaken = weaken } open Extension extension public hiding (weaken) -- An generalized version of Data.Fin.Lemmas.Lemmas₀ -- -- FIXME: this should go into Data.Fin.Substitution.Lemmas. module ExtLemmas₀ {ℓ} {T : Pred ℕ ℓ} (lemmas₀ : Lemmas₀ T) where open Data.Fin using (lift; raise) open Lemmas₀ lemmas₀ public hiding (lookup-map-weaken-↑⋆) open SimpleExt simple -- A generalized variant of Lemmas₀.lookup-map-weaken-↑⋆. lookup-map-weaken-↑⋆ : ∀ {m n} k x {ρ : Sub T m n} {t} → lookup (map weaken ρ ↑⋆ k) x ≡ lookup ((t /∷ ρ) ↑⋆ k) (lift k suc x) lookup-map-weaken-↑⋆ zero x = refl lookup-map-weaken-↑⋆ (suc k) zero = refl lookup-map-weaken-↑⋆ (suc k) (suc x) {ρ} {t} = begin lookup (map weaken (map weaken ρ ↑⋆ k)) x ≡⟨ lookup-map x weaken (map weaken ρ ↑⋆ k) ⟩ weaken (lookup (map weaken ρ ↑⋆ k) x) ≡⟨ cong weaken (lookup-map-weaken-↑⋆ k x) ⟩ weaken (lookup ((t /∷ ρ) ↑⋆ k) (lift k suc x)) ≡⟨ sym (lookup-map (lift k suc x) weaken ((t /∷ ρ) ↑⋆ k)) ⟩ lookup (map weaken ((t /∷ ρ) ↑⋆ k)) (lift k suc x) ∎ -- A version of Data.Fin.Lemmas.Lemmas₁ with additional lemmas. -- -- FIXME: this should go into Data.Fin.Substitution.Lemmas. module ExtLemmas₁ {ℓ} {T : Pred ℕ ℓ} (lemmas₁ : Lemmas₁ T) where open Data.Fin using (raise; fromℕ; lift) open Lemmas₁ lemmas₁ open Simple simple lookup-wk⋆ : ∀ {n} (x : Fin n) k → lookup (wk⋆ k) x ≡ var (raise k x) lookup-wk⋆ x zero = lookup-id x lookup-wk⋆ x (suc k) = lookup-map-weaken x {_} {wk⋆ k} (lookup-wk⋆ x k) lookup-raise-↑⋆ : ∀ k {m n} x {y} {σ : Sub T m n} → lookup σ x ≡ var y → lookup (σ ↑⋆ k) (raise k x) ≡ var (raise k y) lookup-raise-↑⋆ zero x hyp = hyp lookup-raise-↑⋆ (suc k) x {y} {σ} hyp = lookup-map-weaken (raise k x) {_} {σ ↑⋆ k} (lookup-raise-↑⋆ k x hyp) -- A generalized version of Data.Fin.Lemmas.Lemmas₄ -- -- FIXME: this should go into Data.Fin.Substitution.Lemmas. module ExtLemmas₄ {ℓ} {T : Pred ℕ ℓ} (lemmas₄ : Lemmas₄ T) where open Data.Fin using (lift; raise) open Lemmas₄ lemmas₄ public hiding (⊙-wk; wk-commutes) open Lemmas₃ lemmas₃ using (lookup-wk-↑⋆-⊙; /✶-↑✶′) open SimpleExt simple using (_/∷_; weaken⋆) open ExtLemmas₀ lemmas₀ using (lookup-map-weaken-↑⋆) ⊙-wk-↑⋆ : ∀ {m n} {ρ : Sub T m n} {t} k → ρ ↑⋆ k ⊙ wk ↑⋆ k ≡ wk ↑⋆ k ⊙ (t /∷ ρ) ↑⋆ k ⊙-wk-↑⋆ {ρ = ρ} {t} k = sym (begin wk ↑⋆ k ⊙ (t /∷ ρ) ↑⋆ k ≡⟨ lemma ⟩ map weaken ρ ↑⋆ k ≡⟨ cong (λ ρ′ → ρ′ ↑⋆ k) map-weaken ⟩ (ρ ⊙ wk) ↑⋆ k ≡⟨ ↑⋆-distrib k ⟩ ρ ↑⋆ k ⊙ wk ↑⋆ k ∎) where lemma = extensionality λ x → begin lookup (wk ↑⋆ k ⊙ (t /∷ ρ) ↑⋆ k) x ≡⟨ lookup-wk-↑⋆-⊙ k ⟩ lookup ((t /∷ ρ) ↑⋆ k) (lift k suc x) ≡⟨ sym (lookup-map-weaken-↑⋆ k x) ⟩ lookup (map weaken ρ ↑⋆ k) x ∎ ⊙-wk : ∀ {m n} {ρ : Sub T m n} {t} → ρ ⊙ wk ≡ wk ⊙ (t /∷ ρ) ⊙-wk = ⊙-wk-↑⋆ zero wk-⊙-∷ : ∀ {n m} t {ρ : Sub T m n} → wk ⊙ (t ∷ ρ) ≡ ρ wk-⊙-∷ t {ρ} = extensionality λ x → begin lookup (wk ⊙ (t ∷ ρ)) x ≡⟨ lookup-wk-↑⋆-⊙ zero {x} ⟩ lookup (t ∷ ρ) (suc x) ≡⟨⟩ lookup ρ x ∎ wk-↑⋆-commutes : ∀ {m n} {ρ : Sub T m n} {t′} k t → t / ρ ↑⋆ k / wk ↑⋆ k ≡ t / wk ↑⋆ k / (t′ /∷ ρ) ↑⋆ k wk-↑⋆-commutes {ρ = ρ} {t} k = /✶-↑✶′ (ε ▻ ρ ▻ wk) (ε ▻ wk ▻ (t /∷ ρ)) ⊙-wk-↑⋆ k wk-commutes : ∀ {m n} {ρ : Sub T m n} {t′} t → t / ρ / wk ≡ t / wk / (t′ /∷ ρ) wk-commutes = wk-↑⋆-commutes zero raise-/-↑⋆ : ∀ {m n} k x {ρ : Sub T m n} → var (raise k x) / ρ ↑⋆ k ≡ var x / ρ / wk⋆ k raise-/-↑⋆ zero x {ρ} = sym (id-vanishes (var x / ρ)) raise-/-↑⋆ (suc k) x {ρ} = begin var (suc (raise k x)) / ρ ↑⋆ suc k ≡⟨ suc-/-↑ (raise k x) ⟩ var (raise k x) / ρ ↑⋆ k / wk ≡⟨ cong (_/ wk) (raise-/-↑⋆ k x) ⟩ var x / ρ / wk⋆ k / wk ≡⟨ sym (/-⊙ (var x / ρ)) ⟩ var x / ρ / wk⋆ k ⊙ wk ≡⟨ cong (var x / ρ /_) (sym map-weaken) ⟩ var x / ρ / wk⋆ (suc k) ∎ /-wk⋆ : ∀ {n} k {t : T n} → t / wk⋆ k ≡ weaken⋆ k t /-wk⋆ zero {t} = id-vanishes t /-wk⋆ (suc k) {t} = begin t / map weaken (wk⋆ k) ≡⟨ cong (t /_) map-weaken ⟩ t / wk⋆ k ⊙ wk ≡⟨ /-⊙ t ⟩ t / wk⋆ k / wk ≡⟨ /-wk ⟩ weaken (t / wk⋆ k) ≡⟨ cong weaken (/-wk⋆ k) ⟩ weaken (weaken⋆ k t) ∎ -- Weakening commutes with substitution. weaken-/ : ∀ {m n} {ρ : Sub T m n} {t′} t → weaken (t / ρ) ≡ weaken t / (t′ /∷ ρ) weaken-/ {ρ = ρ} {t′} t = begin weaken (t / ρ) ≡⟨ sym /-wk ⟩ t / ρ / wk ≡⟨ wk-commutes t ⟩ t / wk / (t′ /∷ ρ) ≡⟨ cong₂ _/_ /-wk refl ⟩ weaken t / (t′ /∷ ρ) ∎ weaken-/-∷ : ∀ {n m} {t′} {ρ : Sub T m n} t → weaken t / (t′ ∷ ρ) ≡ t / ρ weaken-/-∷ {_} {_} {t′} {ρ} t = begin weaken t / (t′ ∷ ρ) ≡⟨ cong (_/ (t′ ∷ ρ)) (sym /-wk) ⟩ t / wk / (t′ ∷ ρ) ≡⟨ sym (/-⊙ t) ⟩ t / (wk ⊙ (t′ ∷ ρ)) ≡⟨ cong (t /_) (wk-⊙-∷ t′) ⟩ t / ρ ∎ -- A generalize version of Data.Fin.Lemmas.AppLemmas -- -- FIXME: this should go into Data.Fin.Substitution.Lemmas. module ExtAppLemmas {ℓ₁ ℓ₂} {T₁ : Pred ℕ ℓ₁} {T₂ : Pred ℕ ℓ₂} (appLemmas : AppLemmas T₁ T₂) where open AppLemmas appLemmas public hiding (wk-commutes) open SimpleExt simple using (_/∷_) private module L₄ = ExtLemmas₄ lemmas₄ open L₄ public using (wk-⊙-∷) wk-↑⋆-commutes : ∀ {m n} {ρ : Sub T₂ m n} {t′} k t → t / ρ ↑⋆ k / wk ↑⋆ k ≡ t / wk ↑⋆ k / (t′ /∷ ρ) ↑⋆ k wk-↑⋆-commutes {ρ = ρ} {t} k = ⨀→/✶ (ε ▻ ρ ↑⋆ k ▻ wk ↑⋆ k) (ε ▻ wk ↑⋆ k ▻ (t /∷ ρ) ↑⋆ k) (L₄.⊙-wk-↑⋆ k) wk-commutes : ∀ {m n} {ρ : Sub T₂ m n} {t′} t → t / ρ / wk ≡ t / wk / (t′ /∷ ρ) wk-commutes = wk-↑⋆-commutes zero -- Lemmas relating T₃ substitutions in T₁ and T₂. record LiftAppLemmas {ℓ₁ ℓ₂ ℓ₃} (T₁ : Pred ℕ ℓ₁) (T₂ : Pred ℕ ℓ₂) (T₃ : Pred ℕ ℓ₃) : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where field lift : ∀ {n} → T₃ n → T₂ n application₁₃ : Application T₁ T₃ application₂₃ : Application T₂ T₃ lemmas₂ : Lemmas₄ T₂ lemmas₃ : Lemmas₄ T₃ private module L₂ = ExtLemmas₄ lemmas₂ module L₃ = ExtLemmas₄ lemmas₃ module A₁ = Application application₁₃ module A₂ = Application application₂₃ field -- Lifting commutes with application of T₃ substitutions. lift-/ : ∀ {m n} t {σ : Sub T₃ m n} → lift (t L₃./ σ) ≡ lift t A₂./ σ -- Lifting preserves variables. lift-var : ∀ {n} (x : Fin n) → lift (L₃.var x) ≡ L₂.var x -- Sequences of T₃ substitutions are equivalent when applied to -- T₁s if they are equivalent when applied to T₂ variables. /✶-↑✶ : ∀ {m n} (σs₁ σs₂ : Subs T₃ m n) → (∀ k x → L₂.var x A₂./✶ σs₁ L₃.↑✶ k ≡ L₂.var x A₂./✶ σs₂ L₃.↑✶ k) → ∀ k t → t A₁./✶ σs₁ L₃.↑✶ k ≡ t A₁./✶ σs₂ L₃.↑✶ k lift-lookup-⊙ : ∀ {m n k} x {σ₁ : Sub T₃ m n} {σ₂ : Sub T₃ n k} → lift (lookup (σ₁ L₃.⊙ σ₂) x) ≡ lift (lookup σ₁ x) A₂./ σ₂ lift-lookup-⊙ x {σ₁} {σ₂} = begin lift (lookup (σ₁ L₃.⊙ σ₂) x) ≡⟨ cong lift (L₃.lookup-⊙ x {σ₁}) ⟩ lift (lookup σ₁ x L₃./ σ₂) ≡⟨ lift-/ (lookup σ₁ x) ⟩ lift (lookup σ₁ x) A₂./ σ₂ ∎ lift-lookup-⨀ : ∀ {m n} x (σs : Subs T₃ m n) → lift (lookup (L₃.⨀ σs) x) ≡ L₂.var x A₂./✶ σs lift-lookup-⨀ x ε = begin lift (lookup L₃.id x) ≡⟨ cong lift (L₃.lookup-id x) ⟩ lift (L₃.var x) ≡⟨ lift-var x ⟩ L₂.var x ∎ lift-lookup-⨀ x (σ ◅ ε) = begin lift (lookup σ x) ≡⟨ cong lift (sym L₃.var-/) ⟩ lift (L₃.var x L₃./ σ) ≡⟨ lift-/ _ ⟩ lift (L₃.var x) A₂./ σ ≡⟨ cong₂ A₂._/_ (lift-var x) refl ⟩ L₂.var x A₂./ σ ∎ lift-lookup-⨀ x (σ ◅ (σ′ ◅ σs′)) = begin lift (lookup (L₃.⨀ σs L₃.⊙ σ) x) ≡⟨ lift-lookup-⊙ x {L₃.⨀ σs} ⟩ lift (lookup (L₃.⨀ σs) x) A₂./ σ ≡⟨ cong₂ A₂._/_ (lift-lookup-⨀ x (σ′ ◅ σs′)) refl ⟩ L₂.var x A₂./✶ σs A₂./ σ ∎ where σs = σ′ ◅ σs′ -- Sequences of T₃ substitutions are equivalent when applied to -- T₁s if they are equivalent when applied as composites. /✶-↑✶′ : ∀ {m n} (σs₁ σs₂ : Subs T₃ m n) → (∀ k → L₃.⨀ (σs₁ L₃.↑✶ k) ≡ L₃.⨀ (σs₂ L₃.↑✶ k)) → ∀ k t → t A₁./✶ σs₁ L₃.↑✶ k ≡ t A₁./✶ σs₂ L₃.↑✶ k /✶-↑✶′ σs₁ σs₂ hyp = /✶-↑✶ σs₁ σs₂ (λ k x → begin L₂.var x A₂./✶ σs₁ L₃.↑✶ k ≡⟨ sym (lift-lookup-⨀ x (σs₁ L₃.↑✶ k)) ⟩ lift (lookup (L₃.⨀ (σs₁ L₃.↑✶ k)) x) ≡⟨ cong (λ σ → lift (lookup σ x)) (hyp k) ⟩ lift (lookup (L₃.⨀ (σs₂ L₃.↑✶ k)) x) ≡⟨ lift-lookup-⨀ x (σs₂ L₃.↑✶ k) ⟩ L₂.var x A₂./✶ σs₂ L₃.↑✶ k ∎) -- Derived lemmas about applications of T₃ substitutions to T₁s. appLemmas : AppLemmas T₁ T₃ appLemmas = record { application = application₁₃ ; lemmas₄ = lemmas₃ ; id-vanishes = /✶-↑✶′ (ε ▻ L₃.id) ε L₃.id-↑⋆ 0 ; /-⊙ = /✶-↑✶′ (ε ▻ _ L₃.⊙ _) (ε ▻ _ ▻ _) L₃.↑⋆-distrib 0 } open ExtAppLemmas appLemmas public hiding (application; lemmas₂; lemmas₃; var; weaken; subst; simple) -- Lemmas relating T₂ and T₃ substitutions in T₁. record LiftSubLemmas {ℓ₁ ℓ₂ ℓ₃} (T₁ : Pred ℕ ℓ₁) (T₂ : Pred ℕ ℓ₂) (T₃ : Pred ℕ ℓ₃) : Set (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) where field application₁₂ : Application T₁ T₂ liftAppLemmas : LiftAppLemmas T₁ T₂ T₃ open LiftAppLemmas liftAppLemmas hiding (/✶-↑✶; /-wk) private module L₃ = ExtLemmas₄ lemmas₃ module L₂ = ExtLemmas₄ lemmas₂ module A₁₂ = Application application₁₂ module A₁₃ = Application (AppLemmas.application appLemmas) module A₂₃ = Application application₂₃ field -- Weakening commutes with lifting. weaken-lift : ∀ {n} (t : T₃ n) → L₂.weaken (lift t) ≡ lift (L₃.weaken t) -- Applying a composition of T₂ substitutions to T₁s -- corresponds to two consecutive applications. /-⊙₂ : ∀ {m n k} {σ₁ : Sub T₂ m n} {σ₂ : Sub T₂ n k} t → t A₁₂./ σ₁ L₂.⊙ σ₂ ≡ t A₁₂./ σ₁ A₁₂./ σ₂ -- Sequences of T₃ substitutions are equivalent to T₂ -- substitutions when applied to T₁s if they are equivalent when -- applied to variables. /✶-↑✶₁ : ∀ {m n} (σs₁ : Subs T₃ m n) (σs₂ : Subs T₂ m n) → (∀ k x → L₂.var x A₂₃./✶ σs₁ ↑✶ k ≡ L₂.var x L₂./✶ σs₂ L₂.↑✶ k) → ∀ k t → t A₁₃./✶ σs₁ ↑✶ k ≡ t A₁₂./✶ σs₂ L₂.↑✶ k -- Sequences of T₃ substitutions are equivalent to T₂ -- substitutions when applied to T₂s if they are equivalent when -- applied to variables. /✶-↑✶₂ : ∀ {m n} (σs₁ : Subs T₃ m n) (σs₂ : Subs T₂ m n) → (∀ k x → L₂.var x A₂₃./✶ σs₁ ↑✶ k ≡ L₂.var x L₂./✶ σs₂ L₂.↑✶ k) → ∀ k t → t A₂₃./✶ σs₁ ↑✶ k ≡ t L₂./✶ σs₂ L₂.↑✶ k -- Lifting of T₃ substitutions to T₂ substitutions. liftSub : ∀ {m n} → Sub T₃ m n → Sub T₂ m n liftSub σ = map lift σ -- The two types of lifting commute. liftSub-↑⋆ : ∀ {m n} (σ : Sub T₃ m n) k → liftSub σ L₂.↑⋆ k ≡ liftSub (σ ↑⋆ k) liftSub-↑⋆ σ zero = refl liftSub-↑⋆ σ (suc k) = cong₂ _∷_ (sym (lift-var _)) (begin map L₂.weaken (liftSub σ L₂.↑⋆ k) ≡⟨ cong (map _) (liftSub-↑⋆ σ k) ⟩ map L₂.weaken (map lift (σ ↑⋆ k)) ≡⟨ sym (map-∘ _ _ _) ⟩ map (L₂.weaken ∘ lift) (σ ↑⋆ k) ≡⟨ map-cong weaken-lift _ ⟩ map (lift ∘ L₃.weaken) (σ ↑⋆ k) ≡⟨ map-∘ _ _ _ ⟩ map lift (map L₃.weaken (σ ↑⋆ k)) ∎) -- The identity substitutions are equivalent up to lifting. liftSub-id : ∀ {n} → liftSub (L₃.id {n}) ≡ L₂.id {n} liftSub-id {zero} = refl liftSub-id {suc n} = begin liftSub (L₃.id L₃.↑) ≡⟨ sym (liftSub-↑⋆ L₃.id 1) ⟩ liftSub L₃.id L₂.↑ ≡⟨ cong L₂._↑ liftSub-id ⟩ L₂.id ∎ -- Weakening is equivalent up to lifting. liftSub-wk⋆ : ∀ k {n} → liftSub (L₃.wk⋆ k {n}) ≡ L₂.wk⋆ k {n} liftSub-wk⋆ zero = liftSub-id liftSub-wk⋆ (suc k) = begin liftSub (map L₃.weaken (L₃.wk⋆ k)) ≡⟨ sym (map-∘ _ _ _) ⟩ map (lift ∘ L₃.weaken) (L₃.wk⋆ k) ≡⟨ sym (map-cong weaken-lift _) ⟩ map (L₂.weaken ∘ lift) (L₃.wk⋆ k) ≡⟨ map-∘ _ _ _ ⟩ map L₂.weaken (liftSub (L₃.wk⋆ k)) ≡⟨ cong (map _) (liftSub-wk⋆ k) ⟩ map L₂.weaken (L₂.wk⋆ k) ∎ -- Weakening is equivalent up to lifting. liftSub-wk : ∀ {n} → liftSub (L₃.wk {n}) ≡ L₂.wk {n} liftSub-wk = liftSub-wk⋆ 1 -- Single variable substitution is equivalent up to lifting. liftSub-sub : ∀ {n} (t : T₃ n) → liftSub (L₃.sub t) ≡ L₂.sub (lift t) liftSub-sub t = cong₂ _∷_ refl liftSub-id -- Lifting commutes with application to variables. var-/-liftSub-↑⋆ : ∀ {m n} (σ : Sub T₃ m n) k x → L₂.var x A₂₃./ σ ↑⋆ k ≡ L₂.var x L₂./ liftSub σ L₂.↑⋆ k var-/-liftSub-↑⋆ σ k x = begin L₂.var x A₂₃./ σ ↑⋆ k ≡⟨ cong₂ A₂₃._/_ (sym (lift-var x)) refl ⟩ lift (L₃.var x) A₂₃./ σ ↑⋆ k ≡⟨ sym (lift-/ _) ⟩ lift (L₃.var x L₃./ σ ↑⋆ k) ≡⟨ cong lift L₃.var-/ ⟩ lift (lookup (σ ↑⋆ k) x) ≡⟨ sym (lookup-map x lift (σ ↑⋆ k)) ⟩ lookup (liftSub (σ ↑⋆ k)) x ≡⟨ sym L₂.var-/ ⟩ L₂.var x L₂./ liftSub (σ ↑⋆ k) ≡⟨ cong (L₂._/_ (L₂.var x)) (sym (liftSub-↑⋆ σ k)) ⟩ L₂.var x L₂./ liftSub σ L₂.↑⋆ k ∎ -- Lifting commutes with application. /-liftSub-↑⋆ : ∀ {m n} k t {σ : Sub T₃ m n} → t A₁₃./ σ ↑⋆ k ≡ t A₁₂./ liftSub σ L₂.↑⋆ k /-liftSub-↑⋆ k t {σ} = /✶-↑✶₁ (ε ▻ σ) (ε ▻ liftSub σ) (var-/-liftSub-↑⋆ σ) k t /-liftSub : ∀ {m n} t {σ : Sub T₃ m n} → t A₁₃./ σ ≡ t A₁₂./ liftSub σ /-liftSub = /-liftSub-↑⋆ zero -- Weakening is equivalent up to choice of application. /-wk-↑⋆ : ∀ {n} k {t : T₁ (k + n)} → t A₁₃./ L₃.wk ↑⋆ k ≡ t A₁₂./ L₂.wk L₂.↑⋆ k /-wk-↑⋆ k {t = t} = begin t A₁₃./ L₃.wk ↑⋆ k ≡⟨ /-liftSub-↑⋆ k t ⟩ t A₁₂./ (liftSub L₃.wk) L₂.↑⋆ k ≡⟨ cong (λ σ → t A₁₂./ σ L₂.↑⋆ k) liftSub-wk ⟩ t A₁₂./ L₂.wk L₂.↑⋆ k ∎ /-wk : ∀ {n} {t : T₁ n} → t A₁₃./ L₃.wk ≡ t A₁₂./ L₂.wk /-wk = /-wk-↑⋆ zero -- Single-variable substitution is equivalent up to choice of -- application. /-sub-↑⋆ : ∀ {n} k t (s : T₃ n) → t A₁₃./ L₃.sub s ↑⋆ k ≡ t A₁₂./ L₂.sub (lift s) L₂.↑⋆ k /-sub-↑⋆ k t s = begin t A₁₃./ L₃.sub s ↑⋆ k ≡⟨ /-liftSub-↑⋆ k t ⟩ t A₁₂./ liftSub (L₃.sub s) L₂.↑⋆ k ≡⟨ cong (λ σ → t A₁₂./ σ L₂.↑⋆ k) (liftSub-sub s) ⟩ t A₁₂./ L₂.sub (lift s) L₂.↑⋆ k ∎ /-sub : ∀ {n} t (s : T₃ n) → t A₁₃./ L₃.sub s ≡ t A₁₂./ L₂.sub (lift s) /-sub = /-sub-↑⋆ zero -- Lifting commutes with application. /-sub-↑ : ∀ {m n} t s (σ : Sub T₃ m n) → t A₁₂./ L₂.sub s A₁₃./ σ ≡ (t A₁₃./ σ ↑) A₁₂./ L₂.sub (s A₂₃./ σ) /-sub-↑ t s σ = begin t A₁₂./ L₂.sub s A₁₃./ σ ≡⟨ /-liftSub _ ⟩ t A₁₂./ L₂.sub s A₁₂./ liftSub σ ≡⟨ sym (/-⊙₂ t) ⟩ t A₁₂./ (L₂.sub s L₂.⊙ liftSub σ) ≡⟨ cong₂ A₁₂._/_ refl (L₂.sub-⊙ s) ⟩ t A₁₂./ (liftSub σ L₂.↑ L₂.⊙ L₂.sub (s L₂./ liftSub σ)) ≡⟨ /-⊙₂ t ⟩ t A₁₂./ liftSub σ L₂.↑ A₁₂./ L₂.sub (s L₂./ liftSub σ) ≡⟨ cong₂ (A₁₂._/_ ∘ A₁₂._/_ t) (liftSub-↑⋆ _ 1) (cong L₂.sub (sym (/-liftSub₂ s))) ⟩ t A₁₂./ liftSub (σ ↑) A₁₂./ L₂.sub (s A₂₃./ σ) ≡⟨ cong₂ A₁₂._/_ (sym (/-liftSub t)) refl ⟩ t A₁₃./ σ ↑ A₁₂./ L₂.sub (s A₂₃./ σ) ∎ where /-liftSub₂ : ∀ {m n} s {σ : Sub T₃ m n} → s A₂₃./ σ ≡ s L₂./ liftSub σ /-liftSub₂ s {σ} = /✶-↑✶₂ (ε ▻ σ) (ε ▻ liftSub σ) (var-/-liftSub-↑⋆ σ) zero s -- Lemmas relating weakening of T₁ to T₂ substitutions in T₁. record WeakenLemmas {ℓ₁ ℓ₂} (T₁ : Pred ℕ ℓ₁) (T₂ : Pred ℕ ℓ₂) : Set (ℓ₁ ⊔ ℓ₂) where field weaken : ∀ {n} → T₁ n → T₁ (suc n) -- Weakening of T₁s. -- Lemmas about application of T₂ substitutions in T₁ appLemmas : AppLemmas T₁ T₂ open ExtAppLemmas appLemmas hiding (/-wk; weaken; _⊙_) open Lemmas₄ lemmas₄ using (_⊙_) renaming (weaken to weaken′) -- A lemma relating weakening to the wk substitution field /-wk : ∀ {n} {t : T₁ n} → t / wk ≡ weaken t extension : Extension T₁ extension = record { weaken = weaken } open Extension extension public using (weaken⋆) -- A generalized version of wk-sub-vanishes for T₁s. weaken-sub : ∀ {n t′} → (t : T₁ n) → weaken t / sub t′ ≡ t weaken-sub t = begin weaken t / sub _ ≡⟨ cong₂ _/_ (sym /-wk) refl ⟩ t / wk / sub _ ≡⟨ wk-sub-vanishes t ⟩ t ∎ -- A variants of /-wk⋆ for T₁s. /-wk⋆ : ∀ {n} k {t : T₁ n} → t / wk⋆ k ≡ weaken⋆ k t /-wk⋆ zero {t} = id-vanishes t /-wk⋆ (suc k) {t} = begin t / map weaken′ (wk⋆ k) ≡⟨ /-weaken t ⟩ t / wk⋆ k / wk ≡⟨ /-wk ⟩ weaken (t / wk⋆ k) ≡⟨ cong weaken (/-wk⋆ k) ⟩ weaken (weaken⋆ k t) ∎ open SimpleExt simple public using (_/∷_) -- Weakening commutes with substitution. weaken-/ : ∀ {m n} {σ : Sub T₂ m n} {t′} t → weaken (t / σ) ≡ weaken t / (t′ /∷ σ) weaken-/ {σ = σ} {t′} t = begin weaken (t / σ) ≡⟨ sym /-wk ⟩ t / σ / wk ≡⟨ wk-commutes t ⟩ t / wk / (t′ /∷ σ) ≡⟨ cong₂ _/_ /-wk refl ⟩ weaken t / (t′ /∷ σ) ∎ weaken-/-∷ : ∀ {n m} {t′} {σ : Sub T₂ m n} (t : T₁ m) → weaken t / (t′ ∷ σ) ≡ t / σ weaken-/-∷ {_} {_} {t′} {σ} t = begin weaken t / (t′ ∷ σ) ≡⟨ cong (_/ (t′ ∷ σ)) (sym /-wk) ⟩ t / wk / (t′ ∷ σ) ≡⟨ sym (/-⊙ t) ⟩ t / wk ⊙ (t′ ∷ σ) ≡⟨ cong (t /_) (wk-⊙-∷ t′) ⟩ t / σ ∎ -- T₂-substitutions in term-like T₁ -- -- FIXME: this should go into Data.Fin.Substitution. record TermLikeSubst {ℓ} (T₁ : Pred ℕ ℓ) (T₂ : ℕ → Set) : Set (lsuc (ℓ ⊔ lzero)) where field app : ∀ {T₃} → Lift T₃ T₂ → ∀ {m n} → T₁ m → Sub T₃ m n → T₁ n termSubst : TermSubst T₂ open TermSubst termSubst public hiding (app; var; weaken; _/Var_; _/_; _/✶_) termApplication : Application T₁ T₂ termApplication = record { _/_ = app termLift } varApplication : Application T₁ Fin varApplication = record { _/_ = app varLift } open Application termApplication public using (_/_; _/✶_) open Application varApplication public using () renaming (_/_ to _/Var_) -- Weakening of T₁s. weaken : ∀ {n} → T₁ n → T₁ (suc n) weaken t = t /Var VarSubst.wk -- Lemmas for a term-like T₁ derived from term lemmas for T₂ record TermLikeLemmas {ℓ} (T₁ : Pred ℕ ℓ) (T₂ : ℕ → Set) : Set (lsuc (ℓ ⊔ lzero)) where field app : ∀ {T₃} → Lift T₃ T₂ → ∀ {m n} → T₁ m → Sub T₃ m n → T₁ n termLemmas : TermLemmas T₂ termLikeSubst : TermLikeSubst T₁ T₂ termLikeSubst = record { app = app ; termSubst = TermLemmas.termSubst termLemmas } open TermLikeSubst termLikeSubst using (termSubst; termLift; varLift; weaken) open TermSubst termSubst using (var; _⊙_; module Lifted) field /✶-↑✶₁ : ∀ {T₃} {lift : Lift T₃ T₂} → let open Application (record { _/_ = app lift }) using () renaming (_/✶_ to _/✶₁_) open Lifted lift using (_↑✶_) renaming (_/✶_ to _/✶₂_) in ∀ {m n} (σs₁ : Subs T₃ m n) (σs₂ : Subs T₃ m n) → (∀ k x → var x /✶₂ σs₁ ↑✶ k ≡ var x /✶₂ σs₂ ↑✶ k) → ∀ k t → t /✶₁ σs₁ ↑✶ k ≡ t /✶₁ σs₂ ↑✶ k termApplication : Application T₁ T₂ termApplication = record { _/_ = app termLift } varApplication : Application T₁ Fin varApplication = record { _/_ = app varLift } field /✶-↑✶₂ : let open Application varApplication using () renaming (_/✶_ to _/✶₁₃_) open Application termApplication using () renaming (_/✶_ to _/✶₁₂_) open Lifted varLift using () renaming (_↑✶_ to _↑✶₃_; _/✶_ to _/✶₂₃_) open TermSubst termSubst using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂₂_) in ∀ {m n} (σs₁ : Subs Fin m n) (σs₂ : Subs T₂ m n) → (∀ k x → var x /✶₂₃ σs₁ ↑✶₃ k ≡ var x /✶₂₂ σs₂ ↑✶₂ k) → ∀ k t → t /✶₁₃ σs₁ ↑✶₃ k ≡ t /✶₁₂ σs₂ ↑✶₂ k -- An instantiation of the above lemmas for T₂ substitutions in T₁s. termLiftAppLemmas : LiftAppLemmas T₁ T₂ T₂ termLiftAppLemmas = record { lift = Lift.lift termLift ; application₁₃ = termApplication ; application₂₃ = TermLemmas.application termLemmas ; lemmas₂ = TermLemmas.lemmas₄ termLemmas ; lemmas₃ = TermLemmas.lemmas₄ termLemmas ; lift-/ = λ _ → refl ; lift-var = λ _ → refl ; /✶-↑✶ = /✶-↑✶₁ } open LiftAppLemmas termLiftAppLemmas public hiding (/-wk; _⊙_) -- An instantiation of the above lemmas for variable substitutions -- (renamings) in T₁s. varLiftSubLemmas : LiftSubLemmas T₁ T₂ Fin varLiftSubLemmas = record { application₁₂ = termApplication ; liftAppLemmas = record { lift = Lift.lift varLift ; application₁₃ = varApplication ; application₂₃ = Lifted.application varLift ; lemmas₂ = TermLemmas.lemmas₄ termLemmas ; lemmas₃ = VarLemmas.lemmas₄ ; lift-/ = λ _ → sym (TermLemmas.app-var termLemmas) ; lift-var = λ _ → refl ; /✶-↑✶ = /✶-↑✶₁ } ; weaken-lift = λ _ → TermLemmas.weaken-var termLemmas ; /-⊙₂ = AppLemmas./-⊙ appLemmas ; /✶-↑✶₁ = /✶-↑✶₂ ; /✶-↑✶₂ = TermLemmas./✶-↑✶ termLemmas } open Application varApplication public using () renaming (_/_ to _/Var_) open LiftSubLemmas varLiftSubLemmas public hiding (/✶-↑✶₁; /✶-↑✶₂; _⊙_; /-wk) renaming (liftAppLemmas to varLiftAppLemmas) -- Lemmas relating weakening of T₁s to T₂-substitutions in T₁s. weakenLemmas : WeakenLemmas T₁ T₂ weakenLemmas = record { weaken = weaken ; appLemmas = appLemmas ; /-wk = sym /-wk } where open LiftSubLemmas varLiftSubLemmas using (/-wk) open WeakenLemmas weakenLemmas public hiding (appLemmas) -- Another variant of /-wk⋆ relating VarSubst.wk to weakening of T₁s. /Var-wk⋆ : ∀ {n} k {t : T₁ n} → t /Var VarSubst.wk⋆ k ≡ weaken⋆ k t /Var-wk⋆ k {t} = begin t /Var VarSubst.wk⋆ k ≡⟨ /-liftSub t ⟩ t / liftSub (VarSubst.wk⋆ k) ≡⟨ cong (t /_) (liftSub-wk⋆ k) ⟩ t / wk⋆ k ≡⟨ /-wk⋆ k ⟩ weaken⋆ k t ∎
{ "alphanum_fraction": 0.5131915244, "avg_line_length": 37.785046729, "ext": "agda", "hexsha": "86b4432e654409708b4b609d027e7f2fffce55cf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Blaisorblade/f-omega-int-agda", "max_forks_repo_path": "src/Data/Fin/Substitution/ExtraLemmas.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Blaisorblade/f-omega-int-agda", "max_issues_repo_path": "src/Data/Fin/Substitution/ExtraLemmas.agda", "max_line_length": 79, "max_stars_count": null, "max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Blaisorblade/f-omega-int-agda", "max_stars_repo_path": "src/Data/Fin/Substitution/ExtraLemmas.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 10804, "size": 24258 }
{-# OPTIONS --cubical --safe #-} module Relation.Binary.Equivalence.PropHIT where open import Prelude open import Relation.Nullary.Stable open import HITs.PropositionalTruncation open import HITs.PropositionalTruncation.Sugar open import Relation.Binary infix 4 _≐_ _≐_ : A → A → Type _ x ≐ y = ∥ x ≡ y ∥ import Relation.Binary.Equivalence.Reasoning module _ {A : Type a} where prop-equiv : Equivalence A _ prop-equiv .Equivalence._≋_ = _≐_ prop-equiv .Equivalence.sym = sym ∥$∥_ prop-equiv .Equivalence.refl = ∣ refl ∣ prop-equiv .Equivalence.trans x≐y y≐z = ⦇ x≐y ; y≐z ⦈ module Reasoning = Relation.Binary.Equivalence.Reasoning prop-equiv -- data ∙⊥ : Prop where -- private -- variable -- x y z : A -- rerel : ∙⊥ → ⊥ -- rerel () -- ∙refute : x ≐ y → (x ≡ y → ⊥) → ∙⊥ -- ∙refute ∣ x≡y ∣ x≢y with x≢y x≡y -- ∙refute ∣ x≡y ∣ x≢y | () -- refute : x ≐ y → ¬ (¬ (x ≡ y)) -- refute x≐y x≢y = rerel (∙refute x≐y x≢y) -- unsquash : Stable (x ≡ y) → x ≐ y → x ≡ y -- unsquash st x≐y = st (refute x≐y) -- ∙refl : x ≐ x -- ∙refl = ∣ refl ∣ -- ∙trans : x ≐ y → y ≐ z → x ≐ z -- ∙trans ∣ xy ∣ (∣_∣ yz) = ∣_∣ (xy ; yz) -- ∙sym : x ≐ y → y ≐ x -- ∙sym (∣_∣ p) = ∣_∣ (sym p) -- ∙cong : (f : A → B) → x ≐ y → f x ≐ f y -- ∙cong f ∣ x≡y ∣ = ∣ cong f x≡y ∣ -- module Reasoning where -- infixr 2 ≐˘⟨⟩-syntax ≐⟨∙⟩-syntax -- ≐˘⟨⟩-syntax : ∀ (x : A) {y z} → y ≐ z → y ≐ x → x ≐ z -- ≐˘⟨⟩-syntax _ y≡z y≡x = ∙trans (∙sym y≡x) y≡z -- syntax ≐˘⟨⟩-syntax x y≡z y≡x = x ≐˘⟨ y≡x ⟩ y≡z -- ≐⟨∙⟩-syntax : ∀ (x : A) {y z} → y ≐ z → x ≐ y → x ≐ z -- ≐⟨∙⟩-syntax _ y≡z x≡y = ∙trans x≡y y≡z -- syntax ≐⟨∙⟩-syntax x y≡z x≡y = x ≐⟨ x≡y ⟩ y≡z -- _≐⟨⟩_ : ∀ (x : A) {y} → x ≐ y → x ≐ y -- _ ≐⟨⟩ x≡y = x≡y -- infix 2.5 _∎ -- _∎ : ∀ {A : Type a} (x : A) → x ≐ x -- _∎ x = ∙refl -- infixr 2 ≡˘⟨⟩-syntax ≡⟨∙⟩-syntax -- ≡˘⟨⟩-syntax : ∀ (x : A) {y z} → y ≐ z → y ≡ x → x ≐ z -- ≡˘⟨⟩-syntax _ y≡z y≡x = ∙trans (∣_∣ (sym y≡x)) y≡z -- syntax ≡˘⟨⟩-syntax x y≡z y≡x = x ≡˘⟨ y≡x ⟩ y≡z -- ≡⟨∙⟩-syntax : ∀ (x : A) {y z} → y ≐ z → x ≡ y → x ≐ z -- ≡⟨∙⟩-syntax _ y≡z x≡y = ∙trans ∣ x≡y ∣ y≡z -- syntax ≡⟨∙⟩-syntax x y≡z x≡y = x ≡⟨ x≡y ⟩ y≡z
{ "alphanum_fraction": 0.4882542607, "avg_line_length": 24.393258427, "ext": "agda", "hexsha": "4c4641f9293c2aacdc7bfdecf6bc57cb4d1d6600", "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": "Relation/Binary/Equivalence/PropHIT.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": "Relation/Binary/Equivalence/PropHIT.agda", "max_line_length": 69, "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": "Relation/Binary/Equivalence/PropHIT.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": 1187, "size": 2171 }
module Extensions.ListFirst where open import Prelude hiding (_⊔_) open import Data.Product open import Data.List open import Data.List.Any open Membership-≡ hiding (find) open import Level -- proof that an element is the first in a vector to satisfy the predicate B data First {a b} {A : Set a} (B : A → Set b) : (x : A) → List A → Set (a ⊔ b) where here : ∀ {x : A} → (p : B x) → (v : List A) → First B x (x ∷ v) there : ∀ {x} {v : List A} (x' : A) → ¬ (B x') → First B x v → First B x (x' ∷ v) -- get the witness of B x from the element ∈ First first⟶witness : ∀ {A : Set} {B : A → Set} {x l} → First B x l → B x first⟶witness (here p v) = p first⟶witness (there x ¬px f) = first⟶witness f first⟶∈ : ∀ {A : Set} {B : A → Set} {x l} → First B x l → (x ∈ l × B x) first⟶∈ (here {x = x} p v) = here refl , p first⟶∈ (there x' ¬px f) with (first⟶∈ f) first⟶∈ (there x' ¬px f) | x∈l , p = there x∈l , p -- more likable syntax for the above structure first_∈_⇔_ : {A : Set} → A → List A → (B : A → Set) → Set first_∈_⇔_ x v p = First p x v -- a decision procedure to find the first element in a vector that satisfies a predicate find : ∀ {A : Set} (P : A → Set) → ((a : A) → Dec (P a)) → (v : List A) → Dec (∃ λ e → first e ∈ v ⇔ P) find P dec [] = no (λ{ (e , ()) }) find P dec (x ∷ v) with dec x find P dec (x ∷ v) | yes px = yes (x , here px v) find P dec (x ∷ v) | no ¬px with find P dec v find P dec (x ∷ v) | no ¬px | yes firstv = yes (, there x ¬px (proj₂ firstv)) find P dec (x ∷ v) | no ¬px | no ¬firstv = no $ helper ¬px ¬firstv where helper : ¬ (P x) → ¬ (∃ λ e → First P e v) → ¬ (∃ λ e → First P e (x ∷ v)) helper ¬px ¬firstv (.x , here p .v) = ¬px p helper ¬px ¬firstv (u , there ._ _ firstv) = ¬firstv (u , firstv) module FirstLemmas where first-unique : ∀ {A : Set} {P : A → Set} {x y v} → First P x v → First P y v → x ≡ y first-unique (here x v) (here y .v) = refl first-unique (here {x = x} px v) (there .x ¬px r) = ⊥-elim (¬px px) first-unique (there x ¬px l) (here {x = .x} px v) = ⊥-elim (¬px px) first-unique (there x' _ l) (there .x' _ r) = first-unique l r
{ "alphanum_fraction": 0.5602069614, "avg_line_length": 40.8846153846, "ext": "agda", "hexsha": "68611f578be330b615c469f976d189d841b0372f", "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/Extensions/ListFirst.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/Extensions/ListFirst.agda", "max_line_length": 88, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Extensions/ListFirst.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": 856, "size": 2126 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Some theory for Semigroup ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Algebra using (Semigroup) module Algebra.Properties.Semigroup {a ℓ} (S : Semigroup a ℓ) where open Semigroup S x∙yz≈xy∙z : ∀ x y z → x ∙ (y ∙ z) ≈ (x ∙ y) ∙ z x∙yz≈xy∙z x y z = sym (assoc x y z)
{ "alphanum_fraction": 0.4263736264, "avg_line_length": 26.7647058824, "ext": "agda", "hexsha": "0f1af152e9ded71dd34f53b71199db4add04d050", "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/Algebra/Properties/Semigroup.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/Algebra/Properties/Semigroup.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/Algebra/Properties/Semigroup.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": 121, "size": 455 }
------------------------------------------------------------------------ -- Infinite grammars ------------------------------------------------------------------------ -- The grammar language introduced below is not more expressive than -- the one in Grammar.Infinite.Basic. There are two reasons for -- introducing this new language: -- -- ⑴ The function final-whitespace? below analyses the structure of a -- grammar, and can in some cases automatically prove a certain -- theorem. It is quite hard to analyse grammars that contain -- unrestricted corecursion and/or the higher-order bind combinator, -- so the new language contains extra constructors intended to make -- the analysis easier (in some cases). -- -- ⑵ The extra constructors can also make it easier to convince Agda's -- termination checker that certain infinite grammars are -- productive. {-# OPTIONS --guardedness #-} module Grammar.Infinite where open import Algebra open import Category.Monad open import Codata.Musical.Colist using (Colist; []; _∷_; _∈_; here; there) open import Codata.Musical.Notation open import Data.Bool open import Data.Char open import Data.Empty open import Data.List as List using (List; []; _∷_; [_]; _++_; concat) open import Data.List.Categorical renaming (module MonadProperties to List-monad) open import Data.List.NonEmpty as List⁺ using (List⁺; _∷_; _∷⁺_; head; tail) open import Data.List.Properties open import Data.Maybe hiding (_>>=_) open import Data.Maybe.Categorical as MaybeC open import Data.Nat open import Data.Product as Prod open import Data.String as String using (String) open import Data.Unit open import Function.Base open import Function.Equality using (_⟨$⟩_) open import Function.Inverse using (_↔_; module Inverse) open import Relation.Binary.PropositionalEquality as P using (_≡_; refl) open import Relation.Nullary open import Tactic.MonoidSolver private module LM {A : Set} = Monoid (++-monoid A) open module MM {f} = RawMonadPlus (MaybeC.monadPlus {f = f}) using () renaming (_<$>_ to _<$>M_; _⊛_ to _⊛M_) import Grammar.Infinite.Basic as Basic; open Basic._∈_·_ open import Utilities ------------------------------------------------------------------------ -- A grammar language that is less minimal than the one in -- Grammar.Infinite.Basic mutual infix 30 _⋆ infixl 20 _<$>_ _<$_ _⊛_ _<⊛_ _⊛>_ infixl 15 _>>=_ infixl 10 _∣_ data Grammar : Set → Set₁ where -- The empty string. return : ∀ {A} → A → Grammar A -- A single, arbitrary token. token : Grammar Char -- Monadic sequencing. _>>=_ : ∀ {c₁ c₂ A B} → ∞Grammar c₁ A → (A → ∞Grammar c₂ B) → Grammar B -- Symmetric choice. _∣_ : ∀ {c₁ c₂ A} → ∞Grammar c₁ A → ∞Grammar c₂ A → Grammar A -- Failure. fail : ∀ {A} → Grammar A -- A specific token. tok : Char → Grammar Char -- Map. _<$>_ : ∀ {c A B} → (A → B) → ∞Grammar c A → Grammar B _<$_ : ∀ {c A B} → A → ∞Grammar c B → Grammar A -- Applicative sequencing. _⊛_ : ∀ {c₁ c₂ A B} → ∞Grammar c₁ (A → B) → ∞Grammar c₂ A → Grammar B _<⊛_ : ∀ {c₁ c₂ A B} → ∞Grammar c₁ A → ∞Grammar c₂ B → Grammar A _⊛>_ : ∀ {c₁ c₂ A B} → ∞Grammar c₁ A → ∞Grammar c₂ B → Grammar B -- Kleene star. _⋆ : ∀ {c A} → ∞Grammar c A → Grammar (List A) -- Coinductive if the argument is true. -- -- Conditional coinduction is used to avoid having to write the -- delay operator (♯_) all the time. ∞Grammar : Bool → Set → Set₁ ∞Grammar true A = ∞ (Grammar A) ∞Grammar false A = Grammar A -- Families of grammars for specific values. Grammar-for : Set → Set₁ Grammar-for A = (x : A) → Grammar (∃ λ x′ → x′ ≡ x) -- Forcing of a conditionally coinductive grammar. ♭? : ∀ {c A} → ∞Grammar c A → Grammar A ♭? {true} = ♭ ♭? {false} = id -- A grammar combinator: Kleene plus. infix 30 _+ _+ : ∀ {c A} → ∞Grammar c A → Grammar (List⁺ A) g + = _∷_ <$> g ⊛ g ⋆ -- The semantics of "extended" grammars is given by translation to -- simple grammars. ⟦_⟧ : ∀ {A} → Grammar A → Basic.Grammar A ⟦ return x ⟧ = Basic.return x ⟦ token ⟧ = Basic.token ⟦ g₁ >>= g₂ ⟧ = ♯ ⟦ ♭? g₁ ⟧ Basic.>>= λ x → ♯ ⟦ ♭? (g₂ x) ⟧ ⟦ g₁ ∣ g₂ ⟧ = ♯ ⟦ ♭? g₁ ⟧ Basic.∣ ♯ ⟦ ♭? g₂ ⟧ ⟦ fail ⟧ = Basic.fail ⟦ tok t ⟧ = Basic.tok t ⟦ f <$> g ⟧ = ♯ ⟦ ♭? g ⟧ Basic.>>= λ x → ♯ Basic.return (f x) ⟦ x <$ g ⟧ = ♯ ⟦ ♭? g ⟧ Basic.>>= λ _ → ♯ Basic.return x ⟦ g₁ ⊛ g₂ ⟧ = ♯ ⟦ ♭? g₁ ⟧ Basic.>>= λ f → ♯ ⟦ f <$> g₂ ⟧ ⟦ g₁ <⊛ g₂ ⟧ = ♯ ⟦ ♭? g₁ ⟧ Basic.>>= λ x → ♯ ⟦ x <$ g₂ ⟧ ⟦ g₁ ⊛> g₂ ⟧ = ♯ ⟦ ♭? g₁ ⟧ Basic.>>= λ _ → ♯ ⟦ ♭? g₂ ⟧ ⟦ g ⋆ ⟧ = ♯ Basic.return [] Basic.∣ ♯ ⟦ List⁺.toList <$> g + ⟧ ------------------------------------------------------------------------ -- More grammar combinators mutual -- Combinators that transform families of grammars for certain -- elements to families of grammars for certain lists. list : ∀ {A} → Grammar-for A → Grammar-for (List A) list elem [] = return ([] , refl) list elem (x ∷ xs) = Prod.map List⁺.toList (λ eq → P.cong₂ _∷_ (P.cong head eq) (P.cong tail eq)) <$> list⁺ elem (x ∷ xs) list⁺ : ∀ {A} → Grammar-for A → Grammar-for (List⁺ A) list⁺ elem (x ∷ xs) = Prod.zip _∷_ (P.cong₂ _∷_) <$> elem x ⊛ list elem xs -- Elements preceded by something. infixl 18 _prec-by_ _prec-by_ : ∀ {A B} → Grammar A → Grammar B → Grammar (List A) g prec-by prec = (prec ⊛> g) ⋆ -- Elements separated by something. infixl 18 _sep-by_ _sep-by_ : ∀ {A B} → Grammar A → Grammar B → Grammar (List⁺ A) g sep-by sep = _∷_ <$> g ⊛ (g prec-by sep) -- The empty string if the argument is true, otherwise failure. if-true : (b : Bool) → Grammar (T b) if-true true = return tt if-true false = fail -- A token satisfying a given predicate. sat : (p : Char → Bool) → Grammar (∃ λ t → T (p t)) sat p = token >>= λ t → _,_ t <$> if-true (p t) -- A given token satisfying a given predicate. tok-sat : (p : Char → Bool) → Grammar-for (∃ (T ∘ p)) tok-sat p (t , pt) = ((t , pt) , refl) <$ tok t -- Whitespace. whitespace : Grammar Char whitespace = tok ' ' ∣ tok '\n' -- The given string. string : List Char → Grammar (List Char) string [] = return [] string (t ∷ s) = _∷_ <$> tok t ⊛ string s -- A variant of string that takes a String rather than a list of -- characters. string′ : String → Grammar (List Char) string′ = string ∘ String.toList -- The given string, possibly followed by some whitespace. symbol : List Char → Grammar (List Char) symbol s = string s <⊛ whitespace ⋆ symbol′ : String → Grammar (List Char) symbol′ = symbol ∘ String.toList ------------------------------------------------------------------------ -- Alternative definition of the semantics -- Pattern matching on values of type x Basic.∈ ⟦ g₁ ⊛ g₂ ⟧ · s (say) -- is somewhat inconvenient: the patterns have the form -- (>>=-sem _ (>>=-sem _ return-sem)). The following, direct -- definition of the semantics may be easier to use. infix 4 _∈_·_ data _∈_·_ : ∀ {A} → A → Grammar A → List Char → Set₁ where return-sem : ∀ {A} {x : A} → x ∈ return x · [] token-sem : ∀ {t} → t ∈ token · [ t ] >>=-sem : ∀ {c₁ c₂ A B} {g₁ : ∞Grammar c₁ A} {g₂ : A → ∞Grammar c₂ B} {x y s₁ s₂} → x ∈ ♭? g₁ · s₁ → y ∈ ♭? (g₂ x) · s₂ → y ∈ g₁ >>= g₂ · s₁ ++ s₂ left-sem : ∀ {c₁ c₂ A} {g₁ : ∞Grammar c₁ A} {g₂ : ∞Grammar c₂ A} {x s} → x ∈ ♭? g₁ · s → x ∈ g₁ ∣ g₂ · s right-sem : ∀ {c₁ c₂ A} {g₁ : ∞Grammar c₁ A} {g₂ : ∞Grammar c₂ A} {x s} → x ∈ ♭? g₂ · s → x ∈ g₁ ∣ g₂ · s tok-sem : ∀ {t} → t ∈ tok t · [ t ] <$>-sem : ∀ {c A B} {f : A → B} {g : ∞Grammar c A} {x s} → x ∈ ♭? g · s → f x ∈ f <$> g · s <$-sem : ∀ {c A B} {x : A} {g : ∞Grammar c B} {y s} → y ∈ ♭? g · s → x ∈ x <$ g · s ⊛-sem : ∀ {c₁ c₂ A B} {g₁ : ∞Grammar c₁ (A → B)} {g₂ : ∞Grammar c₂ A} {f x s₁ s₂} → f ∈ ♭? g₁ · s₁ → x ∈ ♭? g₂ · s₂ → f x ∈ g₁ ⊛ g₂ · s₁ ++ s₂ <⊛-sem : ∀ {c₁ c₂ A B} {g₁ : ∞Grammar c₁ A} {g₂ : ∞Grammar c₂ B} {x y s₁ s₂} → x ∈ ♭? g₁ · s₁ → y ∈ ♭? g₂ · s₂ → x ∈ g₁ <⊛ g₂ · s₁ ++ s₂ ⊛>-sem : ∀ {c₁ c₂ A B} {g₁ : ∞Grammar c₁ A} {g₂ : ∞Grammar c₂ B} {x y s₁ s₂} → x ∈ ♭? g₁ · s₁ → y ∈ ♭? g₂ · s₂ → y ∈ g₁ ⊛> g₂ · s₁ ++ s₂ ⋆-[]-sem : ∀ {c A} {g : ∞Grammar c A} → [] ∈ g ⋆ · [] ⋆-+-sem : ∀ {c A} {g : ∞Grammar c A} {x xs s} → (x ∷ xs) ∈ g + · s → x ∷ xs ∈ g ⋆ · s -- A weak form of "local unambiguity", unambiguity for a given string. -- (Note that the parse trees are not required to be equal.) Locally-unambiguous : ∀ {A} → Grammar A → List Char → Set₁ Locally-unambiguous g s = ∀ {x y} → x ∈ g · s → y ∈ g · s → x ≡ y -- A weak form of unambiguity. Unambiguous : ∀ {A} → Grammar A → Set₁ Unambiguous g = ∀ {s} → Locally-unambiguous g s -- Parsers. Parser : ∀ {A} → Grammar A → Set₁ Parser g = ∀ s → Dec (∃ λ x → x ∈ g · s) -- Cast lemma. cast : ∀ {A} {g : Grammar A} {x s₁ s₂} → s₁ ≡ s₂ → x ∈ g · s₁ → x ∈ g · s₂ cast refl = id -- The alternative semantics is isomorphic to the one above. isomorphic : ∀ {A x s} {g : Grammar A} → x ∈ g · s ↔ x Basic.∈ ⟦ g ⟧ · s isomorphic {g = g} = record { to = P.→-to-⟶ sound ; from = P.→-to-⟶ (complete g) ; inverse-of = record { left-inverse-of = complete∘sound ; right-inverse-of = sound∘complete g } } where -- Some short lemmas. lemma₁ : ∀ s → s ++ [] ≡ s lemma₁ = proj₂ LM.identity lemma₂ : ∀ s₁ s₂ → s₁ ++ s₂ ++ [] ≡ s₁ ++ s₂ lemma₂ s₁ s₂ = P.cong (_++_ s₁) (lemma₁ s₂) lemma₃ : ∀ s₁ s₂ → s₁ ++ s₂ ≡ ((s₁ ++ []) ++ s₂ ++ []) ++ [] lemma₃ s₁ s₂ = begin s₁ ++ s₂ ≡⟨ P.cong₂ _++_ (P.sym $ lemma₁ s₁) (P.sym $ lemma₁ s₂) ⟩ (s₁ ++ []) ++ s₂ ++ [] ≡⟨ P.sym $ lemma₁ _ ⟩ ((s₁ ++ []) ++ s₂ ++ []) ++ [] ∎ where open P.≡-Reasoning tok-lemma : ∀ {t t′ s} → t ≡ t′ × s ≡ [ t ] → t′ ∈ tok t · s tok-lemma (refl , refl) = tok-sem -- Soundness. sound : ∀ {A x s} {g : Grammar A} → x ∈ g · s → x Basic.∈ ⟦ g ⟧ · s sound return-sem = return-sem sound token-sem = token-sem sound (>>=-sem x∈ y∈) = >>=-sem (sound x∈) (sound y∈) sound (left-sem x∈) = left-sem (sound x∈) sound (right-sem x∈) = right-sem (sound x∈) sound tok-sem = Inverse.from Basic.tok-sem ⟨$⟩ (refl , refl) sound (<$>-sem x∈) = Basic.cast (lemma₁ _) (>>=-sem (sound x∈) return-sem) sound (<$-sem x∈) = Basic.cast (lemma₁ _) (>>=-sem (sound x∈) return-sem) sound (⊛-sem {s₁ = s₁} f∈ x∈) = Basic.cast (lemma₂ s₁ _) (>>=-sem (sound f∈) (>>=-sem (sound x∈) return-sem)) sound (<⊛-sem {s₁ = s₁} x∈ y∈) = Basic.cast (lemma₂ s₁ _) (>>=-sem (sound x∈) (>>=-sem (sound y∈) return-sem)) sound (⊛>-sem {s₁ = s₁} x∈ y∈) = >>=-sem (sound x∈) (sound y∈) sound ⋆-[]-sem = left-sem return-sem sound (⋆-+-sem xs∈) = Basic.cast (lemma₁ _) (right-sem (>>=-sem (sound xs∈) return-sem)) -- Completeness. complete : ∀ {A x s} (g : Grammar A) → x Basic.∈ ⟦ g ⟧ · s → x ∈ g · s complete (return x) return-sem = return-sem complete token token-sem = token-sem complete (g₁ >>= g₂) (>>=-sem x∈ y∈) = >>=-sem (complete _ x∈) (complete _ y∈) complete (g₁ ∣ g₂) (left-sem x∈) = left-sem (complete _ x∈) complete (g₁ ∣ g₂) (right-sem x∈) = right-sem (complete _ x∈) complete fail ∈fail = ⊥-elim (Basic.fail-sem⁻¹ ∈fail) complete (tok t) t∈ = tok-lemma (Inverse.to Basic.tok-sem ⟨$⟩ t∈) complete (f <$> g) (>>=-sem x∈ return-sem) = cast (P.sym $ lemma₁ _) (<$>-sem (complete _ x∈)) complete (x <$ g) (>>=-sem x∈ return-sem) = cast (P.sym $ lemma₁ _) (<$-sem (complete _ x∈)) complete (g₁ ⊛ g₂) (>>=-sem {s₁ = s₁} f∈ (>>=-sem x∈ return-sem)) = cast (P.sym $ lemma₂ s₁ _) (⊛-sem (complete _ f∈) (complete _ x∈)) complete (g₁ <⊛ g₂) (>>=-sem {s₁ = s₁} x∈ (>>=-sem y∈ return-sem)) = cast (P.sym $ lemma₂ s₁ _) (<⊛-sem (complete _ x∈) (complete _ y∈)) complete (g₁ ⊛> g₂) (>>=-sem x∈ y∈) = ⊛>-sem (complete _ x∈) (complete _ y∈) complete (g ⋆) (left-sem return-sem) = ⋆-[]-sem complete (g ⋆) (right-sem (>>=-sem (>>=-sem (>>=-sem {s₁ = s₁} x∈ return-sem) (>>=-sem xs∈ return-sem)) return-sem)) = cast (lemma₃ s₁ _) (⋆-+-sem (⊛-sem (<$>-sem (complete _ x∈)) (complete _ xs∈))) -- More short lemmas. sound-cast : ∀ {A x s₁ s₂} (g : Grammar A) (eq : s₁ ≡ s₂) (x∈ : x ∈ g · s₁) → sound (cast eq x∈) ≡ Basic.cast eq (sound x∈) sound-cast _ refl _ = refl complete-cast : ∀ {A x s₁ s₂} (g : Grammar A) (eq : s₁ ≡ s₂) (x∈ : x Basic.∈ ⟦ g ⟧ · s₁) → complete g (Basic.cast eq x∈) ≡ cast eq (complete g x∈) complete-cast _ refl _ = refl cast-cast : ∀ {A} {x : A} {s₁ s₂ g} (eq : s₁ ≡ s₂) {x∈ : x Basic.∈ g · s₁} → Basic.cast (P.sym eq) (Basic.cast eq x∈) ≡ x∈ cast-cast refl = refl cast-cast′ : ∀ {A} {x : A} {s₁ s₂ g} (eq₁ : s₂ ≡ s₁) (eq₂ : s₁ ≡ s₂) {x∈ : x Basic.∈ g · s₁} → Basic.cast eq₁ (Basic.cast eq₂ x∈) ≡ x∈ cast-cast′ refl refl = refl -- The functions sound and complete are inverses. complete∘sound : ∀ {A x s} {g : Grammar A} (x∈ : x ∈ g · s) → complete g (sound x∈) ≡ x∈ complete∘sound return-sem = refl complete∘sound token-sem = refl complete∘sound (>>=-sem x∈ y∈) = P.cong₂ >>=-sem (complete∘sound x∈) (complete∘sound y∈) complete∘sound (left-sem x∈) = P.cong left-sem (complete∘sound x∈) complete∘sound (right-sem x∈) = P.cong right-sem (complete∘sound x∈) complete∘sound (tok-sem {t = t}) rewrite Inverse.right-inverse-of (Basic.tok-sem {t = t}) (refl , refl) = refl complete∘sound (<$>-sem {s = s} x∈) with sound x∈ | complete∘sound x∈ complete∘sound (<$>-sem {f = f} {g = g} {s = s} .(complete _ x∈′)) | x∈′ | refl rewrite complete-cast (f <$> g) (lemma₁ s) (>>=-sem x∈′ return-sem) | lemma₁ s = refl complete∘sound (<$-sem {x = x} {g = g} {s = s} x∈) with sound x∈ | complete∘sound x∈ complete∘sound (<$-sem {x = x} {g = g} {s = s} .(complete _ x∈′)) | x∈′ | refl rewrite complete-cast (x <$ g) (lemma₁ s) (>>=-sem x∈′ return-sem) | lemma₁ s = refl complete∘sound (⊛-sem f∈ x∈) with sound f∈ | complete∘sound f∈ | sound x∈ | complete∘sound x∈ complete∘sound (⊛-sem {g₁ = g₁} {g₂ = g₂} {s₁ = s₁} {s₂ = s₂} .(complete _ f∈′) .(complete _ x∈′)) | f∈′ | refl | x∈′ | refl rewrite complete-cast (g₁ ⊛ g₂) (lemma₂ s₁ s₂) (>>=-sem f∈′ (>>=-sem x∈′ return-sem)) | lemma₁ s₂ = refl complete∘sound (<⊛-sem x∈ y∈) with sound x∈ | complete∘sound x∈ | sound y∈ | complete∘sound y∈ complete∘sound (<⊛-sem {g₁ = g₁} {g₂ = g₂} {s₁ = s₁} {s₂ = s₂} .(complete _ x∈′) .(complete _ y∈′)) | x∈′ | refl | y∈′ | refl rewrite complete-cast (g₁ <⊛ g₂) (lemma₂ s₁ s₂) (>>=-sem x∈′ (>>=-sem y∈′ return-sem)) | lemma₁ s₂ = refl complete∘sound (⊛>-sem x∈ y∈) with sound x∈ | complete∘sound x∈ | sound y∈ | complete∘sound y∈ complete∘sound (⊛>-sem .(complete _ x∈′) .(complete _ y∈′)) | x∈′ | refl | y∈′ | refl = refl complete∘sound ⋆-[]-sem = refl complete∘sound (⋆-+-sem xs∈) with sound xs∈ | complete∘sound xs∈ complete∘sound (⋆-+-sem {g = g} .(complete _ (>>=-sem (>>=-sem x∈ return-sem) (>>=-sem xs∈′ return-sem)))) | >>=-sem (>>=-sem {s₁ = s₁} x∈ return-sem) (>>=-sem {s₁ = s₂} xs∈′ return-sem) | refl rewrite complete-cast (g ⋆) (lemma₁ ((s₁ ++ []) ++ s₂ ++ [])) (right-sem (>>=-sem (>>=-sem (>>=-sem x∈ return-sem) (>>=-sem xs∈′ return-sem)) return-sem)) | lemma₁ s₁ | lemma₁ s₂ | lemma₁ (s₁ ++ s₂) = refl sound∘complete : ∀ {A x s} (g : Grammar A) (x∈ : x Basic.∈ ⟦ g ⟧ · s) → sound (complete g x∈) ≡ x∈ sound∘complete (return x) return-sem = refl sound∘complete token token-sem = refl sound∘complete (g₁ >>= g₂) (>>=-sem x∈ y∈) = P.cong₂ >>=-sem (sound∘complete (♭? g₁) x∈) (sound∘complete (♭? (g₂ _)) y∈) sound∘complete (g₁ ∣ g₂) (left-sem x∈) = P.cong left-sem (sound∘complete (♭? g₁) x∈) sound∘complete (g₁ ∣ g₂) (right-sem x∈) = P.cong right-sem (sound∘complete (♭? g₂) x∈) sound∘complete fail ∈fail = ⊥-elim (Basic.fail-sem⁻¹ ∈fail) sound∘complete (tok t) t∈ = helper _ (Inverse.left-inverse-of Basic.tok-sem t∈) where helper : ∀ {t t′ s} {t∈ : t′ Basic.∈ Basic.tok t · s} (eqs : t ≡ t′ × s ≡ [ t ]) → Inverse.from Basic.tok-sem ⟨$⟩ eqs ≡ t∈ → sound (tok-lemma eqs) ≡ t∈ helper (refl , refl) ≡t∈ = ≡t∈ sound∘complete (f <$> g) (>>=-sem x∈ return-sem) with complete (♭? g) x∈ | sound∘complete (♭? g) x∈ sound∘complete (f <$> g) (>>=-sem {s₁ = s₁} .(sound x∈′) return-sem) | x∈′ | refl rewrite sound-cast (f <$> g) (P.sym $ lemma₁ s₁) (<$>-sem x∈′) = cast-cast (lemma₁ s₁) sound∘complete (x <$ g) (>>=-sem x∈ return-sem) with complete (♭? g) x∈ | sound∘complete (♭? g) x∈ sound∘complete (x <$ g) (>>=-sem {s₁ = s₁} .(sound x∈′) return-sem) | x∈′ | refl rewrite sound-cast (x <$ g) (P.sym $ lemma₁ s₁) (<$-sem x∈′) = cast-cast (lemma₁ s₁) sound∘complete (g₁ ⊛ g₂) (>>=-sem f∈ (>>=-sem x∈ return-sem)) with complete (♭? g₁) f∈ | sound∘complete (♭? g₁) f∈ | complete (♭? g₂) x∈ | sound∘complete (♭? g₂) x∈ sound∘complete (g₁ ⊛ g₂) (>>=-sem {s₁ = s₁} .(sound f∈′) (>>=-sem {s₁ = s₂} .(sound x∈′) return-sem)) | f∈′ | refl | x∈′ | refl rewrite sound-cast (g₁ ⊛ g₂) (P.sym $ lemma₂ s₁ s₂) (⊛-sem f∈′ x∈′) = cast-cast (lemma₂ s₁ s₂) sound∘complete (g₁ <⊛ g₂) (>>=-sem x∈ (>>=-sem y∈ return-sem)) with complete (♭? g₁) x∈ | sound∘complete (♭? g₁) x∈ | complete (♭? g₂) y∈ | sound∘complete (♭? g₂) y∈ sound∘complete (g₁ <⊛ g₂) (>>=-sem {s₁ = s₁} .(sound x∈′) (>>=-sem {s₁ = s₂} .(sound y∈′) return-sem)) | x∈′ | refl | y∈′ | refl rewrite sound-cast (g₁ <⊛ g₂) (P.sym $ lemma₂ s₁ s₂) (<⊛-sem x∈′ y∈′) = cast-cast (lemma₂ s₁ s₂) sound∘complete (g₁ ⊛> g₂) (>>=-sem x∈ y∈) with complete (♭? g₁) x∈ | sound∘complete (♭? g₁) x∈ | complete (♭? g₂) y∈ | sound∘complete (♭? g₂) y∈ sound∘complete (g₁ ⊛> g₂) (>>=-sem .(sound x∈′) .(sound y∈′)) | x∈′ | refl | y∈′ | refl = refl sound∘complete (g ⋆) (left-sem return-sem) = refl sound∘complete (g ⋆) (right-sem (>>=-sem (>>=-sem (>>=-sem x∈ return-sem) (>>=-sem xs∈ return-sem)) return-sem)) with complete (♭? g) x∈ | sound∘complete (♭? g) x∈ | complete (g ⋆) xs∈ | sound∘complete (g ⋆) xs∈ sound∘complete (g ⋆) (right-sem (>>=-sem (>>=-sem (>>=-sem {s₁ = s₁} .(sound x∈′) return-sem) (>>=-sem {s₁ = s₂} .(sound xs∈′) return-sem)) return-sem)) | x∈′ | refl | xs∈′ | refl rewrite sound-cast (g ⋆) (lemma₃ s₁ s₂) (⋆-+-sem (⊛-sem (<$>-sem x∈′) xs∈′)) = lemma g (lemma₃ s₁ s₂) (lemma₁ (s₁ ++ s₂)) (lemma₂ s₁ s₂) (lemma₁ s₁) (>>=-sem (sound x∈′) return-sem) (>>=-sem (sound xs∈′) return-sem) where lemma : ∀ {c A} {f : List A → List⁺ A} {xs s₁ s₁++s₂ s₁++[] s₂++[]} (g : ∞Grammar c A) (eq₁ : s₁++s₂ ≡ (s₁++[] ++ s₂++[]) ++ []) (eq₂ : (s₁++s₂) ++ [] ≡ s₁++s₂) (eq₃ : s₁ ++ s₂++[] ≡ s₁++s₂) (eq₄ : s₁++[] ≡ s₁) (f∈ : f Basic.∈ ⟦ _∷_ <$> g ⟧ · s₁++[]) (xs∈ : xs Basic.∈ ⟦ f <$> g ⋆ ⟧ · s₂++[]) → _≡_ {A = List⁺.toList xs Basic.∈ ⟦ g ⋆ ⟧ · _} (Basic.cast eq₁ (Basic.cast eq₂ (right-sem (>>=-sem (Basic.cast eq₃ (>>=-sem (Basic.cast eq₄ f∈) xs∈)) return-sem)))) (right-sem (>>=-sem (>>=-sem f∈ xs∈) return-sem)) lemma _ eq₁ eq₂ refl refl _ _ = cast-cast′ eq₁ eq₂ ------------------------------------------------------------------------ -- Semantics combinators +-sem : ∀ {c A} {g : ∞Grammar c A} {x xs s₁ s₂} → x ∈ ♭? g · s₁ → xs ∈ g ⋆ · s₂ → (x ∷ xs) ∈ g + · s₁ ++ s₂ +-sem x∈ xs∈ = ⊛-sem (<$>-sem x∈) xs∈ ⋆-∷-sem : ∀ {c A} {g : ∞Grammar c A} {x xs s₁ s₂} → x ∈ ♭? g · s₁ → xs ∈ g ⋆ · s₂ → x ∷ xs ∈ g ⋆ · s₁ ++ s₂ ⋆-∷-sem x∈ xs∈ = ⋆-+-sem (+-sem x∈ xs∈) ⋆-⋆-sem : ∀ {c A} {g : ∞Grammar c A} {xs₁ xs₂ s₁ s₂} → xs₁ ∈ g ⋆ · s₁ → xs₂ ∈ g ⋆ · s₂ → xs₁ ++ xs₂ ∈ g ⋆ · s₁ ++ s₂ ⋆-⋆-sem ⋆-[]-sem xs₂∈ = xs₂∈ ⋆-⋆-sem (⋆-+-sem (⊛-sem (<$>-sem {s = s₁} x∈) xs₁∈)) xs₂∈ = cast (P.sym $ LM.assoc s₁ _ _) (⋆-∷-sem x∈ (⋆-⋆-sem xs₁∈ xs₂∈)) +-∷-sem : ∀ {c A} {g : ∞Grammar c A} {x xs s₁ s₂} → x ∈ ♭? g · s₁ → xs ∈ g + · s₂ → x ∷⁺ xs ∈ g + · s₁ ++ s₂ +-∷-sem x∈ xs∈ = +-sem x∈ (⋆-+-sem xs∈) mutual list-sem : ∀ {A} {g : Grammar-for A} {s : A → List Char} → (∀ x → (x , refl) ∈ g x · s x) → ∀ xs → (xs , refl) ∈ list g xs · concat (List.map s xs) list-sem elem [] = return-sem list-sem elem (x ∷ xs) = <$>-sem (list⁺-sem elem (x ∷ xs)) list⁺-sem : ∀ {A} {g : Grammar-for A} {s : A → List Char} → (∀ x → (x , refl) ∈ g x · s x) → ∀ xs → (xs , refl) ∈ list⁺ g xs · concat (List.map s (List⁺.toList xs)) list⁺-sem elem (x ∷ xs) = ⊛-sem (<$>-sem (elem x)) (list-sem elem xs) sep-by-sem-singleton : ∀ {A B} {g : Grammar A} {sep : Grammar B} {x s} → x ∈ g · s → x ∷ [] ∈ g sep-by sep · s sep-by-sem-singleton x∈ = cast (proj₂ LM.identity _) (⊛-sem (<$>-sem x∈) ⋆-[]-sem) sep-by-sem-∷ : ∀ {A B} {g : Grammar A} {sep : Grammar B} {x y xs s₁ s₂ s₃} → x ∈ g · s₁ → y ∈ sep · s₂ → xs ∈ g sep-by sep · s₃ → x ∷⁺ xs ∈ g sep-by sep · s₁ ++ s₂ ++ s₃ sep-by-sem-∷ {s₂ = s₂} x∈ y∈ (⊛-sem (<$>-sem x′∈) xs∈) = ⊛-sem (<$>-sem x∈) (cast (LM.assoc s₂ _ _) (⋆-∷-sem (⊛>-sem y∈ x′∈) xs∈)) if-true-sem : ∀ {b} (t : T b) → t ∈ if-true b · [] if-true-sem {b = true} _ = return-sem if-true-sem {b = false} () sat-sem : ∀ {p : Char → Bool} {t} (pt : T (p t)) → (t , pt) ∈ sat p · [ t ] sat-sem pt = >>=-sem token-sem (<$>-sem (if-true-sem pt)) tok-sat-sem : ∀ {p : Char → Bool} {t} (pt : T (p t)) → ((t , pt) , refl) ∈ tok-sat p (t , pt) · [ t ] tok-sat-sem _ = <$-sem tok-sem list-sem-lemma : ∀ {A} {x : A} {g s} → x ∈ g · concat (List.map [_] s) → x ∈ g · s list-sem-lemma = cast (List-monad.right-identity _) single-space-sem : (' ' ∷ []) ∈ whitespace + · String.toList " " single-space-sem = +-sem (left-sem tok-sem) ⋆-[]-sem string-sem′ : ∀ {s s′ s″} → s ∈ string s′ · s″ ↔ (s ≡ s′ × s′ ≡ s″) string-sem′ = record { to = P.→-to-⟶ (to _) ; from = P.→-to-⟶ (from _) ; inverse-of = record { left-inverse-of = from∘to _ ; right-inverse-of = to∘from _ } } where to : ∀ {s} s′ {s″} → s ∈ string s′ · s″ → s ≡ s′ × s′ ≡ s″ to [] return-sem = (refl , refl) to (c ∷ s′) (⊛-sem (<$>-sem tok-sem) s∈) = Prod.map (P.cong (_∷_ c)) (P.cong (_∷_ c)) $ to s′ s∈ from : ∀ {s} s′ {s″} → s ≡ s′ × s′ ≡ s″ → s ∈ string s′ · s″ from [] (refl , refl) = return-sem from (c ∷ s′) (refl , refl) = ⊛-sem (<$>-sem tok-sem) (from s′ (refl , refl)) from∘to : ∀ {s} s′ {s″} (s∈ : s ∈ string s′ · s″) → from s′ (to s′ s∈) ≡ s∈ from∘to [] return-sem = refl from∘to (c ∷ s′) (⊛-sem (<$>-sem tok-sem) s∈) with to s′ s∈ | from∘to s′ s∈ from∘to (c ∷ s′) (⊛-sem (<$>-sem tok-sem) .(from s′ (refl , refl))) | (refl , refl) | refl = refl to∘from : ∀ {s} s′ {s″} (eqs : s ≡ s′ × s′ ≡ s″) → to s′ (from s′ eqs) ≡ eqs to∘from [] (refl , refl) = refl to∘from (c ∷ s′) (refl , refl) rewrite to∘from s′ (refl , refl) = refl string-sem : ∀ {s} → s ∈ string s · s string-sem = Inverse.from string-sem′ ⟨$⟩ (refl , refl) ------------------------------------------------------------------------ -- Expressiveness -- Every language that can be recursively enumerated can be -- represented by a (unit-valued) grammar. -- -- Note that, given a Turing machine that halts and accepts for -- certain strings, and runs forever for other strings, one can define -- a potentially infinite list of type Colist (Maybe (List Char)) that -- contains exactly the strings accepted by the Turing machine -- (assuming that there is some way to construct a stream containing -- all strings of type List Char). expressive : (enumeration : Colist (Maybe (List Char))) → ∃ λ (g : Grammar ⊤) → ∀ {s} → tt ∈ g · s ↔ just s ∈ enumeration expressive ss = (g ss , g-sem ss) where maybe-string : Maybe (List Char) → Grammar ⊤ maybe-string nothing = fail maybe-string (just s) = tt <$ string s g : Colist (Maybe (List Char)) → Grammar ⊤ g [] = fail g (s ∷ ss) = maybe-string s ∣ ♯ g (♭ ss) maybe-string-sem : ∀ {m s} → tt ∈ maybe-string m · s ↔ just s ≡ m maybe-string-sem {nothing} = record { to = P.→-to-⟶ (λ ()) ; from = P.→-to-⟶ (λ ()) ; inverse-of = record { left-inverse-of = λ () ; right-inverse-of = λ () } } maybe-string-sem {just s} = record { to = P.→-to-⟶ to ; from = P.→-to-⟶ from ; inverse-of = record { left-inverse-of = from∘to ; right-inverse-of = to∘from } } where to : ∀ {s′} → tt ∈ tt <$ string s · s′ → Maybe.just s′ ≡ just s to (<$-sem s∈) = P.sym $ P.cong just $ proj₂ (Inverse.to string-sem′ ⟨$⟩ s∈) from : ∀ {s′} → Maybe.just s′ ≡ just s → tt ∈ tt <$ string s · s′ from refl = <$-sem (Inverse.from string-sem′ ⟨$⟩ (refl , refl)) from∘to : ∀ {s′} (tt∈ : tt ∈ tt <$ string s · s′) → from (to tt∈) ≡ tt∈ from∘to (<$-sem s∈) with Inverse.to string-sem′ ⟨$⟩ s∈ | Inverse.left-inverse-of string-sem′ s∈ from∘to (<$-sem .(Inverse.from string-sem′ ⟨$⟩ (refl , refl))) | (refl , refl) | refl = refl to∘from : ∀ {s′} (eq : Maybe.just s′ ≡ just s) → to (from eq) ≡ eq to∘from refl rewrite Inverse.right-inverse-of (string-sem′ {s = s}) (refl , refl) = refl g-sem : ∀ ss {s} → tt ∈ g ss · s ↔ just s ∈ ss g-sem ss = record { to = P.→-to-⟶ (to ss) ; from = P.→-to-⟶ (from ss) ; inverse-of = record { left-inverse-of = from∘to ss ; right-inverse-of = to∘from ss } } where to : ∀ ss {s} → tt ∈ g ss · s → just s ∈ ss to [] () to (s ∷ ss) (left-sem tt∈) = here (Inverse.to maybe-string-sem ⟨$⟩ tt∈) to (s ∷ ss) (right-sem tt∈) = there (to (♭ ss) tt∈) from : ∀ ss {s} → just s ∈ ss → tt ∈ g ss · s from [] () from (s ∷ ss) (here eq) = left-sem (Inverse.from maybe-string-sem ⟨$⟩ eq) from (s ∷ ss) (there p) = right-sem (from (♭ ss) p) from∘to : ∀ ss {s} (tt∈ : tt ∈ g ss · s) → from ss (to ss tt∈) ≡ tt∈ from∘to [] () from∘to (s ∷ ss) (right-sem tt∈) = P.cong right-sem (from∘to (♭ ss) tt∈) from∘to (s ∷ ss) (left-sem tt∈) = P.cong left-sem (Inverse.left-inverse-of maybe-string-sem tt∈) to∘from : ∀ ss {s} (eq : just s ∈ ss) → to ss (from ss eq) ≡ eq to∘from [] () to∘from (s ∷ ss) (there p) = P.cong there (to∘from (♭ ss) p) to∘from (s ∷ ss) (here eq) = P.cong here (Inverse.right-inverse-of maybe-string-sem eq) ------------------------------------------------------------------------ -- Detecting the whitespace combinator -- A predicate for the whitespace combinator. data Is-whitespace : ∀ {A} → Grammar A → Set₁ where is-whitespace : Is-whitespace whitespace -- Detects the whitespace combinator. is-whitespace? : ∀ {A} (g : Grammar A) → Maybe (Is-whitespace g) is-whitespace? (_∣_ {c₁ = false} {c₂ = false} (tok ' ') g) = helper _ refl where helper : ∀ {A} (g : Grammar A) (eq : A ≡ Char) → Maybe (Is-whitespace (tok ' ' ∣ P.subst Grammar eq g)) helper (tok '\n') refl = just is-whitespace helper _ _ = nothing is-whitespace? _ = nothing ------------------------------------------------------------------------ -- Trailing whitespace -- A predicate for grammars that can "swallow" extra trailing -- whitespace. Trailing-whitespace : ∀ {A} → Grammar A → Set₁ Trailing-whitespace g = ∀ {x s} → x ∈ g <⊛ whitespace ⋆ · s → x ∈ g · s -- A similar but weaker property. Trailing-whitespace′ : ∀ {A} → Grammar A → Set₁ Trailing-whitespace′ g = ∀ {x s s₁ s₂} → x ∈ g · s₁ → s ∈ whitespace ⋆ · s₂ → ∃ λ y → y ∈ g · s₁ ++ s₂ -- A heuristic (and rather incomplete) procedure that either proves -- that a production can swallow trailing whitespace (in the weaker -- sense), or returns "don't know" as the answer. -- -- The natural number n is used to ensure termination. trailing-whitespace′ : ∀ (n : ℕ) {A} (g : Grammar A) → Maybe (Trailing-whitespace′ g) trailing-whitespace′ = trailing? where <$>-lemma : ∀ {c A B} {f : A → B} {g : ∞Grammar c A} → Trailing-whitespace′ (♭? g) → Trailing-whitespace′ (f <$> g) <$>-lemma t (<$>-sem x∈) w = -, <$>-sem (proj₂ $ t x∈ w) <$-lemma : ∀ {c A B} {x : A} {g : ∞Grammar c B} → Trailing-whitespace′ (♭? g) → Trailing-whitespace′ (x <$ g) <$-lemma t (<$-sem x∈) w = -, <$-sem (proj₂ $ t x∈ w) ⊛-lemma : ∀ {c₁ c₂ A B} {g₁ : ∞Grammar c₁ (A → B)} {g₂ : ∞Grammar c₂ A} → Trailing-whitespace′ (♭? g₂) → Trailing-whitespace′ (g₁ ⊛ g₂) ⊛-lemma t₂ (⊛-sem {s₁ = s₁} f∈ x∈) w = -, cast (P.sym $ LM.assoc s₁ _ _) (⊛-sem f∈ (proj₂ $ t₂ x∈ w)) <⊛-lemma : ∀ {c₁ c₂ A B} {g₁ : ∞Grammar c₁ A} {g₂ : ∞Grammar c₂ B} → Trailing-whitespace′ (♭? g₂) → Trailing-whitespace′ (g₁ <⊛ g₂) <⊛-lemma t₂ (<⊛-sem {s₁ = s₁} x∈ y∈) w = -, cast (P.sym $ LM.assoc s₁ _ _) (<⊛-sem x∈ (proj₂ $ t₂ y∈ w)) ⊛>-lemma : ∀ {c₁ c₂ A B} {g₁ : ∞Grammar c₁ A} {g₂ : ∞Grammar c₂ B} → Trailing-whitespace′ (♭? g₂) → Trailing-whitespace′ (g₁ ⊛> g₂) ⊛>-lemma t₂ (⊛>-sem {s₁ = s₁} x∈ y∈) w = -, cast (P.sym $ LM.assoc s₁ _ _) (⊛>-sem x∈ (proj₂ $ t₂ y∈ w)) ∣-lemma : ∀ {c₁ c₂ A} {g₁ : ∞Grammar c₁ A} {g₂ : ∞Grammar c₂ A} → Trailing-whitespace′ (♭? g₁) → Trailing-whitespace′ (♭? g₂) → Trailing-whitespace′ (g₁ ∣ g₂) ∣-lemma t₁ t₂ (left-sem x∈) w = -, left-sem (proj₂ $ t₁ x∈ w) ∣-lemma t₁ t₂ (right-sem x∈) w = -, right-sem (proj₂ $ t₂ x∈ w) whitespace⋆-lemma : ∀ {A} {g : Grammar A} → Is-whitespace g → Trailing-whitespace′ (g ⋆) whitespace⋆-lemma is-whitespace xs∈ w = -, ⋆-⋆-sem xs∈ w trailing? : ℕ → ∀ {A} (g : Grammar A) → Maybe (Trailing-whitespace′ g) trailing? (suc n) fail = just (λ ()) trailing? (suc n) (f <$> g) = <$>-lemma <$>M trailing? n (♭? g) trailing? (suc n) (x <$ g) = <$-lemma <$>M trailing? n (♭? g) trailing? (suc n) (g₁ ⊛ g₂) = ⊛-lemma <$>M trailing? n (♭? g₂) trailing? (suc n) (g₁ <⊛ g₂) = <⊛-lemma <$>M trailing? n (♭? g₂) trailing? (suc n) (g₁ ⊛> g₂) = ⊛>-lemma <$>M trailing? n (♭? g₂) trailing? (suc n) (g₁ ∣ g₂) = ∣-lemma <$>M trailing? n (♭? g₁) ⊛M trailing? n (♭? g₂) trailing? (suc n) (_⋆ {c = false} g) = whitespace⋆-lemma <$>M is-whitespace? g trailing? _ _ = nothing -- A heuristic (and rather incomplete) procedure that either proves -- that a production can swallow trailing whitespace, or returns -- "don't know" as the answer. -- -- The natural number n is used to ensure termination. trailing-whitespace : ∀ (n : ℕ) {A} (g : Grammar A) → Maybe (Trailing-whitespace g) trailing-whitespace n g = convert <$>M trailing? n g where -- An alternative formulation of Trailing-whitespace. Trailing-whitespace″ : ∀ {A} → Grammar A → Set₁ Trailing-whitespace″ g = ∀ {x s s₁ s₂} → x ∈ g · s₁ → s ∈ whitespace ⋆ · s₂ → x ∈ g · s₁ ++ s₂ convert : ∀ {A} {g : Grammar A} → Trailing-whitespace″ g → Trailing-whitespace g convert t (<⊛-sem x∈ w) = t x∈ w ++-lemma : ∀ s₁ {s₂} → (s₁ ++ s₂) ++ [] ≡ (s₁ ++ []) ++ s₂ ++-lemma _ = solve (++-monoid Char) <$>-lemma : ∀ {c A B} {f : A → B} {g : ∞Grammar c A} → Trailing-whitespace″ (♭? g) → Trailing-whitespace″ (f <$> g) <$>-lemma t (<$>-sem x∈) w = <$>-sem (t x∈ w) <$-lemma : ∀ {c A B} {x : A} {g : ∞Grammar c B} → Trailing-whitespace′ (♭? g) → Trailing-whitespace″ (x <$ g) <$-lemma t (<$-sem x∈) w = <$-sem (proj₂ $ t x∈ w) ⊛-return-lemma : ∀ {c A B} {g : ∞Grammar c (A → B)} {x} → Trailing-whitespace″ (♭? g) → Trailing-whitespace″ (g ⊛ return x) ⊛-return-lemma t (⊛-sem {s₁ = s₁} f∈ return-sem) w = cast (++-lemma s₁) (⊛-sem (t f∈ w) return-sem) +-lemma : ∀ {c A} {g : ∞Grammar c A} → Trailing-whitespace″ (♭? g) → Trailing-whitespace″ (g +) +-lemma t (⊛-sem {s₁ = s₁} (<$>-sem x∈) ⋆-[]-sem) w = cast (++-lemma s₁) (+-sem (t x∈ w) ⋆-[]-sem) +-lemma t (⊛-sem {s₁ = s₁} (<$>-sem x∈) (⋆-+-sem xs∈)) w = cast (P.sym $ LM.assoc s₁ _ _) (+-∷-sem x∈ (+-lemma t xs∈ w)) ⊛-⋆-lemma : ∀ {c₁ c₂ A B} {g₁ : ∞Grammar c₁ (List A → B)} {g₂ : ∞Grammar c₂ A} → Trailing-whitespace″ (♭? g₁) → Trailing-whitespace″ (♭? g₂) → Trailing-whitespace″ (g₁ ⊛ g₂ ⋆) ⊛-⋆-lemma t₁ t₂ (⊛-sem {s₁ = s₁} f∈ ⋆-[]-sem) w = cast (++-lemma s₁) (⊛-sem (t₁ f∈ w) ⋆-[]-sem) ⊛-⋆-lemma t₁ t₂ (⊛-sem {s₁ = s₁} f∈ (⋆-+-sem xs∈)) w = cast (P.sym $ LM.assoc s₁ _ _) (⊛-sem f∈ (⋆-+-sem (+-lemma t₂ xs∈ w))) ⊛-∣-lemma : ∀ {c₁ c₂₁ c₂₂ A B} {g₁ : ∞Grammar c₁ (A → B)} {g₂₁ : ∞Grammar c₂₁ A} {g₂₂ : ∞Grammar c₂₂ A} → Trailing-whitespace″ (g₁ ⊛ g₂₁) → Trailing-whitespace″ (g₁ ⊛ g₂₂) → Trailing-whitespace″ (g₁ ⊛ (g₂₁ ∣ g₂₂)) ⊛-∣-lemma t₁₂ t₁₃ {s₂ = s₃} (⊛-sem {f = f} {x = x} {s₁ = s₁} {s₂ = s₂} f∈ (left-sem x∈)) w with f x | (s₁ ++ s₂) ++ s₃ | t₁₂ (⊛-sem f∈ x∈) w ... | ._ | ._ | ⊛-sem f∈′ x∈′ = ⊛-sem f∈′ (left-sem x∈′) ⊛-∣-lemma t₁₂ t₁₃ {s₂ = s₃} (⊛-sem {f = f} {x = x} {s₁ = s₁} {s₂ = s₂} f∈ (right-sem x∈)) w with f x | (s₁ ++ s₂) ++ s₃ | t₁₃ (⊛-sem f∈ x∈) w ... | ._ | ._ | ⊛-sem f∈′ x∈′ = ⊛-sem f∈′ (right-sem x∈′) ⊛-lemma : ∀ {c₁ c₂ A B} {g₁ : ∞Grammar c₁ (A → B)} {g₂ : ∞Grammar c₂ A} → Trailing-whitespace″ (♭? g₂) → Trailing-whitespace″ (g₁ ⊛ g₂) ⊛-lemma t₂ (⊛-sem {s₁ = s₁} f∈ x∈) w = cast (P.sym $ LM.assoc s₁ _ _) (⊛-sem f∈ (t₂ x∈ w)) <⊛-return-lemma : ∀ {c A B} {g : ∞Grammar c A} {x : B} → Trailing-whitespace″ (♭? g) → Trailing-whitespace″ (g <⊛ return x) <⊛-return-lemma t (<⊛-sem {s₁ = s₁} f∈ return-sem) w = cast (++-lemma s₁) (<⊛-sem (t f∈ w) return-sem) <⊛-lemma : ∀ {c₁ c₂ A B} {g₁ : ∞Grammar c₁ A} {g₂ : ∞Grammar c₂ B} → Trailing-whitespace′ (♭? g₂) → Trailing-whitespace″ (g₁ <⊛ g₂) <⊛-lemma t₂ (<⊛-sem {s₁ = s₁} x∈ y∈) w = cast (P.sym $ LM.assoc s₁ _ _) (<⊛-sem x∈ (proj₂ $ t₂ y∈ w)) ⊛>-lemma : ∀ {c₁ c₂ A B} {g₁ : ∞Grammar c₁ A} {g₂ : ∞Grammar c₂ B} → Trailing-whitespace″ (♭? g₂) → Trailing-whitespace″ (g₁ ⊛> g₂) ⊛>-lemma t₂ (⊛>-sem {s₁ = s₁} x∈ y∈) w = cast (P.sym $ LM.assoc s₁ _ _) (⊛>-sem x∈ (t₂ y∈ w)) ∣-lemma : ∀ {c₁ c₂ A} {g₁ : ∞Grammar c₁ A} {g₂ : ∞Grammar c₂ A} → Trailing-whitespace″ (♭? g₁) → Trailing-whitespace″ (♭? g₂) → Trailing-whitespace″ (g₁ ∣ g₂) ∣-lemma t₁ t₂ (left-sem x∈) w = left-sem (t₁ x∈ w) ∣-lemma t₁ t₂ (right-sem x∈) w = right-sem (t₂ x∈ w) trailing? : ℕ → ∀ {A} (g : Grammar A) → Maybe (Trailing-whitespace″ g) trailing? (suc n) fail = just (λ ()) trailing? (suc n) (f <$> g) = <$>-lemma <$>M trailing? n (♭? g) trailing? (suc n) (x <$ g) = <$-lemma <$>M trailing-whitespace′ (suc n) (♭? g) trailing? (suc n) (_⊛_ {c₂ = false} g (return x)) = ⊛-return-lemma <$>M trailing? n (♭? g) trailing? (suc n) (_⊛_ {c₂ = false} g₁ (g₂ ⋆)) = ⊛-⋆-lemma <$>M trailing? n (♭? g₁) ⊛M trailing? n (♭? g₂) trailing? (suc n) (_⊛_ {c₂ = false} g₁ (g₂₁ ∣ g₂₂)) = ⊛-∣-lemma <$>M trailing? n (g₁ ⊛ g₂₁) ⊛M trailing? n (g₁ ⊛ g₂₂) trailing? (suc n) (_⊛_ g₁ g₂) = ⊛-lemma <$>M trailing? n (♭? g₂) trailing? (suc n) (_<⊛_ {c₂ = false} g (return x)) = <⊛-return-lemma <$>M trailing? n (♭? g) trailing? (suc n) (_<⊛_ g₁ g₂) = <⊛-lemma <$>M trailing-whitespace′ (suc n) (♭? g₂) trailing? (suc n) (g₁ ⊛> g₂) = ⊛>-lemma <$>M trailing? n (♭? g₂) trailing? (suc n) (g₁ ∣ g₂) = ∣-lemma <$>M trailing? n (♭? g₁) ⊛M trailing? n (♭? g₂) trailing? _ _ = nothing private -- Some unit tests. test₁ : T (is-just (trailing-whitespace′ 1 (whitespace ⋆))) test₁ = _ test₂ : T (is-just (trailing-whitespace′ 2 (whitespace +))) test₂ = _ test₃ : T (is-just (trailing-whitespace 1 (tt <$ whitespace ⋆))) test₃ = _ test₄ : T (is-just (trailing-whitespace 2 (tt <$ whitespace +))) test₄ = _
{ "alphanum_fraction": 0.4774945077, "avg_line_length": 36.7568075117, "ext": "agda", "hexsha": "d545d13cff61c5d9b0059b1403b147bffc32bc71", "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": "b956803ba90b6c5f57bbbaab01bb18485d948492", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/pretty", "max_forks_repo_path": "Grammar/Infinite.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492", "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/pretty", "max_issues_repo_path": "Grammar/Infinite.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "b956803ba90b6c5f57bbbaab01bb18485d948492", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/pretty", "max_stars_repo_path": "Grammar/Infinite.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 15227, "size": 39146 }
{- Copyright © 2015 Benjamin Barenblat Licensed under the Apache License, Version 2.0 (the ‘License’); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an ‘AS IS’ BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -} module B.Prelude.Eq where import Data.Bool as Bool open Bool using (Bool) import Data.Char as Char open Char using (Char) import Data.Nat as ℕ open ℕ using (ℕ) open import Function using (_$_) import Level open Level using (_⊔_) open import Relation.Nullary.Decidable using (⌊_⌋) open import Relation.Binary using (DecSetoid) record Eq {c} {ℓ} (t : Set c) : Set (Level.suc $ c ⊔ ℓ) where field decSetoid : DecSetoid c ℓ _≟_ = DecSetoid._≟_ decSetoid _==_ : DecSetoid.Carrier decSetoid → DecSetoid.Carrier decSetoid → Bool x == y = ⌊ x ≟ y ⌋ open Eq ⦃...⦄ public instance Eq-Bool : Eq Bool Eq-Bool = record { decSetoid = Bool.decSetoid } Eq-Char : Eq Char Eq-Char = record { decSetoid = Char.decSetoid } -- TODO: Float Eq-ℕ : Eq ℕ Eq-ℕ = let module DecTotalOrder = Relation.Binary.DecTotalOrder in record { decSetoid = DecTotalOrder.Eq.decSetoid ℕ.decTotalOrder }
{ "alphanum_fraction": 0.7194630872, "avg_line_length": 27.5925925926, "ext": "agda", "hexsha": "59142c1d33da5100d1ac715f5f1cae389d607978", "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": "c1fd2daa41aa1b915f74b4c09c6e62c79320e8ec", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "bbarenblat/B", "max_forks_repo_path": "Prelude/Eq.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c1fd2daa41aa1b915f74b4c09c6e62c79320e8ec", "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": "bbarenblat/B", "max_issues_repo_path": "Prelude/Eq.agda", "max_line_length": 79, "max_stars_count": 1, "max_stars_repo_head_hexsha": "c1fd2daa41aa1b915f74b4c09c6e62c79320e8ec", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "bbarenblat/B", "max_stars_repo_path": "Prelude/Eq.agda", "max_stars_repo_stars_event_max_datetime": "2017-06-30T15:59:38.000Z", "max_stars_repo_stars_event_min_datetime": "2017-06-30T15:59:38.000Z", "num_tokens": 443, "size": 1490 }
module FRP.JS.Bool where open import FRP.JS.Primitive public using ( Bool ; true ; false ) not : Bool → Bool not true = false not false = true {-# COMPILED_JS not function(x) { return !x; } #-} _≟_ : Bool → Bool → Bool true ≟ b = b false ≟ b = not b {-# COMPILED_JS _≟_ function(x) { return function(y) { return x === y; }; } #-} if_then_else_ : ∀ {α} {A : Set α} → Bool → A → A → A if true then t else f = t if false then t else f = f {-# COMPILED_JS if_then_else_ function(a) { return function(A) { return function(x) { if (x) { return function(t) { return function(f) { return t; }; }; } else { return function(t) { return function(f) { return f; }; }; } }; }; } #-} _∧_ : Bool → Bool → Bool true ∧ b = b false ∧ b = false {-# COMPILED_JS _∧_ function(x) { return function(y) { return x && y; }; } #-} _∨_ : Bool → Bool → Bool true ∨ b = true false ∨ b = b {-# COMPILED_JS _∨_ function(x) { return function(y) { return x || y; }; } #-} _xor_ : Bool → Bool → Bool true xor b = not b false xor b = b _≠_ = _xor_ {-# COMPILED_JS _xor_ function(x) { return function(y) { return x !== y; }; } #-} {-# COMPILED_JS _≠_ function(x) { return function(y) { return x !== y; }; } #-}
{ "alphanum_fraction": 0.5863219349, "avg_line_length": 26.0652173913, "ext": "agda", "hexsha": "10cd888130166c22318e7abe37e44f4f68601f1e", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "src/agda/FRP/JS/Bool.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "src/agda/FRP/JS/Bool.agda", "max_line_length": 85, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "src/agda/FRP/JS/Bool.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 406, "size": 1199 }
module Text.Greek.SBLGNT.Phil where open import Data.List open import Text.Greek.Bible open import Text.Greek.Script open import Text.Greek.Script.Unicode ΠΡΟΣ-ΦΙΛΙΠΠΗΣΙΟΥΣ : List (Word) ΠΡΟΣ-ΦΙΛΙΠΠΗΣΙΟΥΣ = word (Π ∷ α ∷ ῦ ∷ ∙λ ∷ ο ∷ ς ∷ []) "Phil.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.1" ∷ word (Τ ∷ ι ∷ μ ∷ ό ∷ θ ∷ ε ∷ ο ∷ ς ∷ []) "Phil.1.1" ∷ word (δ ∷ ο ∷ ῦ ∷ ∙λ ∷ ο ∷ ι ∷ []) "Phil.1.1" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.1.1" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.1.1" ∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "Phil.1.1" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.1.1" ∷ word (ἁ ∷ γ ∷ ί ∷ ο ∷ ι ∷ ς ∷ []) "Phil.1.1" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.1" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phil.1.1" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.1.1" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.1.1" ∷ word (ο ∷ ὖ ∷ σ ∷ ι ∷ ν ∷ []) "Phil.1.1" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.1" ∷ word (Φ ∷ ι ∷ ∙λ ∷ ί ∷ π ∷ π ∷ ο ∷ ι ∷ ς ∷ []) "Phil.1.1" ∷ word (σ ∷ ὺ ∷ ν ∷ []) "Phil.1.1" ∷ word (ἐ ∷ π ∷ ι ∷ σ ∷ κ ∷ ό ∷ π ∷ ο ∷ ι ∷ ς ∷ []) "Phil.1.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.1" ∷ word (δ ∷ ι ∷ α ∷ κ ∷ ό ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "Phil.1.1" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "Phil.1.2" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.2" ∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "Phil.1.2" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "Phil.1.2" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Phil.1.2" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὸ ∷ ς ∷ []) "Phil.1.2" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.1.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.2" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "Phil.1.2" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.1.2" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.1.2" ∷ word (Ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῶ ∷ []) "Phil.1.3" ∷ word (τ ∷ ῷ ∷ []) "Phil.1.3" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "Phil.1.3" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.1.3" ∷ word (ἐ ∷ π ∷ ὶ ∷ []) "Phil.1.3" ∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "Phil.1.3" ∷ word (τ ∷ ῇ ∷ []) "Phil.1.3" ∷ word (μ ∷ ν ∷ ε ∷ ί ∷ ᾳ ∷ []) "Phil.1.3" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.1.3" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "Phil.1.4" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.4" ∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "Phil.1.4" ∷ word (δ ∷ ε ∷ ή ∷ σ ∷ ε ∷ ι ∷ []) "Phil.1.4" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.1.4" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "Phil.1.4" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "Phil.1.4" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.1.4" ∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "Phil.1.4" ∷ word (χ ∷ α ∷ ρ ∷ ᾶ ∷ ς ∷ []) "Phil.1.4" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.1.4" ∷ word (δ ∷ έ ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "Phil.1.4" ∷ word (π ∷ ο ∷ ι ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Phil.1.4" ∷ word (ἐ ∷ π ∷ ὶ ∷ []) "Phil.1.5" ∷ word (τ ∷ ῇ ∷ []) "Phil.1.5" ∷ word (κ ∷ ο ∷ ι ∷ ν ∷ ω ∷ ν ∷ ί ∷ ᾳ ∷ []) "Phil.1.5" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.1.5" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.1.5" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.5" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ι ∷ ο ∷ ν ∷ []) "Phil.1.5" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "Phil.1.5" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.1.5" ∷ word (π ∷ ρ ∷ ώ ∷ τ ∷ η ∷ ς ∷ []) "Phil.1.5" ∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "Phil.1.5" ∷ word (ἄ ∷ χ ∷ ρ ∷ ι ∷ []) "Phil.1.5" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.1.5" ∷ word (ν ∷ ῦ ∷ ν ∷ []) "Phil.1.5" ∷ word (π ∷ ε ∷ π ∷ ο ∷ ι ∷ θ ∷ ὼ ∷ ς ∷ []) "Phil.1.6" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ []) "Phil.1.6" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Phil.1.6" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.1.6" ∷ word (ὁ ∷ []) "Phil.1.6" ∷ word (ἐ ∷ ν ∷ α ∷ ρ ∷ ξ ∷ ά ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Phil.1.6" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.6" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.1.6" ∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ ν ∷ []) "Phil.1.6" ∷ word (ἀ ∷ γ ∷ α ∷ θ ∷ ὸ ∷ ν ∷ []) "Phil.1.6" ∷ word (ἐ ∷ π ∷ ι ∷ τ ∷ ε ∷ ∙λ ∷ έ ∷ σ ∷ ε ∷ ι ∷ []) "Phil.1.6" ∷ word (ἄ ∷ χ ∷ ρ ∷ ι ∷ []) "Phil.1.6" ∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ς ∷ []) "Phil.1.6" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.1.6" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.1.6" ∷ word (κ ∷ α ∷ θ ∷ ώ ∷ ς ∷ []) "Phil.1.7" ∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "Phil.1.7" ∷ word (δ ∷ ί ∷ κ ∷ α ∷ ι ∷ ο ∷ ν ∷ []) "Phil.1.7" ∷ word (ἐ ∷ μ ∷ ο ∷ ὶ ∷ []) "Phil.1.7" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Phil.1.7" ∷ word (φ ∷ ρ ∷ ο ∷ ν ∷ ε ∷ ῖ ∷ ν ∷ []) "Phil.1.7" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "Phil.1.7" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ω ∷ ν ∷ []) "Phil.1.7" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.1.7" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phil.1.7" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.7" ∷ word (ἔ ∷ χ ∷ ε ∷ ι ∷ ν ∷ []) "Phil.1.7" ∷ word (μ ∷ ε ∷ []) "Phil.1.7" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.7" ∷ word (τ ∷ ῇ ∷ []) "Phil.1.7" ∷ word (κ ∷ α ∷ ρ ∷ δ ∷ ί ∷ ᾳ ∷ []) "Phil.1.7" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.1.7" ∷ word (ἔ ∷ ν ∷ []) "Phil.1.7" ∷ word (τ ∷ ε ∷ []) "Phil.1.7" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.1.7" ∷ word (δ ∷ ε ∷ σ ∷ μ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.1.7" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.1.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.7" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.7" ∷ word (τ ∷ ῇ ∷ []) "Phil.1.7" ∷ word (ἀ ∷ π ∷ ο ∷ ∙λ ∷ ο ∷ γ ∷ ί ∷ ᾳ ∷ []) "Phil.1.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.7" ∷ word (β ∷ ε ∷ β ∷ α ∷ ι ∷ ώ ∷ σ ∷ ε ∷ ι ∷ []) "Phil.1.7" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.1.7" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ο ∷ υ ∷ []) "Phil.1.7" ∷ word (σ ∷ υ ∷ γ ∷ κ ∷ ο ∷ ι ∷ ν ∷ ω ∷ ν ∷ ο ∷ ύ ∷ ς ∷ []) "Phil.1.7" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.1.7" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.1.7" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ τ ∷ ο ∷ ς ∷ []) "Phil.1.7" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Phil.1.7" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.1.7" ∷ word (ὄ ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Phil.1.7" ∷ word (μ ∷ ά ∷ ρ ∷ τ ∷ υ ∷ ς ∷ []) "Phil.1.8" ∷ word (γ ∷ ά ∷ ρ ∷ []) "Phil.1.8" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.1.8" ∷ word (ὁ ∷ []) "Phil.1.8" ∷ word (θ ∷ ε ∷ ό ∷ ς ∷ []) "Phil.1.8" ∷ word (ὡ ∷ ς ∷ []) "Phil.1.8" ∷ word (ἐ ∷ π ∷ ι ∷ π ∷ ο ∷ θ ∷ ῶ ∷ []) "Phil.1.8" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Phil.1.8" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.1.8" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.8" ∷ word (σ ∷ π ∷ ∙λ ∷ ά ∷ γ ∷ χ ∷ ν ∷ ο ∷ ι ∷ ς ∷ []) "Phil.1.8" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.1.8" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.1.8" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.9" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Phil.1.9" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ ύ ∷ χ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Phil.1.9" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.1.9" ∷ word (ἡ ∷ []) "Phil.1.9" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ []) "Phil.1.9" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.1.9" ∷ word (ἔ ∷ τ ∷ ι ∷ []) "Phil.1.9" ∷ word (μ ∷ ᾶ ∷ ∙λ ∷ ∙λ ∷ ο ∷ ν ∷ []) "Phil.1.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.9" ∷ word (μ ∷ ᾶ ∷ ∙λ ∷ ∙λ ∷ ο ∷ ν ∷ []) "Phil.1.9" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ε ∷ ύ ∷ ῃ ∷ []) "Phil.1.9" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.9" ∷ word (ἐ ∷ π ∷ ι ∷ γ ∷ ν ∷ ώ ∷ σ ∷ ε ∷ ι ∷ []) "Phil.1.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.9" ∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "Phil.1.9" ∷ word (α ∷ ἰ ∷ σ ∷ θ ∷ ή ∷ σ ∷ ε ∷ ι ∷ []) "Phil.1.9" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.1.10" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.10" ∷ word (δ ∷ ο ∷ κ ∷ ι ∷ μ ∷ ά ∷ ζ ∷ ε ∷ ι ∷ ν ∷ []) "Phil.1.10" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.1.10" ∷ word (τ ∷ ὰ ∷ []) "Phil.1.10" ∷ word (δ ∷ ι ∷ α ∷ φ ∷ έ ∷ ρ ∷ ο ∷ ν ∷ τ ∷ α ∷ []) "Phil.1.10" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.1.10" ∷ word (ἦ ∷ τ ∷ ε ∷ []) "Phil.1.10" ∷ word (ε ∷ ἰ ∷ ∙λ ∷ ι ∷ κ ∷ ρ ∷ ι ∷ ν ∷ ε ∷ ῖ ∷ ς ∷ []) "Phil.1.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.10" ∷ word (ἀ ∷ π ∷ ρ ∷ ό ∷ σ ∷ κ ∷ ο ∷ π ∷ ο ∷ ι ∷ []) "Phil.1.10" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.1.10" ∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ν ∷ []) "Phil.1.10" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.1.10" ∷ word (π ∷ ε ∷ π ∷ ∙λ ∷ η ∷ ρ ∷ ω ∷ μ ∷ έ ∷ ν ∷ ο ∷ ι ∷ []) "Phil.1.11" ∷ word (κ ∷ α ∷ ρ ∷ π ∷ ὸ ∷ ν ∷ []) "Phil.1.11" ∷ word (δ ∷ ι ∷ κ ∷ α ∷ ι ∷ ο ∷ σ ∷ ύ ∷ ν ∷ η ∷ ς ∷ []) "Phil.1.11" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Phil.1.11" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phil.1.11" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.1.11" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.1.11" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.1.11" ∷ word (δ ∷ ό ∷ ξ ∷ α ∷ ν ∷ []) "Phil.1.11" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.11" ∷ word (ἔ ∷ π ∷ α ∷ ι ∷ ν ∷ ο ∷ ν ∷ []) "Phil.1.11" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Phil.1.11" ∷ word (Γ ∷ ι ∷ ν ∷ ώ ∷ σ ∷ κ ∷ ε ∷ ι ∷ ν ∷ []) "Phil.1.12" ∷ word (δ ∷ ὲ ∷ []) "Phil.1.12" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.1.12" ∷ word (β ∷ ο ∷ ύ ∷ ∙λ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Phil.1.12" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "Phil.1.12" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.1.12" ∷ word (τ ∷ ὰ ∷ []) "Phil.1.12" ∷ word (κ ∷ α ∷ τ ∷ []) "Phil.1.12" ∷ word (ἐ ∷ μ ∷ ὲ ∷ []) "Phil.1.12" ∷ word (μ ∷ ᾶ ∷ ∙λ ∷ ∙λ ∷ ο ∷ ν ∷ []) "Phil.1.12" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.1.12" ∷ word (π ∷ ρ ∷ ο ∷ κ ∷ ο ∷ π ∷ ὴ ∷ ν ∷ []) "Phil.1.12" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.1.12" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ο ∷ υ ∷ []) "Phil.1.12" ∷ word (ἐ ∷ ∙λ ∷ ή ∷ ∙λ ∷ υ ∷ θ ∷ ε ∷ ν ∷ []) "Phil.1.12" ∷ word (ὥ ∷ σ ∷ τ ∷ ε ∷ []) "Phil.1.13" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.1.13" ∷ word (δ ∷ ε ∷ σ ∷ μ ∷ ο ∷ ύ ∷ ς ∷ []) "Phil.1.13" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.1.13" ∷ word (φ ∷ α ∷ ν ∷ ε ∷ ρ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.1.13" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.13" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phil.1.13" ∷ word (γ ∷ ε ∷ ν ∷ έ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Phil.1.13" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.13" ∷ word (ὅ ∷ ∙λ ∷ ῳ ∷ []) "Phil.1.13" ∷ word (τ ∷ ῷ ∷ []) "Phil.1.13" ∷ word (π ∷ ρ ∷ α ∷ ι ∷ τ ∷ ω ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phil.1.13" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.13" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.1.13" ∷ word (∙λ ∷ ο ∷ ι ∷ π ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.1.13" ∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "Phil.1.13" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.14" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.1.14" ∷ word (π ∷ ∙λ ∷ ε ∷ ί ∷ ο ∷ ν ∷ α ∷ ς ∷ []) "Phil.1.14" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Phil.1.14" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ῶ ∷ ν ∷ []) "Phil.1.14" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.14" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phil.1.14" ∷ word (π ∷ ε ∷ π ∷ ο ∷ ι ∷ θ ∷ ό ∷ τ ∷ α ∷ ς ∷ []) "Phil.1.14" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.1.14" ∷ word (δ ∷ ε ∷ σ ∷ μ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.1.14" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.1.14" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ο ∷ τ ∷ έ ∷ ρ ∷ ω ∷ ς ∷ []) "Phil.1.14" ∷ word (τ ∷ ο ∷ ∙λ ∷ μ ∷ ᾶ ∷ ν ∷ []) "Phil.1.14" ∷ word (ἀ ∷ φ ∷ ό ∷ β ∷ ω ∷ ς ∷ []) "Phil.1.14" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Phil.1.14" ∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ν ∷ []) "Phil.1.14" ∷ word (∙λ ∷ α ∷ ∙λ ∷ ε ∷ ῖ ∷ ν ∷ []) "Phil.1.14" ∷ word (Τ ∷ ι ∷ ν ∷ ὲ ∷ ς ∷ []) "Phil.1.15" ∷ word (μ ∷ ὲ ∷ ν ∷ []) "Phil.1.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.15" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phil.1.15" ∷ word (φ ∷ θ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "Phil.1.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.15" ∷ word (ἔ ∷ ρ ∷ ι ∷ ν ∷ []) "Phil.1.15" ∷ word (τ ∷ ι ∷ ν ∷ ὲ ∷ ς ∷ []) "Phil.1.15" ∷ word (δ ∷ ὲ ∷ []) "Phil.1.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.15" ∷ word (δ ∷ ι ∷ []) "Phil.1.15" ∷ word (ε ∷ ὐ ∷ δ ∷ ο ∷ κ ∷ ί ∷ α ∷ ν ∷ []) "Phil.1.15" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Phil.1.15" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.1.15" ∷ word (κ ∷ η ∷ ρ ∷ ύ ∷ σ ∷ σ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "Phil.1.15" ∷ word (ο ∷ ἱ ∷ []) "Phil.1.16" ∷ word (μ ∷ ὲ ∷ ν ∷ []) "Phil.1.16" ∷ word (ἐ ∷ ξ ∷ []) "Phil.1.16" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ς ∷ []) "Phil.1.16" ∷ word (ε ∷ ἰ ∷ δ ∷ ό ∷ τ ∷ ε ∷ ς ∷ []) "Phil.1.16" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.1.16" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.1.16" ∷ word (ἀ ∷ π ∷ ο ∷ ∙λ ∷ ο ∷ γ ∷ ί ∷ α ∷ ν ∷ []) "Phil.1.16" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.1.16" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ο ∷ υ ∷ []) "Phil.1.16" ∷ word (κ ∷ ε ∷ ῖ ∷ μ ∷ α ∷ ι ∷ []) "Phil.1.16" ∷ word (ο ∷ ἱ ∷ []) "Phil.1.17" ∷ word (δ ∷ ὲ ∷ []) "Phil.1.17" ∷ word (ἐ ∷ ξ ∷ []) "Phil.1.17" ∷ word (ἐ ∷ ρ ∷ ι ∷ θ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "Phil.1.17" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Phil.1.17" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.1.17" ∷ word (κ ∷ α ∷ τ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ο ∷ υ ∷ σ ∷ ι ∷ ν ∷ []) "Phil.1.17" ∷ word (ο ∷ ὐ ∷ χ ∷ []) "Phil.1.17" ∷ word (ἁ ∷ γ ∷ ν ∷ ῶ ∷ ς ∷ []) "Phil.1.17" ∷ word (ο ∷ ἰ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Phil.1.17" ∷ word (θ ∷ ∙λ ∷ ῖ ∷ ψ ∷ ι ∷ ν ∷ []) "Phil.1.17" ∷ word (ἐ ∷ γ ∷ ε ∷ ί ∷ ρ ∷ ε ∷ ι ∷ ν ∷ []) "Phil.1.17" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.1.17" ∷ word (δ ∷ ε ∷ σ ∷ μ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.1.17" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.1.17" ∷ word (τ ∷ ί ∷ []) "Phil.1.18" ∷ word (γ ∷ ά ∷ ρ ∷ []) "Phil.1.18" ∷ word (π ∷ ∙λ ∷ ὴ ∷ ν ∷ []) "Phil.1.18" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.1.18" ∷ word (π ∷ α ∷ ν ∷ τ ∷ ὶ ∷ []) "Phil.1.18" ∷ word (τ ∷ ρ ∷ ό ∷ π ∷ ῳ ∷ []) "Phil.1.18" ∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "Phil.1.18" ∷ word (π ∷ ρ ∷ ο ∷ φ ∷ ά ∷ σ ∷ ε ∷ ι ∷ []) "Phil.1.18" ∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "Phil.1.18" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ε ∷ ί ∷ ᾳ ∷ []) "Phil.1.18" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "Phil.1.18" ∷ word (κ ∷ α ∷ τ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ∙λ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "Phil.1.18" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.18" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.18" ∷ word (τ ∷ ο ∷ ύ ∷ τ ∷ ῳ ∷ []) "Phil.1.18" ∷ word (χ ∷ α ∷ ί ∷ ρ ∷ ω ∷ []) "Phil.1.18" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.1.18" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.18" ∷ word (χ ∷ α ∷ ρ ∷ ή ∷ σ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Phil.1.18" ∷ word (ο ∷ ἶ ∷ δ ∷ α ∷ []) "Phil.1.19" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phil.1.19" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.1.19" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ό ∷ []) "Phil.1.19" ∷ word (μ ∷ ο ∷ ι ∷ []) "Phil.1.19" ∷ word (ἀ ∷ π ∷ ο ∷ β ∷ ή ∷ σ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "Phil.1.19" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.1.19" ∷ word (σ ∷ ω ∷ τ ∷ η ∷ ρ ∷ ί ∷ α ∷ ν ∷ []) "Phil.1.19" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phil.1.19" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.1.19" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.1.19" ∷ word (δ ∷ ε ∷ ή ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "Phil.1.19" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.19" ∷ word (ἐ ∷ π ∷ ι ∷ χ ∷ ο ∷ ρ ∷ η ∷ γ ∷ ί ∷ α ∷ ς ∷ []) "Phil.1.19" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.1.19" ∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "Phil.1.19" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.1.19" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.1.19" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Phil.1.20" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.1.20" ∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ρ ∷ α ∷ δ ∷ ο ∷ κ ∷ ί ∷ α ∷ ν ∷ []) "Phil.1.20" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.20" ∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ δ ∷ α ∷ []) "Phil.1.20" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.1.20" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.1.20" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.20" ∷ word (ο ∷ ὐ ∷ δ ∷ ε ∷ ν ∷ ὶ ∷ []) "Phil.1.20" ∷ word (α ∷ ἰ ∷ σ ∷ χ ∷ υ ∷ ν ∷ θ ∷ ή ∷ σ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Phil.1.20" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "Phil.1.20" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.20" ∷ word (π ∷ ά ∷ σ ∷ ῃ ∷ []) "Phil.1.20" ∷ word (π ∷ α ∷ ρ ∷ ρ ∷ η ∷ σ ∷ ί ∷ ᾳ ∷ []) "Phil.1.20" ∷ word (ὡ ∷ ς ∷ []) "Phil.1.20" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "Phil.1.20" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.20" ∷ word (ν ∷ ῦ ∷ ν ∷ []) "Phil.1.20" ∷ word (μ ∷ ε ∷ γ ∷ α ∷ ∙λ ∷ υ ∷ ν ∷ θ ∷ ή ∷ σ ∷ ε ∷ τ ∷ α ∷ ι ∷ []) "Phil.1.20" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "Phil.1.20" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.20" ∷ word (τ ∷ ῷ ∷ []) "Phil.1.20" ∷ word (σ ∷ ώ ∷ μ ∷ α ∷ τ ∷ ί ∷ []) "Phil.1.20" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.1.20" ∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "Phil.1.20" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phil.1.20" ∷ word (ζ ∷ ω ∷ ῆ ∷ ς ∷ []) "Phil.1.20" ∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "Phil.1.20" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phil.1.20" ∷ word (θ ∷ α ∷ ν ∷ ά ∷ τ ∷ ο ∷ υ ∷ []) "Phil.1.20" ∷ word (ἐ ∷ μ ∷ ο ∷ ὶ ∷ []) "Phil.1.21" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phil.1.21" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.21" ∷ word (ζ ∷ ῆ ∷ ν ∷ []) "Phil.1.21" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "Phil.1.21" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.21" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.21" ∷ word (ἀ ∷ π ∷ ο ∷ θ ∷ α ∷ ν ∷ ε ∷ ῖ ∷ ν ∷ []) "Phil.1.21" ∷ word (κ ∷ έ ∷ ρ ∷ δ ∷ ο ∷ ς ∷ []) "Phil.1.21" ∷ word (ε ∷ ἰ ∷ []) "Phil.1.22" ∷ word (δ ∷ ὲ ∷ []) "Phil.1.22" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.22" ∷ word (ζ ∷ ῆ ∷ ν ∷ []) "Phil.1.22" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.22" ∷ word (σ ∷ α ∷ ρ ∷ κ ∷ ί ∷ []) "Phil.1.22" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ό ∷ []) "Phil.1.22" ∷ word (μ ∷ ο ∷ ι ∷ []) "Phil.1.22" ∷ word (κ ∷ α ∷ ρ ∷ π ∷ ὸ ∷ ς ∷ []) "Phil.1.22" ∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ υ ∷ []) "Phil.1.22" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.22" ∷ word (τ ∷ ί ∷ []) "Phil.1.22" ∷ word (α ∷ ἱ ∷ ρ ∷ ή ∷ σ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Phil.1.22" ∷ word (ο ∷ ὐ ∷ []) "Phil.1.22" ∷ word (γ ∷ ν ∷ ω ∷ ρ ∷ ί ∷ ζ ∷ ω ∷ []) "Phil.1.22" ∷ word (σ ∷ υ ∷ ν ∷ έ ∷ χ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Phil.1.23" ∷ word (δ ∷ ὲ ∷ []) "Phil.1.23" ∷ word (ἐ ∷ κ ∷ []) "Phil.1.23" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Phil.1.23" ∷ word (δ ∷ ύ ∷ ο ∷ []) "Phil.1.23" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.1.23" ∷ word (ἐ ∷ π ∷ ι ∷ θ ∷ υ ∷ μ ∷ ί ∷ α ∷ ν ∷ []) "Phil.1.23" ∷ word (ἔ ∷ χ ∷ ω ∷ ν ∷ []) "Phil.1.23" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.1.23" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.23" ∷ word (ἀ ∷ ν ∷ α ∷ ∙λ ∷ ῦ ∷ σ ∷ α ∷ ι ∷ []) "Phil.1.23" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.23" ∷ word (σ ∷ ὺ ∷ ν ∷ []) "Phil.1.23" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phil.1.23" ∷ word (ε ∷ ἶ ∷ ν ∷ α ∷ ι ∷ []) "Phil.1.23" ∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ῷ ∷ []) "Phil.1.23" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phil.1.23" ∷ word (μ ∷ ᾶ ∷ ∙λ ∷ ∙λ ∷ ο ∷ ν ∷ []) "Phil.1.23" ∷ word (κ ∷ ρ ∷ ε ∷ ῖ ∷ σ ∷ σ ∷ ο ∷ ν ∷ []) "Phil.1.23" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.24" ∷ word (δ ∷ ὲ ∷ []) "Phil.1.24" ∷ word (ἐ ∷ π ∷ ι ∷ μ ∷ έ ∷ ν ∷ ε ∷ ι ∷ ν ∷ []) "Phil.1.24" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.24" ∷ word (τ ∷ ῇ ∷ []) "Phil.1.24" ∷ word (σ ∷ α ∷ ρ ∷ κ ∷ ὶ ∷ []) "Phil.1.24" ∷ word (ἀ ∷ ν ∷ α ∷ γ ∷ κ ∷ α ∷ ι ∷ ό ∷ τ ∷ ε ∷ ρ ∷ ο ∷ ν ∷ []) "Phil.1.24" ∷ word (δ ∷ ι ∷ []) "Phil.1.24" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.1.24" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.25" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Phil.1.25" ∷ word (π ∷ ε ∷ π ∷ ο ∷ ι ∷ θ ∷ ὼ ∷ ς ∷ []) "Phil.1.25" ∷ word (ο ∷ ἶ ∷ δ ∷ α ∷ []) "Phil.1.25" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.1.25" ∷ word (μ ∷ ε ∷ ν ∷ ῶ ∷ []) "Phil.1.25" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.25" ∷ word (π ∷ α ∷ ρ ∷ α ∷ μ ∷ ε ∷ ν ∷ ῶ ∷ []) "Phil.1.25" ∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "Phil.1.25" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.1.25" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.1.25" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.1.25" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.1.25" ∷ word (π ∷ ρ ∷ ο ∷ κ ∷ ο ∷ π ∷ ὴ ∷ ν ∷ []) "Phil.1.25" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.25" ∷ word (χ ∷ α ∷ ρ ∷ ὰ ∷ ν ∷ []) "Phil.1.25" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.1.25" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "Phil.1.25" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.1.26" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.26" ∷ word (κ ∷ α ∷ ύ ∷ χ ∷ η ∷ μ ∷ α ∷ []) "Phil.1.26" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.1.26" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ε ∷ ύ ∷ ῃ ∷ []) "Phil.1.26" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.26" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phil.1.26" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.1.26" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.26" ∷ word (ἐ ∷ μ ∷ ο ∷ ὶ ∷ []) "Phil.1.26" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phil.1.26" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.1.26" ∷ word (ἐ ∷ μ ∷ ῆ ∷ ς ∷ []) "Phil.1.26" ∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ α ∷ ς ∷ []) "Phil.1.26" ∷ word (π ∷ ά ∷ ∙λ ∷ ι ∷ ν ∷ []) "Phil.1.26" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "Phil.1.26" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.1.26" ∷ word (Μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "Phil.1.27" ∷ word (ἀ ∷ ξ ∷ ί ∷ ω ∷ ς ∷ []) "Phil.1.27" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.1.27" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ο ∷ υ ∷ []) "Phil.1.27" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.1.27" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.1.27" ∷ word (π ∷ ο ∷ ∙λ ∷ ι ∷ τ ∷ ε ∷ ύ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "Phil.1.27" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.1.27" ∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "Phil.1.27" ∷ word (ἐ ∷ ∙λ ∷ θ ∷ ὼ ∷ ν ∷ []) "Phil.1.27" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.27" ∷ word (ἰ ∷ δ ∷ ὼ ∷ ν ∷ []) "Phil.1.27" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.1.27" ∷ word (ε ∷ ἴ ∷ τ ∷ ε ∷ []) "Phil.1.27" ∷ word (ἀ ∷ π ∷ ὼ ∷ ν ∷ []) "Phil.1.27" ∷ word (ἀ ∷ κ ∷ ο ∷ ύ ∷ ω ∷ []) "Phil.1.27" ∷ word (τ ∷ ὰ ∷ []) "Phil.1.27" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Phil.1.27" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.1.27" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.1.27" ∷ word (σ ∷ τ ∷ ή ∷ κ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.1.27" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.27" ∷ word (ἑ ∷ ν ∷ ὶ ∷ []) "Phil.1.27" ∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "Phil.1.27" ∷ word (μ ∷ ι ∷ ᾷ ∷ []) "Phil.1.27" ∷ word (ψ ∷ υ ∷ χ ∷ ῇ ∷ []) "Phil.1.27" ∷ word (σ ∷ υ ∷ ν ∷ α ∷ θ ∷ ∙λ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Phil.1.27" ∷ word (τ ∷ ῇ ∷ []) "Phil.1.27" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "Phil.1.27" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.1.27" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ο ∷ υ ∷ []) "Phil.1.27" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.28" ∷ word (μ ∷ ὴ ∷ []) "Phil.1.28" ∷ word (π ∷ τ ∷ υ ∷ ρ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Phil.1.28" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.28" ∷ word (μ ∷ η ∷ δ ∷ ε ∷ ν ∷ ὶ ∷ []) "Phil.1.28" ∷ word (ὑ ∷ π ∷ ὸ ∷ []) "Phil.1.28" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Phil.1.28" ∷ word (ἀ ∷ ν ∷ τ ∷ ι ∷ κ ∷ ε ∷ ι ∷ μ ∷ έ ∷ ν ∷ ω ∷ ν ∷ []) "Phil.1.28" ∷ word (ἥ ∷ τ ∷ ι ∷ ς ∷ []) "Phil.1.28" ∷ word (ἐ ∷ σ ∷ τ ∷ ὶ ∷ ν ∷ []) "Phil.1.28" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.1.28" ∷ word (ἔ ∷ ν ∷ δ ∷ ε ∷ ι ∷ ξ ∷ ι ∷ ς ∷ []) "Phil.1.28" ∷ word (ἀ ∷ π ∷ ω ∷ ∙λ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "Phil.1.28" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.1.28" ∷ word (δ ∷ ὲ ∷ []) "Phil.1.28" ∷ word (σ ∷ ω ∷ τ ∷ η ∷ ρ ∷ ί ∷ α ∷ ς ∷ []) "Phil.1.28" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.28" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Phil.1.28" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "Phil.1.28" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Phil.1.28" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.1.29" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.1.29" ∷ word (ἐ ∷ χ ∷ α ∷ ρ ∷ ί ∷ σ ∷ θ ∷ η ∷ []) "Phil.1.29" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.29" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "Phil.1.29" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.1.29" ∷ word (ο ∷ ὐ ∷ []) "Phil.1.29" ∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "Phil.1.29" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.29" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.1.29" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.1.29" ∷ word (π ∷ ι ∷ σ ∷ τ ∷ ε ∷ ύ ∷ ε ∷ ι ∷ ν ∷ []) "Phil.1.29" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.1.29" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.29" ∷ word (τ ∷ ὸ ∷ []) "Phil.1.29" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "Phil.1.29" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.1.29" ∷ word (π ∷ ά ∷ σ ∷ χ ∷ ε ∷ ι ∷ ν ∷ []) "Phil.1.29" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Phil.1.30" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.1.30" ∷ word (ἀ ∷ γ ∷ ῶ ∷ ν ∷ α ∷ []) "Phil.1.30" ∷ word (ἔ ∷ χ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Phil.1.30" ∷ word (ο ∷ ἷ ∷ ο ∷ ν ∷ []) "Phil.1.30" ∷ word (ε ∷ ἴ ∷ δ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.1.30" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.30" ∷ word (ἐ ∷ μ ∷ ο ∷ ὶ ∷ []) "Phil.1.30" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.1.30" ∷ word (ν ∷ ῦ ∷ ν ∷ []) "Phil.1.30" ∷ word (ἀ ∷ κ ∷ ο ∷ ύ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.1.30" ∷ word (ἐ ∷ ν ∷ []) "Phil.1.30" ∷ word (ἐ ∷ μ ∷ ο ∷ ί ∷ []) "Phil.1.30" ∷ word (Ε ∷ ἴ ∷ []) "Phil.2.1" ∷ word (τ ∷ ι ∷ ς ∷ []) "Phil.2.1" ∷ word (ο ∷ ὖ ∷ ν ∷ []) "Phil.2.1" ∷ word (π ∷ α ∷ ρ ∷ ά ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ι ∷ ς ∷ []) "Phil.2.1" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.1" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phil.2.1" ∷ word (ε ∷ ἴ ∷ []) "Phil.2.1" ∷ word (τ ∷ ι ∷ []) "Phil.2.1" ∷ word (π ∷ α ∷ ρ ∷ α ∷ μ ∷ ύ ∷ θ ∷ ι ∷ ο ∷ ν ∷ []) "Phil.2.1" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ς ∷ []) "Phil.2.1" ∷ word (ε ∷ ἴ ∷ []) "Phil.2.1" ∷ word (τ ∷ ι ∷ ς ∷ []) "Phil.2.1" ∷ word (κ ∷ ο ∷ ι ∷ ν ∷ ω ∷ ν ∷ ί ∷ α ∷ []) "Phil.2.1" ∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "Phil.2.1" ∷ word (ε ∷ ἴ ∷ []) "Phil.2.1" ∷ word (τ ∷ ι ∷ ς ∷ []) "Phil.2.1" ∷ word (σ ∷ π ∷ ∙λ ∷ ά ∷ γ ∷ χ ∷ ν ∷ α ∷ []) "Phil.2.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.1" ∷ word (ο ∷ ἰ ∷ κ ∷ τ ∷ ι ∷ ρ ∷ μ ∷ ο ∷ ί ∷ []) "Phil.2.1" ∷ word (π ∷ ∙λ ∷ η ∷ ρ ∷ ώ ∷ σ ∷ α ∷ τ ∷ έ ∷ []) "Phil.2.2" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.2.2" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.2.2" ∷ word (χ ∷ α ∷ ρ ∷ ὰ ∷ ν ∷ []) "Phil.2.2" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.2.2" ∷ word (τ ∷ ὸ ∷ []) "Phil.2.2" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ []) "Phil.2.2" ∷ word (φ ∷ ρ ∷ ο ∷ ν ∷ ῆ ∷ τ ∷ ε ∷ []) "Phil.2.2" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.2.2" ∷ word (α ∷ ὐ ∷ τ ∷ ὴ ∷ ν ∷ []) "Phil.2.2" ∷ word (ἀ ∷ γ ∷ ά ∷ π ∷ η ∷ ν ∷ []) "Phil.2.2" ∷ word (ἔ ∷ χ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Phil.2.2" ∷ word (σ ∷ ύ ∷ μ ∷ ψ ∷ υ ∷ χ ∷ ο ∷ ι ∷ []) "Phil.2.2" ∷ word (τ ∷ ὸ ∷ []) "Phil.2.2" ∷ word (ἓ ∷ ν ∷ []) "Phil.2.2" ∷ word (φ ∷ ρ ∷ ο ∷ ν ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Phil.2.2" ∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ ν ∷ []) "Phil.2.3" ∷ word (κ ∷ α ∷ τ ∷ []) "Phil.2.3" ∷ word (ἐ ∷ ρ ∷ ι ∷ θ ∷ ε ∷ ί ∷ α ∷ ν ∷ []) "Phil.2.3" ∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ []) "Phil.2.3" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Phil.2.3" ∷ word (κ ∷ ε ∷ ν ∷ ο ∷ δ ∷ ο ∷ ξ ∷ ί ∷ α ∷ ν ∷ []) "Phil.2.3" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.2.3" ∷ word (τ ∷ ῇ ∷ []) "Phil.2.3" ∷ word (τ ∷ α ∷ π ∷ ε ∷ ι ∷ ν ∷ ο ∷ φ ∷ ρ ∷ ο ∷ σ ∷ ύ ∷ ν ∷ ῃ ∷ []) "Phil.2.3" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ή ∷ ∙λ ∷ ο ∷ υ ∷ ς ∷ []) "Phil.2.3" ∷ word (ἡ ∷ γ ∷ ο ∷ ύ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Phil.2.3" ∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ έ ∷ χ ∷ ο ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Phil.2.3" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "Phil.2.3" ∷ word (μ ∷ ὴ ∷ []) "Phil.2.4" ∷ word (τ ∷ ὰ ∷ []) "Phil.2.4" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "Phil.2.4" ∷ word (ἕ ∷ κ ∷ α ∷ σ ∷ τ ∷ ο ∷ ι ∷ []) "Phil.2.4" ∷ word (σ ∷ κ ∷ ο ∷ π ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Phil.2.4" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.2.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.4" ∷ word (τ ∷ ὰ ∷ []) "Phil.2.4" ∷ word (ἑ ∷ τ ∷ έ ∷ ρ ∷ ω ∷ ν ∷ []) "Phil.2.4" ∷ word (ἕ ∷ κ ∷ α ∷ σ ∷ τ ∷ ο ∷ ι ∷ []) "Phil.2.4" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Phil.2.5" ∷ word (φ ∷ ρ ∷ ο ∷ ν ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "Phil.2.5" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.5" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.2.5" ∷ word (ὃ ∷ []) "Phil.2.5" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.5" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.5" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phil.2.5" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.2.5" ∷ word (ὃ ∷ ς ∷ []) "Phil.2.6" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.6" ∷ word (μ ∷ ο ∷ ρ ∷ φ ∷ ῇ ∷ []) "Phil.2.6" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Phil.2.6" ∷ word (ὑ ∷ π ∷ ά ∷ ρ ∷ χ ∷ ω ∷ ν ∷ []) "Phil.2.6" ∷ word (ο ∷ ὐ ∷ χ ∷ []) "Phil.2.6" ∷ word (ἁ ∷ ρ ∷ π ∷ α ∷ γ ∷ μ ∷ ὸ ∷ ν ∷ []) "Phil.2.6" ∷ word (ἡ ∷ γ ∷ ή ∷ σ ∷ α ∷ τ ∷ ο ∷ []) "Phil.2.6" ∷ word (τ ∷ ὸ ∷ []) "Phil.2.6" ∷ word (ε ∷ ἶ ∷ ν ∷ α ∷ ι ∷ []) "Phil.2.6" ∷ word (ἴ ∷ σ ∷ α ∷ []) "Phil.2.6" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "Phil.2.6" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.2.7" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.2.7" ∷ word (ἐ ∷ κ ∷ έ ∷ ν ∷ ω ∷ σ ∷ ε ∷ ν ∷ []) "Phil.2.7" ∷ word (μ ∷ ο ∷ ρ ∷ φ ∷ ὴ ∷ ν ∷ []) "Phil.2.7" ∷ word (δ ∷ ο ∷ ύ ∷ ∙λ ∷ ο ∷ υ ∷ []) "Phil.2.7" ∷ word (∙λ ∷ α ∷ β ∷ ώ ∷ ν ∷ []) "Phil.2.7" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.7" ∷ word (ὁ ∷ μ ∷ ο ∷ ι ∷ ώ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "Phil.2.7" ∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ω ∷ ν ∷ []) "Phil.2.7" ∷ word (γ ∷ ε ∷ ν ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Phil.2.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.7" ∷ word (σ ∷ χ ∷ ή ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "Phil.2.7" ∷ word (ε ∷ ὑ ∷ ρ ∷ ε ∷ θ ∷ ε ∷ ὶ ∷ ς ∷ []) "Phil.2.7" ∷ word (ὡ ∷ ς ∷ []) "Phil.2.7" ∷ word (ἄ ∷ ν ∷ θ ∷ ρ ∷ ω ∷ π ∷ ο ∷ ς ∷ []) "Phil.2.7" ∷ word (ἐ ∷ τ ∷ α ∷ π ∷ ε ∷ ί ∷ ν ∷ ω ∷ σ ∷ ε ∷ ν ∷ []) "Phil.2.8" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.2.8" ∷ word (γ ∷ ε ∷ ν ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Phil.2.8" ∷ word (ὑ ∷ π ∷ ή ∷ κ ∷ ο ∷ ο ∷ ς ∷ []) "Phil.2.8" ∷ word (μ ∷ έ ∷ χ ∷ ρ ∷ ι ∷ []) "Phil.2.8" ∷ word (θ ∷ α ∷ ν ∷ ά ∷ τ ∷ ο ∷ υ ∷ []) "Phil.2.8" ∷ word (θ ∷ α ∷ ν ∷ ά ∷ τ ∷ ο ∷ υ ∷ []) "Phil.2.8" ∷ word (δ ∷ ὲ ∷ []) "Phil.2.8" ∷ word (σ ∷ τ ∷ α ∷ υ ∷ ρ ∷ ο ∷ ῦ ∷ []) "Phil.2.8" ∷ word (δ ∷ ι ∷ ὸ ∷ []) "Phil.2.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.9" ∷ word (ὁ ∷ []) "Phil.2.9" ∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "Phil.2.9" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.2.9" ∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ ύ ∷ ψ ∷ ω ∷ σ ∷ ε ∷ ν ∷ []) "Phil.2.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.9" ∷ word (ἐ ∷ χ ∷ α ∷ ρ ∷ ί ∷ σ ∷ α ∷ τ ∷ ο ∷ []) "Phil.2.9" ∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "Phil.2.9" ∷ word (τ ∷ ὸ ∷ []) "Phil.2.9" ∷ word (ὄ ∷ ν ∷ ο ∷ μ ∷ α ∷ []) "Phil.2.9" ∷ word (τ ∷ ὸ ∷ []) "Phil.2.9" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "Phil.2.9" ∷ word (π ∷ ᾶ ∷ ν ∷ []) "Phil.2.9" ∷ word (ὄ ∷ ν ∷ ο ∷ μ ∷ α ∷ []) "Phil.2.9" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.2.10" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.10" ∷ word (τ ∷ ῷ ∷ []) "Phil.2.10" ∷ word (ὀ ∷ ν ∷ ό ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "Phil.2.10" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.2.10" ∷ word (π ∷ ᾶ ∷ ν ∷ []) "Phil.2.10" ∷ word (γ ∷ ό ∷ ν ∷ υ ∷ []) "Phil.2.10" ∷ word (κ ∷ ά ∷ μ ∷ ψ ∷ ῃ ∷ []) "Phil.2.10" ∷ word (ἐ ∷ π ∷ ο ∷ υ ∷ ρ ∷ α ∷ ν ∷ ί ∷ ω ∷ ν ∷ []) "Phil.2.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.10" ∷ word (ἐ ∷ π ∷ ι ∷ γ ∷ ε ∷ ί ∷ ω ∷ ν ∷ []) "Phil.2.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.10" ∷ word (κ ∷ α ∷ τ ∷ α ∷ χ ∷ θ ∷ ο ∷ ν ∷ ί ∷ ω ∷ ν ∷ []) "Phil.2.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.11" ∷ word (π ∷ ᾶ ∷ σ ∷ α ∷ []) "Phil.2.11" ∷ word (γ ∷ ∙λ ∷ ῶ ∷ σ ∷ σ ∷ α ∷ []) "Phil.2.11" ∷ word (ἐ ∷ ξ ∷ ο ∷ μ ∷ ο ∷ ∙λ ∷ ο ∷ γ ∷ ή ∷ σ ∷ η ∷ τ ∷ α ∷ ι ∷ []) "Phil.2.11" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.2.11" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "Phil.2.11" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ς ∷ []) "Phil.2.11" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ς ∷ []) "Phil.2.11" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.2.11" ∷ word (δ ∷ ό ∷ ξ ∷ α ∷ ν ∷ []) "Phil.2.11" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Phil.2.11" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ό ∷ ς ∷ []) "Phil.2.11" ∷ word (Ὥ ∷ σ ∷ τ ∷ ε ∷ []) "Phil.2.12" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ο ∷ ί ∷ []) "Phil.2.12" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.2.12" ∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "Phil.2.12" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "Phil.2.12" ∷ word (ὑ ∷ π ∷ η ∷ κ ∷ ο ∷ ύ ∷ σ ∷ α ∷ τ ∷ ε ∷ []) "Phil.2.12" ∷ word (μ ∷ ὴ ∷ []) "Phil.2.12" ∷ word (ὡ ∷ ς ∷ []) "Phil.2.12" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.12" ∷ word (τ ∷ ῇ ∷ []) "Phil.2.12" ∷ word (π ∷ α ∷ ρ ∷ ο ∷ υ ∷ σ ∷ ί ∷ ᾳ ∷ []) "Phil.2.12" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.2.12" ∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "Phil.2.12" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.2.12" ∷ word (ν ∷ ῦ ∷ ν ∷ []) "Phil.2.12" ∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ῷ ∷ []) "Phil.2.12" ∷ word (μ ∷ ᾶ ∷ ∙λ ∷ ∙λ ∷ ο ∷ ν ∷ []) "Phil.2.12" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.12" ∷ word (τ ∷ ῇ ∷ []) "Phil.2.12" ∷ word (ἀ ∷ π ∷ ο ∷ υ ∷ σ ∷ ί ∷ ᾳ ∷ []) "Phil.2.12" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.2.12" ∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "Phil.2.12" ∷ word (φ ∷ ό ∷ β ∷ ο ∷ υ ∷ []) "Phil.2.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.12" ∷ word (τ ∷ ρ ∷ ό ∷ μ ∷ ο ∷ υ ∷ []) "Phil.2.12" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.2.12" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "Phil.2.12" ∷ word (σ ∷ ω ∷ τ ∷ η ∷ ρ ∷ ί ∷ α ∷ ν ∷ []) "Phil.2.12" ∷ word (κ ∷ α ∷ τ ∷ ε ∷ ρ ∷ γ ∷ ά ∷ ζ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "Phil.2.12" ∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "Phil.2.13" ∷ word (γ ∷ ά ∷ ρ ∷ []) "Phil.2.13" ∷ word (ἐ ∷ σ ∷ τ ∷ ι ∷ ν ∷ []) "Phil.2.13" ∷ word (ὁ ∷ []) "Phil.2.13" ∷ word (ἐ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ῶ ∷ ν ∷ []) "Phil.2.13" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.13" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.2.13" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.13" ∷ word (τ ∷ ὸ ∷ []) "Phil.2.13" ∷ word (θ ∷ έ ∷ ∙λ ∷ ε ∷ ι ∷ ν ∷ []) "Phil.2.13" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.13" ∷ word (τ ∷ ὸ ∷ []) "Phil.2.13" ∷ word (ἐ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ε ∷ ῖ ∷ ν ∷ []) "Phil.2.13" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "Phil.2.13" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.2.13" ∷ word (ε ∷ ὐ ∷ δ ∷ ο ∷ κ ∷ ί ∷ α ∷ ς ∷ []) "Phil.2.13" ∷ word (Π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Phil.2.14" ∷ word (π ∷ ο ∷ ι ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "Phil.2.14" ∷ word (χ ∷ ω ∷ ρ ∷ ὶ ∷ ς ∷ []) "Phil.2.14" ∷ word (γ ∷ ο ∷ γ ∷ γ ∷ υ ∷ σ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.2.14" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.14" ∷ word (δ ∷ ι ∷ α ∷ ∙λ ∷ ο ∷ γ ∷ ι ∷ σ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.2.14" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.2.15" ∷ word (γ ∷ έ ∷ ν ∷ η ∷ σ ∷ θ ∷ ε ∷ []) "Phil.2.15" ∷ word (ἄ ∷ μ ∷ ε ∷ μ ∷ π ∷ τ ∷ ο ∷ ι ∷ []) "Phil.2.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.15" ∷ word (ἀ ∷ κ ∷ έ ∷ ρ ∷ α ∷ ι ∷ ο ∷ ι ∷ []) "Phil.2.15" ∷ word (τ ∷ έ ∷ κ ∷ ν ∷ α ∷ []) "Phil.2.15" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Phil.2.15" ∷ word (ἄ ∷ μ ∷ ω ∷ μ ∷ α ∷ []) "Phil.2.15" ∷ word (μ ∷ έ ∷ σ ∷ ο ∷ ν ∷ []) "Phil.2.15" ∷ word (γ ∷ ε ∷ ν ∷ ε ∷ ᾶ ∷ ς ∷ []) "Phil.2.15" ∷ word (σ ∷ κ ∷ ο ∷ ∙λ ∷ ι ∷ ᾶ ∷ ς ∷ []) "Phil.2.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.15" ∷ word (δ ∷ ι ∷ ε ∷ σ ∷ τ ∷ ρ ∷ α ∷ μ ∷ μ ∷ έ ∷ ν ∷ η ∷ ς ∷ []) "Phil.2.15" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.15" ∷ word (ο ∷ ἷ ∷ ς ∷ []) "Phil.2.15" ∷ word (φ ∷ α ∷ ί ∷ ν ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "Phil.2.15" ∷ word (ὡ ∷ ς ∷ []) "Phil.2.15" ∷ word (φ ∷ ω ∷ σ ∷ τ ∷ ῆ ∷ ρ ∷ ε ∷ ς ∷ []) "Phil.2.15" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.15" ∷ word (κ ∷ ό ∷ σ ∷ μ ∷ ῳ ∷ []) "Phil.2.15" ∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ν ∷ []) "Phil.2.16" ∷ word (ζ ∷ ω ∷ ῆ ∷ ς ∷ []) "Phil.2.16" ∷ word (ἐ ∷ π ∷ έ ∷ χ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Phil.2.16" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.2.16" ∷ word (κ ∷ α ∷ ύ ∷ χ ∷ η ∷ μ ∷ α ∷ []) "Phil.2.16" ∷ word (ἐ ∷ μ ∷ ο ∷ ὶ ∷ []) "Phil.2.16" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.2.16" ∷ word (ἡ ∷ μ ∷ έ ∷ ρ ∷ α ∷ ν ∷ []) "Phil.2.16" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.2.16" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.2.16" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "Phil.2.16" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.2.16" ∷ word (κ ∷ ε ∷ ν ∷ ὸ ∷ ν ∷ []) "Phil.2.16" ∷ word (ἔ ∷ δ ∷ ρ ∷ α ∷ μ ∷ ο ∷ ν ∷ []) "Phil.2.16" ∷ word (ο ∷ ὐ ∷ δ ∷ ὲ ∷ []) "Phil.2.16" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.2.16" ∷ word (κ ∷ ε ∷ ν ∷ ὸ ∷ ν ∷ []) "Phil.2.16" ∷ word (ἐ ∷ κ ∷ ο ∷ π ∷ ί ∷ α ∷ σ ∷ α ∷ []) "Phil.2.16" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.2.17" ∷ word (ε ∷ ἰ ∷ []) "Phil.2.17" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.17" ∷ word (σ ∷ π ∷ έ ∷ ν ∷ δ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Phil.2.17" ∷ word (ἐ ∷ π ∷ ὶ ∷ []) "Phil.2.17" ∷ word (τ ∷ ῇ ∷ []) "Phil.2.17" ∷ word (θ ∷ υ ∷ σ ∷ ί ∷ ᾳ ∷ []) "Phil.2.17" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.17" ∷ word (∙λ ∷ ε ∷ ι ∷ τ ∷ ο ∷ υ ∷ ρ ∷ γ ∷ ί ∷ ᾳ ∷ []) "Phil.2.17" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.2.17" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "Phil.2.17" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.2.17" ∷ word (χ ∷ α ∷ ί ∷ ρ ∷ ω ∷ []) "Phil.2.17" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.17" ∷ word (σ ∷ υ ∷ γ ∷ χ ∷ α ∷ ί ∷ ρ ∷ ω ∷ []) "Phil.2.17" ∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "Phil.2.17" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.2.17" ∷ word (τ ∷ ὸ ∷ []) "Phil.2.18" ∷ word (δ ∷ ὲ ∷ []) "Phil.2.18" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ []) "Phil.2.18" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.18" ∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "Phil.2.18" ∷ word (χ ∷ α ∷ ί ∷ ρ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.2.18" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.18" ∷ word (σ ∷ υ ∷ γ ∷ χ ∷ α ∷ ί ∷ ρ ∷ ε ∷ τ ∷ έ ∷ []) "Phil.2.18" ∷ word (μ ∷ ο ∷ ι ∷ []) "Phil.2.18" ∷ word (Ἐ ∷ ∙λ ∷ π ∷ ί ∷ ζ ∷ ω ∷ []) "Phil.2.19" ∷ word (δ ∷ ὲ ∷ []) "Phil.2.19" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.19" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phil.2.19" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.2.19" ∷ word (Τ ∷ ι ∷ μ ∷ ό ∷ θ ∷ ε ∷ ο ∷ ν ∷ []) "Phil.2.19" ∷ word (τ ∷ α ∷ χ ∷ έ ∷ ω ∷ ς ∷ []) "Phil.2.19" ∷ word (π ∷ έ ∷ μ ∷ ψ ∷ α ∷ ι ∷ []) "Phil.2.19" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.2.19" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.2.19" ∷ word (κ ∷ ἀ ∷ γ ∷ ὼ ∷ []) "Phil.2.19" ∷ word (ε ∷ ὐ ∷ ψ ∷ υ ∷ χ ∷ ῶ ∷ []) "Phil.2.19" ∷ word (γ ∷ ν ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.2.19" ∷ word (τ ∷ ὰ ∷ []) "Phil.2.19" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Phil.2.19" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.2.19" ∷ word (ο ∷ ὐ ∷ δ ∷ έ ∷ ν ∷ α ∷ []) "Phil.2.20" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phil.2.20" ∷ word (ἔ ∷ χ ∷ ω ∷ []) "Phil.2.20" ∷ word (ἰ ∷ σ ∷ ό ∷ ψ ∷ υ ∷ χ ∷ ο ∷ ν ∷ []) "Phil.2.20" ∷ word (ὅ ∷ σ ∷ τ ∷ ι ∷ ς ∷ []) "Phil.2.20" ∷ word (γ ∷ ν ∷ η ∷ σ ∷ ί ∷ ω ∷ ς ∷ []) "Phil.2.20" ∷ word (τ ∷ ὰ ∷ []) "Phil.2.20" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Phil.2.20" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.2.20" ∷ word (μ ∷ ε ∷ ρ ∷ ι ∷ μ ∷ ν ∷ ή ∷ σ ∷ ε ∷ ι ∷ []) "Phil.2.20" ∷ word (ο ∷ ἱ ∷ []) "Phil.2.21" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Phil.2.21" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phil.2.21" ∷ word (τ ∷ ὰ ∷ []) "Phil.2.21" ∷ word (ἑ ∷ α ∷ υ ∷ τ ∷ ῶ ∷ ν ∷ []) "Phil.2.21" ∷ word (ζ ∷ η ∷ τ ∷ ο ∷ ῦ ∷ σ ∷ ι ∷ ν ∷ []) "Phil.2.21" ∷ word (ο ∷ ὐ ∷ []) "Phil.2.21" ∷ word (τ ∷ ὰ ∷ []) "Phil.2.21" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.2.21" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.2.21" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.2.22" ∷ word (δ ∷ ὲ ∷ []) "Phil.2.22" ∷ word (δ ∷ ο ∷ κ ∷ ι ∷ μ ∷ ὴ ∷ ν ∷ []) "Phil.2.22" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.2.22" ∷ word (γ ∷ ι ∷ ν ∷ ώ ∷ σ ∷ κ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.2.22" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.2.22" ∷ word (ὡ ∷ ς ∷ []) "Phil.2.22" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὶ ∷ []) "Phil.2.22" ∷ word (τ ∷ έ ∷ κ ∷ ν ∷ ο ∷ ν ∷ []) "Phil.2.22" ∷ word (σ ∷ ὺ ∷ ν ∷ []) "Phil.2.22" ∷ word (ἐ ∷ μ ∷ ο ∷ ὶ ∷ []) "Phil.2.22" ∷ word (ἐ ∷ δ ∷ ο ∷ ύ ∷ ∙λ ∷ ε ∷ υ ∷ σ ∷ ε ∷ ν ∷ []) "Phil.2.22" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.2.22" ∷ word (τ ∷ ὸ ∷ []) "Phil.2.22" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ έ ∷ ∙λ ∷ ι ∷ ο ∷ ν ∷ []) "Phil.2.22" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ ν ∷ []) "Phil.2.23" ∷ word (μ ∷ ὲ ∷ ν ∷ []) "Phil.2.23" ∷ word (ο ∷ ὖ ∷ ν ∷ []) "Phil.2.23" ∷ word (ἐ ∷ ∙λ ∷ π ∷ ί ∷ ζ ∷ ω ∷ []) "Phil.2.23" ∷ word (π ∷ έ ∷ μ ∷ ψ ∷ α ∷ ι ∷ []) "Phil.2.23" ∷ word (ὡ ∷ ς ∷ []) "Phil.2.23" ∷ word (ἂ ∷ ν ∷ []) "Phil.2.23" ∷ word (ἀ ∷ φ ∷ ί ∷ δ ∷ ω ∷ []) "Phil.2.23" ∷ word (τ ∷ ὰ ∷ []) "Phil.2.23" ∷ word (π ∷ ε ∷ ρ ∷ ὶ ∷ []) "Phil.2.23" ∷ word (ἐ ∷ μ ∷ ὲ ∷ []) "Phil.2.23" ∷ word (ἐ ∷ ξ ∷ α ∷ υ ∷ τ ∷ ῆ ∷ ς ∷ []) "Phil.2.23" ∷ word (π ∷ έ ∷ π ∷ ο ∷ ι ∷ θ ∷ α ∷ []) "Phil.2.24" ∷ word (δ ∷ ὲ ∷ []) "Phil.2.24" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.24" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phil.2.24" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.2.24" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.24" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ς ∷ []) "Phil.2.24" ∷ word (τ ∷ α ∷ χ ∷ έ ∷ ω ∷ ς ∷ []) "Phil.2.24" ∷ word (ἐ ∷ ∙λ ∷ ε ∷ ύ ∷ σ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Phil.2.24" ∷ word (Ἀ ∷ ν ∷ α ∷ γ ∷ κ ∷ α ∷ ῖ ∷ ο ∷ ν ∷ []) "Phil.2.25" ∷ word (δ ∷ ὲ ∷ []) "Phil.2.25" ∷ word (ἡ ∷ γ ∷ η ∷ σ ∷ ά ∷ μ ∷ η ∷ ν ∷ []) "Phil.2.25" ∷ word (Ἐ ∷ π ∷ α ∷ φ ∷ ρ ∷ ό ∷ δ ∷ ι ∷ τ ∷ ο ∷ ν ∷ []) "Phil.2.25" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Phil.2.25" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ὸ ∷ ν ∷ []) "Phil.2.25" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.25" ∷ word (σ ∷ υ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ὸ ∷ ν ∷ []) "Phil.2.25" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.25" ∷ word (σ ∷ υ ∷ σ ∷ τ ∷ ρ ∷ α ∷ τ ∷ ι ∷ ώ ∷ τ ∷ η ∷ ν ∷ []) "Phil.2.25" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.2.25" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.2.25" ∷ word (δ ∷ ὲ ∷ []) "Phil.2.25" ∷ word (ἀ ∷ π ∷ ό ∷ σ ∷ τ ∷ ο ∷ ∙λ ∷ ο ∷ ν ∷ []) "Phil.2.25" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.25" ∷ word (∙λ ∷ ε ∷ ι ∷ τ ∷ ο ∷ υ ∷ ρ ∷ γ ∷ ὸ ∷ ν ∷ []) "Phil.2.25" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.2.25" ∷ word (χ ∷ ρ ∷ ε ∷ ί ∷ α ∷ ς ∷ []) "Phil.2.25" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.2.25" ∷ word (π ∷ έ ∷ μ ∷ ψ ∷ α ∷ ι ∷ []) "Phil.2.25" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "Phil.2.25" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.2.25" ∷ word (ἐ ∷ π ∷ ε ∷ ι ∷ δ ∷ ὴ ∷ []) "Phil.2.26" ∷ word (ἐ ∷ π ∷ ι ∷ π ∷ ο ∷ θ ∷ ῶ ∷ ν ∷ []) "Phil.2.26" ∷ word (ἦ ∷ ν ∷ []) "Phil.2.26" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Phil.2.26" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.2.26" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.26" ∷ word (ἀ ∷ δ ∷ η ∷ μ ∷ ο ∷ ν ∷ ῶ ∷ ν ∷ []) "Phil.2.26" ∷ word (δ ∷ ι ∷ ό ∷ τ ∷ ι ∷ []) "Phil.2.26" ∷ word (ἠ ∷ κ ∷ ο ∷ ύ ∷ σ ∷ α ∷ τ ∷ ε ∷ []) "Phil.2.26" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.2.26" ∷ word (ἠ ∷ σ ∷ θ ∷ έ ∷ ν ∷ η ∷ σ ∷ ε ∷ ν ∷ []) "Phil.2.26" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.27" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phil.2.27" ∷ word (ἠ ∷ σ ∷ θ ∷ έ ∷ ν ∷ η ∷ σ ∷ ε ∷ ν ∷ []) "Phil.2.27" ∷ word (π ∷ α ∷ ρ ∷ α ∷ π ∷ ∙λ ∷ ή ∷ σ ∷ ι ∷ ο ∷ ν ∷ []) "Phil.2.27" ∷ word (θ ∷ α ∷ ν ∷ ά ∷ τ ∷ ῳ ∷ []) "Phil.2.27" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.2.27" ∷ word (ὁ ∷ []) "Phil.2.27" ∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "Phil.2.27" ∷ word (ἠ ∷ ∙λ ∷ έ ∷ η ∷ σ ∷ ε ∷ ν ∷ []) "Phil.2.27" ∷ word (α ∷ ὐ ∷ τ ∷ ό ∷ ν ∷ []) "Phil.2.27" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "Phil.2.27" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.2.27" ∷ word (δ ∷ ὲ ∷ []) "Phil.2.27" ∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ν ∷ []) "Phil.2.27" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.2.27" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.27" ∷ word (ἐ ∷ μ ∷ έ ∷ []) "Phil.2.27" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.2.27" ∷ word (μ ∷ ὴ ∷ []) "Phil.2.27" ∷ word (∙λ ∷ ύ ∷ π ∷ η ∷ ν ∷ []) "Phil.2.27" ∷ word (ἐ ∷ π ∷ ὶ ∷ []) "Phil.2.27" ∷ word (∙λ ∷ ύ ∷ π ∷ η ∷ ν ∷ []) "Phil.2.27" ∷ word (σ ∷ χ ∷ ῶ ∷ []) "Phil.2.27" ∷ word (σ ∷ π ∷ ο ∷ υ ∷ δ ∷ α ∷ ι ∷ ο ∷ τ ∷ έ ∷ ρ ∷ ω ∷ ς ∷ []) "Phil.2.28" ∷ word (ο ∷ ὖ ∷ ν ∷ []) "Phil.2.28" ∷ word (ἔ ∷ π ∷ ε ∷ μ ∷ ψ ∷ α ∷ []) "Phil.2.28" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.2.28" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.2.28" ∷ word (ἰ ∷ δ ∷ ό ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Phil.2.28" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.2.28" ∷ word (π ∷ ά ∷ ∙λ ∷ ι ∷ ν ∷ []) "Phil.2.28" ∷ word (χ ∷ α ∷ ρ ∷ ῆ ∷ τ ∷ ε ∷ []) "Phil.2.28" ∷ word (κ ∷ ἀ ∷ γ ∷ ὼ ∷ []) "Phil.2.28" ∷ word (ἀ ∷ ∙λ ∷ υ ∷ π ∷ ό ∷ τ ∷ ε ∷ ρ ∷ ο ∷ ς ∷ []) "Phil.2.28" ∷ word (ὦ ∷ []) "Phil.2.28" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ δ ∷ έ ∷ χ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "Phil.2.29" ∷ word (ο ∷ ὖ ∷ ν ∷ []) "Phil.2.29" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.2.29" ∷ word (ἐ ∷ ν ∷ []) "Phil.2.29" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phil.2.29" ∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "Phil.2.29" ∷ word (π ∷ ά ∷ σ ∷ η ∷ ς ∷ []) "Phil.2.29" ∷ word (χ ∷ α ∷ ρ ∷ ᾶ ∷ ς ∷ []) "Phil.2.29" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.2.29" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.2.29" ∷ word (τ ∷ ο ∷ ι ∷ ο ∷ ύ ∷ τ ∷ ο ∷ υ ∷ ς ∷ []) "Phil.2.29" ∷ word (ἐ ∷ ν ∷ τ ∷ ί ∷ μ ∷ ο ∷ υ ∷ ς ∷ []) "Phil.2.29" ∷ word (ἔ ∷ χ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.2.29" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.2.30" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phil.2.30" ∷ word (τ ∷ ὸ ∷ []) "Phil.2.30" ∷ word (ἔ ∷ ρ ∷ γ ∷ ο ∷ ν ∷ []) "Phil.2.30" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.2.30" ∷ word (μ ∷ έ ∷ χ ∷ ρ ∷ ι ∷ []) "Phil.2.30" ∷ word (θ ∷ α ∷ ν ∷ ά ∷ τ ∷ ο ∷ υ ∷ []) "Phil.2.30" ∷ word (ἤ ∷ γ ∷ γ ∷ ι ∷ σ ∷ ε ∷ ν ∷ []) "Phil.2.30" ∷ word (π ∷ α ∷ ρ ∷ α ∷ β ∷ ο ∷ ∙λ ∷ ε ∷ υ ∷ σ ∷ ά ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Phil.2.30" ∷ word (τ ∷ ῇ ∷ []) "Phil.2.30" ∷ word (ψ ∷ υ ∷ χ ∷ ῇ ∷ []) "Phil.2.30" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.2.30" ∷ word (ἀ ∷ ν ∷ α ∷ π ∷ ∙λ ∷ η ∷ ρ ∷ ώ ∷ σ ∷ ῃ ∷ []) "Phil.2.30" ∷ word (τ ∷ ὸ ∷ []) "Phil.2.30" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.2.30" ∷ word (ὑ ∷ σ ∷ τ ∷ έ ∷ ρ ∷ η ∷ μ ∷ α ∷ []) "Phil.2.30" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.2.30" ∷ word (π ∷ ρ ∷ ό ∷ ς ∷ []) "Phil.2.30" ∷ word (μ ∷ ε ∷ []) "Phil.2.30" ∷ word (∙λ ∷ ε ∷ ι ∷ τ ∷ ο ∷ υ ∷ ρ ∷ γ ∷ ί ∷ α ∷ ς ∷ []) "Phil.2.30" ∷ word (Τ ∷ ὸ ∷ []) "Phil.3.1" ∷ word (∙λ ∷ ο ∷ ι ∷ π ∷ ό ∷ ν ∷ []) "Phil.3.1" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "Phil.3.1" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.3.1" ∷ word (χ ∷ α ∷ ί ∷ ρ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.3.1" ∷ word (ἐ ∷ ν ∷ []) "Phil.3.1" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phil.3.1" ∷ word (τ ∷ ὰ ∷ []) "Phil.3.1" ∷ word (α ∷ ὐ ∷ τ ∷ ὰ ∷ []) "Phil.3.1" ∷ word (γ ∷ ρ ∷ ά ∷ φ ∷ ε ∷ ι ∷ ν ∷ []) "Phil.3.1" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.3.1" ∷ word (ἐ ∷ μ ∷ ο ∷ ὶ ∷ []) "Phil.3.1" ∷ word (μ ∷ ὲ ∷ ν ∷ []) "Phil.3.1" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "Phil.3.1" ∷ word (ὀ ∷ κ ∷ ν ∷ η ∷ ρ ∷ ό ∷ ν ∷ []) "Phil.3.1" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.3.1" ∷ word (δ ∷ ὲ ∷ []) "Phil.3.1" ∷ word (ἀ ∷ σ ∷ φ ∷ α ∷ ∙λ ∷ έ ∷ ς ∷ []) "Phil.3.1" ∷ word (Β ∷ ∙λ ∷ έ ∷ π ∷ ε ∷ τ ∷ ε ∷ []) "Phil.3.2" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.3.2" ∷ word (κ ∷ ύ ∷ ν ∷ α ∷ ς ∷ []) "Phil.3.2" ∷ word (β ∷ ∙λ ∷ έ ∷ π ∷ ε ∷ τ ∷ ε ∷ []) "Phil.3.2" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.3.2" ∷ word (κ ∷ α ∷ κ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.3.2" ∷ word (ἐ ∷ ρ ∷ γ ∷ ά ∷ τ ∷ α ∷ ς ∷ []) "Phil.3.2" ∷ word (β ∷ ∙λ ∷ έ ∷ π ∷ ε ∷ τ ∷ ε ∷ []) "Phil.3.2" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.3.2" ∷ word (κ ∷ α ∷ τ ∷ α ∷ τ ∷ ο ∷ μ ∷ ή ∷ ν ∷ []) "Phil.3.2" ∷ word (ἡ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "Phil.3.3" ∷ word (γ ∷ ά ∷ ρ ∷ []) "Phil.3.3" ∷ word (ἐ ∷ σ ∷ μ ∷ ε ∷ ν ∷ []) "Phil.3.3" ∷ word (ἡ ∷ []) "Phil.3.3" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ τ ∷ ο ∷ μ ∷ ή ∷ []) "Phil.3.3" ∷ word (ο ∷ ἱ ∷ []) "Phil.3.3" ∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "Phil.3.3" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Phil.3.3" ∷ word (∙λ ∷ α ∷ τ ∷ ρ ∷ ε ∷ ύ ∷ ο ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Phil.3.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.3" ∷ word (κ ∷ α ∷ υ ∷ χ ∷ ώ ∷ μ ∷ ε ∷ ν ∷ ο ∷ ι ∷ []) "Phil.3.3" ∷ word (ἐ ∷ ν ∷ []) "Phil.3.3" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phil.3.3" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.3.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.3" ∷ word (ο ∷ ὐ ∷ κ ∷ []) "Phil.3.3" ∷ word (ἐ ∷ ν ∷ []) "Phil.3.3" ∷ word (σ ∷ α ∷ ρ ∷ κ ∷ ὶ ∷ []) "Phil.3.3" ∷ word (π ∷ ε ∷ π ∷ ο ∷ ι ∷ θ ∷ ό ∷ τ ∷ ε ∷ ς ∷ []) "Phil.3.3" ∷ word (κ ∷ α ∷ ί ∷ π ∷ ε ∷ ρ ∷ []) "Phil.3.4" ∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "Phil.3.4" ∷ word (ἔ ∷ χ ∷ ω ∷ ν ∷ []) "Phil.3.4" ∷ word (π ∷ ε ∷ π ∷ ο ∷ ί ∷ θ ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "Phil.3.4" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.4" ∷ word (ἐ ∷ ν ∷ []) "Phil.3.4" ∷ word (σ ∷ α ∷ ρ ∷ κ ∷ ί ∷ []) "Phil.3.4" ∷ word (Ε ∷ ἴ ∷ []) "Phil.3.4" ∷ word (τ ∷ ι ∷ ς ∷ []) "Phil.3.4" ∷ word (δ ∷ ο ∷ κ ∷ ε ∷ ῖ ∷ []) "Phil.3.4" ∷ word (ἄ ∷ ∙λ ∷ ∙λ ∷ ο ∷ ς ∷ []) "Phil.3.4" ∷ word (π ∷ ε ∷ π ∷ ο ∷ ι ∷ θ ∷ έ ∷ ν ∷ α ∷ ι ∷ []) "Phil.3.4" ∷ word (ἐ ∷ ν ∷ []) "Phil.3.4" ∷ word (σ ∷ α ∷ ρ ∷ κ ∷ ί ∷ []) "Phil.3.4" ∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "Phil.3.4" ∷ word (μ ∷ ᾶ ∷ ∙λ ∷ ∙λ ∷ ο ∷ ν ∷ []) "Phil.3.4" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ τ ∷ ο ∷ μ ∷ ῇ ∷ []) "Phil.3.5" ∷ word (ὀ ∷ κ ∷ τ ∷ α ∷ ή ∷ μ ∷ ε ∷ ρ ∷ ο ∷ ς ∷ []) "Phil.3.5" ∷ word (ἐ ∷ κ ∷ []) "Phil.3.5" ∷ word (γ ∷ έ ∷ ν ∷ ο ∷ υ ∷ ς ∷ []) "Phil.3.5" ∷ word (Ἰ ∷ σ ∷ ρ ∷ α ∷ ή ∷ ∙λ ∷ []) "Phil.3.5" ∷ word (φ ∷ υ ∷ ∙λ ∷ ῆ ∷ ς ∷ []) "Phil.3.5" ∷ word (Β ∷ ε ∷ ν ∷ ι ∷ α ∷ μ ∷ ί ∷ ν ∷ []) "Phil.3.5" ∷ word (Ἑ ∷ β ∷ ρ ∷ α ∷ ῖ ∷ ο ∷ ς ∷ []) "Phil.3.5" ∷ word (ἐ ∷ ξ ∷ []) "Phil.3.5" ∷ word (Ἑ ∷ β ∷ ρ ∷ α ∷ ί ∷ ω ∷ ν ∷ []) "Phil.3.5" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Phil.3.5" ∷ word (ν ∷ ό ∷ μ ∷ ο ∷ ν ∷ []) "Phil.3.5" ∷ word (Φ ∷ α ∷ ρ ∷ ι ∷ σ ∷ α ∷ ῖ ∷ ο ∷ ς ∷ []) "Phil.3.5" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Phil.3.6" ∷ word (ζ ∷ ῆ ∷ ∙λ ∷ ο ∷ ς ∷ []) "Phil.3.6" ∷ word (δ ∷ ι ∷ ώ ∷ κ ∷ ω ∷ ν ∷ []) "Phil.3.6" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.3.6" ∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ α ∷ ν ∷ []) "Phil.3.6" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Phil.3.6" ∷ word (δ ∷ ι ∷ κ ∷ α ∷ ι ∷ ο ∷ σ ∷ ύ ∷ ν ∷ η ∷ ν ∷ []) "Phil.3.6" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.3.6" ∷ word (ἐ ∷ ν ∷ []) "Phil.3.6" ∷ word (ν ∷ ό ∷ μ ∷ ῳ ∷ []) "Phil.3.6" ∷ word (γ ∷ ε ∷ ν ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Phil.3.6" ∷ word (ἄ ∷ μ ∷ ε ∷ μ ∷ π ∷ τ ∷ ο ∷ ς ∷ []) "Phil.3.6" ∷ word (Ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.3.7" ∷ word (ἅ ∷ τ ∷ ι ∷ ν ∷ α ∷ []) "Phil.3.7" ∷ word (ἦ ∷ ν ∷ []) "Phil.3.7" ∷ word (μ ∷ ο ∷ ι ∷ []) "Phil.3.7" ∷ word (κ ∷ έ ∷ ρ ∷ δ ∷ η ∷ []) "Phil.3.7" ∷ word (τ ∷ α ∷ ῦ ∷ τ ∷ α ∷ []) "Phil.3.7" ∷ word (ἥ ∷ γ ∷ η ∷ μ ∷ α ∷ ι ∷ []) "Phil.3.7" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phil.3.7" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Phil.3.7" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.3.7" ∷ word (ζ ∷ η ∷ μ ∷ ί ∷ α ∷ ν ∷ []) "Phil.3.7" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.3.8" ∷ word (μ ∷ ε ∷ ν ∷ ο ∷ ῦ ∷ ν ∷ γ ∷ ε ∷ []) "Phil.3.8" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.8" ∷ word (ἡ ∷ γ ∷ ο ∷ ῦ ∷ μ ∷ α ∷ ι ∷ []) "Phil.3.8" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Phil.3.8" ∷ word (ζ ∷ η ∷ μ ∷ ί ∷ α ∷ ν ∷ []) "Phil.3.8" ∷ word (ε ∷ ἶ ∷ ν ∷ α ∷ ι ∷ []) "Phil.3.8" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phil.3.8" ∷ word (τ ∷ ὸ ∷ []) "Phil.3.8" ∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ έ ∷ χ ∷ ο ∷ ν ∷ []) "Phil.3.8" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.3.8" ∷ word (γ ∷ ν ∷ ώ ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "Phil.3.8" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.3.8" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.3.8" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.3.8" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "Phil.3.8" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.3.8" ∷ word (δ ∷ ι ∷ []) "Phil.3.8" ∷ word (ὃ ∷ ν ∷ []) "Phil.3.8" ∷ word (τ ∷ ὰ ∷ []) "Phil.3.8" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Phil.3.8" ∷ word (ἐ ∷ ζ ∷ η ∷ μ ∷ ι ∷ ώ ∷ θ ∷ η ∷ ν ∷ []) "Phil.3.8" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.8" ∷ word (ἡ ∷ γ ∷ ο ∷ ῦ ∷ μ ∷ α ∷ ι ∷ []) "Phil.3.8" ∷ word (σ ∷ κ ∷ ύ ∷ β ∷ α ∷ ∙λ ∷ α ∷ []) "Phil.3.8" ∷ word (ἵ ∷ ν ∷ α ∷ []) "Phil.3.8" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.3.8" ∷ word (κ ∷ ε ∷ ρ ∷ δ ∷ ή ∷ σ ∷ ω ∷ []) "Phil.3.8" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.9" ∷ word (ε ∷ ὑ ∷ ρ ∷ ε ∷ θ ∷ ῶ ∷ []) "Phil.3.9" ∷ word (ἐ ∷ ν ∷ []) "Phil.3.9" ∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "Phil.3.9" ∷ word (μ ∷ ὴ ∷ []) "Phil.3.9" ∷ word (ἔ ∷ χ ∷ ω ∷ ν ∷ []) "Phil.3.9" ∷ word (ἐ ∷ μ ∷ ὴ ∷ ν ∷ []) "Phil.3.9" ∷ word (δ ∷ ι ∷ κ ∷ α ∷ ι ∷ ο ∷ σ ∷ ύ ∷ ν ∷ η ∷ ν ∷ []) "Phil.3.9" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.3.9" ∷ word (ἐ ∷ κ ∷ []) "Phil.3.9" ∷ word (ν ∷ ό ∷ μ ∷ ο ∷ υ ∷ []) "Phil.3.9" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.3.9" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.3.9" ∷ word (δ ∷ ι ∷ ὰ ∷ []) "Phil.3.9" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ω ∷ ς ∷ []) "Phil.3.9" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.3.9" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.3.9" ∷ word (ἐ ∷ κ ∷ []) "Phil.3.9" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Phil.3.9" ∷ word (δ ∷ ι ∷ κ ∷ α ∷ ι ∷ ο ∷ σ ∷ ύ ∷ ν ∷ η ∷ ν ∷ []) "Phil.3.9" ∷ word (ἐ ∷ π ∷ ὶ ∷ []) "Phil.3.9" ∷ word (τ ∷ ῇ ∷ []) "Phil.3.9" ∷ word (π ∷ ί ∷ σ ∷ τ ∷ ε ∷ ι ∷ []) "Phil.3.9" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.3.10" ∷ word (γ ∷ ν ∷ ῶ ∷ ν ∷ α ∷ ι ∷ []) "Phil.3.10" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.3.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.10" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.3.10" ∷ word (δ ∷ ύ ∷ ν ∷ α ∷ μ ∷ ι ∷ ν ∷ []) "Phil.3.10" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.3.10" ∷ word (ἀ ∷ ν ∷ α ∷ σ ∷ τ ∷ ά ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "Phil.3.10" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.3.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.10" ∷ word (κ ∷ ο ∷ ι ∷ ν ∷ ω ∷ ν ∷ ί ∷ α ∷ ν ∷ []) "Phil.3.10" ∷ word (π ∷ α ∷ θ ∷ η ∷ μ ∷ ά ∷ τ ∷ ω ∷ ν ∷ []) "Phil.3.10" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.3.10" ∷ word (σ ∷ υ ∷ μ ∷ μ ∷ ο ∷ ρ ∷ φ ∷ ι ∷ ζ ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Phil.3.10" ∷ word (τ ∷ ῷ ∷ []) "Phil.3.10" ∷ word (θ ∷ α ∷ ν ∷ ά ∷ τ ∷ ῳ ∷ []) "Phil.3.10" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.3.10" ∷ word (ε ∷ ἴ ∷ []) "Phil.3.11" ∷ word (π ∷ ω ∷ ς ∷ []) "Phil.3.11" ∷ word (κ ∷ α ∷ τ ∷ α ∷ ν ∷ τ ∷ ή ∷ σ ∷ ω ∷ []) "Phil.3.11" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.3.11" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.3.11" ∷ word (ἐ ∷ ξ ∷ α ∷ ν ∷ ά ∷ σ ∷ τ ∷ α ∷ σ ∷ ι ∷ ν ∷ []) "Phil.3.11" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.3.11" ∷ word (ἐ ∷ κ ∷ []) "Phil.3.11" ∷ word (ν ∷ ε ∷ κ ∷ ρ ∷ ῶ ∷ ν ∷ []) "Phil.3.11" ∷ word (Ο ∷ ὐ ∷ χ ∷ []) "Phil.3.12" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.3.12" ∷ word (ἤ ∷ δ ∷ η ∷ []) "Phil.3.12" ∷ word (ἔ ∷ ∙λ ∷ α ∷ β ∷ ο ∷ ν ∷ []) "Phil.3.12" ∷ word (ἢ ∷ []) "Phil.3.12" ∷ word (ἤ ∷ δ ∷ η ∷ []) "Phil.3.12" ∷ word (τ ∷ ε ∷ τ ∷ ε ∷ ∙λ ∷ ε ∷ ί ∷ ω ∷ μ ∷ α ∷ ι ∷ []) "Phil.3.12" ∷ word (δ ∷ ι ∷ ώ ∷ κ ∷ ω ∷ []) "Phil.3.12" ∷ word (δ ∷ ὲ ∷ []) "Phil.3.12" ∷ word (ε ∷ ἰ ∷ []) "Phil.3.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.12" ∷ word (κ ∷ α ∷ τ ∷ α ∷ ∙λ ∷ ά ∷ β ∷ ω ∷ []) "Phil.3.12" ∷ word (ἐ ∷ φ ∷ []) "Phil.3.12" ∷ word (ᾧ ∷ []) "Phil.3.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.12" ∷ word (κ ∷ α ∷ τ ∷ ε ∷ ∙λ ∷ ή ∷ μ ∷ φ ∷ θ ∷ η ∷ ν ∷ []) "Phil.3.12" ∷ word (ὑ ∷ π ∷ ὸ ∷ []) "Phil.3.12" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.3.12" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "Phil.3.13" ∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "Phil.3.13" ∷ word (ἐ ∷ μ ∷ α ∷ υ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.3.13" ∷ word (ο ∷ ὐ ∷ []) "Phil.3.13" ∷ word (∙λ ∷ ο ∷ γ ∷ ί ∷ ζ ∷ ο ∷ μ ∷ α ∷ ι ∷ []) "Phil.3.13" ∷ word (κ ∷ α ∷ τ ∷ ε ∷ ι ∷ ∙λ ∷ η ∷ φ ∷ έ ∷ ν ∷ α ∷ ι ∷ []) "Phil.3.13" ∷ word (ἓ ∷ ν ∷ []) "Phil.3.13" ∷ word (δ ∷ έ ∷ []) "Phil.3.13" ∷ word (τ ∷ ὰ ∷ []) "Phil.3.13" ∷ word (μ ∷ ὲ ∷ ν ∷ []) "Phil.3.13" ∷ word (ὀ ∷ π ∷ ί ∷ σ ∷ ω ∷ []) "Phil.3.13" ∷ word (ἐ ∷ π ∷ ι ∷ ∙λ ∷ α ∷ ν ∷ θ ∷ α ∷ ν ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Phil.3.13" ∷ word (τ ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.3.13" ∷ word (δ ∷ ὲ ∷ []) "Phil.3.13" ∷ word (ἔ ∷ μ ∷ π ∷ ρ ∷ ο ∷ σ ∷ θ ∷ ε ∷ ν ∷ []) "Phil.3.13" ∷ word (ἐ ∷ π ∷ ε ∷ κ ∷ τ ∷ ε ∷ ι ∷ ν ∷ ό ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Phil.3.13" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Phil.3.14" ∷ word (σ ∷ κ ∷ ο ∷ π ∷ ὸ ∷ ν ∷ []) "Phil.3.14" ∷ word (δ ∷ ι ∷ ώ ∷ κ ∷ ω ∷ []) "Phil.3.14" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.3.14" ∷ word (τ ∷ ὸ ∷ []) "Phil.3.14" ∷ word (β ∷ ρ ∷ α ∷ β ∷ ε ∷ ῖ ∷ ο ∷ ν ∷ []) "Phil.3.14" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.3.14" ∷ word (ἄ ∷ ν ∷ ω ∷ []) "Phil.3.14" ∷ word (κ ∷ ∙λ ∷ ή ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "Phil.3.14" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.3.14" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Phil.3.14" ∷ word (ἐ ∷ ν ∷ []) "Phil.3.14" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phil.3.14" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.3.14" ∷ word (ὅ ∷ σ ∷ ο ∷ ι ∷ []) "Phil.3.15" ∷ word (ο ∷ ὖ ∷ ν ∷ []) "Phil.3.15" ∷ word (τ ∷ έ ∷ ∙λ ∷ ε ∷ ι ∷ ο ∷ ι ∷ []) "Phil.3.15" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Phil.3.15" ∷ word (φ ∷ ρ ∷ ο ∷ ν ∷ ῶ ∷ μ ∷ ε ∷ ν ∷ []) "Phil.3.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.15" ∷ word (ε ∷ ἴ ∷ []) "Phil.3.15" ∷ word (τ ∷ ι ∷ []) "Phil.3.15" ∷ word (ἑ ∷ τ ∷ έ ∷ ρ ∷ ω ∷ ς ∷ []) "Phil.3.15" ∷ word (φ ∷ ρ ∷ ο ∷ ν ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "Phil.3.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.15" ∷ word (τ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ []) "Phil.3.15" ∷ word (ὁ ∷ []) "Phil.3.15" ∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "Phil.3.15" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.3.15" ∷ word (ἀ ∷ π ∷ ο ∷ κ ∷ α ∷ ∙λ ∷ ύ ∷ ψ ∷ ε ∷ ι ∷ []) "Phil.3.15" ∷ word (π ∷ ∙λ ∷ ὴ ∷ ν ∷ []) "Phil.3.16" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.3.16" ∷ word (ὃ ∷ []) "Phil.3.16" ∷ word (ἐ ∷ φ ∷ θ ∷ ά ∷ σ ∷ α ∷ μ ∷ ε ∷ ν ∷ []) "Phil.3.16" ∷ word (τ ∷ ῷ ∷ []) "Phil.3.16" ∷ word (α ∷ ὐ ∷ τ ∷ ῷ ∷ []) "Phil.3.16" ∷ word (σ ∷ τ ∷ ο ∷ ι ∷ χ ∷ ε ∷ ῖ ∷ ν ∷ []) "Phil.3.16" ∷ word (Σ ∷ υ ∷ μ ∷ μ ∷ ι ∷ μ ∷ η ∷ τ ∷ α ∷ ί ∷ []) "Phil.3.17" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.3.17" ∷ word (γ ∷ ί ∷ ν ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "Phil.3.17" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "Phil.3.17" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.17" ∷ word (σ ∷ κ ∷ ο ∷ π ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "Phil.3.17" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.3.17" ∷ word (ο ∷ ὕ ∷ τ ∷ ω ∷ []) "Phil.3.17" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ α ∷ ς ∷ []) "Phil.3.17" ∷ word (κ ∷ α ∷ θ ∷ ὼ ∷ ς ∷ []) "Phil.3.17" ∷ word (ἔ ∷ χ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.3.17" ∷ word (τ ∷ ύ ∷ π ∷ ο ∷ ν ∷ []) "Phil.3.17" ∷ word (ἡ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.3.17" ∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ο ∷ ὶ ∷ []) "Phil.3.18" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phil.3.18" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ π ∷ α ∷ τ ∷ ο ∷ ῦ ∷ σ ∷ ι ∷ ν ∷ []) "Phil.3.18" ∷ word (ο ∷ ὓ ∷ ς ∷ []) "Phil.3.18" ∷ word (π ∷ ο ∷ ∙λ ∷ ∙λ ∷ ά ∷ κ ∷ ι ∷ ς ∷ []) "Phil.3.18" ∷ word (ἔ ∷ ∙λ ∷ ε ∷ γ ∷ ο ∷ ν ∷ []) "Phil.3.18" ∷ word (ὑ ∷ μ ∷ ῖ ∷ ν ∷ []) "Phil.3.18" ∷ word (ν ∷ ῦ ∷ ν ∷ []) "Phil.3.18" ∷ word (δ ∷ ὲ ∷ []) "Phil.3.18" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.18" ∷ word (κ ∷ ∙λ ∷ α ∷ ί ∷ ω ∷ ν ∷ []) "Phil.3.18" ∷ word (∙λ ∷ έ ∷ γ ∷ ω ∷ []) "Phil.3.18" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.3.18" ∷ word (ἐ ∷ χ ∷ θ ∷ ρ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.3.18" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.3.18" ∷ word (σ ∷ τ ∷ α ∷ υ ∷ ρ ∷ ο ∷ ῦ ∷ []) "Phil.3.18" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.3.18" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.3.18" ∷ word (ὧ ∷ ν ∷ []) "Phil.3.19" ∷ word (τ ∷ ὸ ∷ []) "Phil.3.19" ∷ word (τ ∷ έ ∷ ∙λ ∷ ο ∷ ς ∷ []) "Phil.3.19" ∷ word (ἀ ∷ π ∷ ώ ∷ ∙λ ∷ ε ∷ ι ∷ α ∷ []) "Phil.3.19" ∷ word (ὧ ∷ ν ∷ []) "Phil.3.19" ∷ word (ὁ ∷ []) "Phil.3.19" ∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "Phil.3.19" ∷ word (ἡ ∷ []) "Phil.3.19" ∷ word (κ ∷ ο ∷ ι ∷ ∙λ ∷ ί ∷ α ∷ []) "Phil.3.19" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.19" ∷ word (ἡ ∷ []) "Phil.3.19" ∷ word (δ ∷ ό ∷ ξ ∷ α ∷ []) "Phil.3.19" ∷ word (ἐ ∷ ν ∷ []) "Phil.3.19" ∷ word (τ ∷ ῇ ∷ []) "Phil.3.19" ∷ word (α ∷ ἰ ∷ σ ∷ χ ∷ ύ ∷ ν ∷ ῃ ∷ []) "Phil.3.19" ∷ word (α ∷ ὐ ∷ τ ∷ ῶ ∷ ν ∷ []) "Phil.3.19" ∷ word (ο ∷ ἱ ∷ []) "Phil.3.19" ∷ word (τ ∷ ὰ ∷ []) "Phil.3.19" ∷ word (ἐ ∷ π ∷ ί ∷ γ ∷ ε ∷ ι ∷ α ∷ []) "Phil.3.19" ∷ word (φ ∷ ρ ∷ ο ∷ ν ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Phil.3.19" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.3.20" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phil.3.20" ∷ word (τ ∷ ὸ ∷ []) "Phil.3.20" ∷ word (π ∷ ο ∷ ∙λ ∷ ί ∷ τ ∷ ε ∷ υ ∷ μ ∷ α ∷ []) "Phil.3.20" ∷ word (ἐ ∷ ν ∷ []) "Phil.3.20" ∷ word (ο ∷ ὐ ∷ ρ ∷ α ∷ ν ∷ ο ∷ ῖ ∷ ς ∷ []) "Phil.3.20" ∷ word (ὑ ∷ π ∷ ά ∷ ρ ∷ χ ∷ ε ∷ ι ∷ []) "Phil.3.20" ∷ word (ἐ ∷ ξ ∷ []) "Phil.3.20" ∷ word (ο ∷ ὗ ∷ []) "Phil.3.20" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.20" ∷ word (σ ∷ ω ∷ τ ∷ ῆ ∷ ρ ∷ α ∷ []) "Phil.3.20" ∷ word (ἀ ∷ π ∷ ε ∷ κ ∷ δ ∷ ε ∷ χ ∷ ό ∷ μ ∷ ε ∷ θ ∷ α ∷ []) "Phil.3.20" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ν ∷ []) "Phil.3.20" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ ν ∷ []) "Phil.3.20" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ό ∷ ν ∷ []) "Phil.3.20" ∷ word (ὃ ∷ ς ∷ []) "Phil.3.21" ∷ word (μ ∷ ε ∷ τ ∷ α ∷ σ ∷ χ ∷ η ∷ μ ∷ α ∷ τ ∷ ί ∷ σ ∷ ε ∷ ι ∷ []) "Phil.3.21" ∷ word (τ ∷ ὸ ∷ []) "Phil.3.21" ∷ word (σ ∷ ῶ ∷ μ ∷ α ∷ []) "Phil.3.21" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.3.21" ∷ word (τ ∷ α ∷ π ∷ ε ∷ ι ∷ ν ∷ ώ ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "Phil.3.21" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.3.21" ∷ word (σ ∷ ύ ∷ μ ∷ μ ∷ ο ∷ ρ ∷ φ ∷ ο ∷ ν ∷ []) "Phil.3.21" ∷ word (τ ∷ ῷ ∷ []) "Phil.3.21" ∷ word (σ ∷ ώ ∷ μ ∷ α ∷ τ ∷ ι ∷ []) "Phil.3.21" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.3.21" ∷ word (δ ∷ ό ∷ ξ ∷ η ∷ ς ∷ []) "Phil.3.21" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.3.21" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Phil.3.21" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.3.21" ∷ word (ἐ ∷ ν ∷ έ ∷ ρ ∷ γ ∷ ε ∷ ι ∷ α ∷ ν ∷ []) "Phil.3.21" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.3.21" ∷ word (δ ∷ ύ ∷ ν ∷ α ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Phil.3.21" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ ν ∷ []) "Phil.3.21" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.3.21" ∷ word (ὑ ∷ π ∷ ο ∷ τ ∷ ά ∷ ξ ∷ α ∷ ι ∷ []) "Phil.3.21" ∷ word (α ∷ ὑ ∷ τ ∷ ῷ ∷ []) "Phil.3.21" ∷ word (τ ∷ ὰ ∷ []) "Phil.3.21" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Phil.3.21" ∷ word (ὥ ∷ σ ∷ τ ∷ ε ∷ []) "Phil.4.1" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "Phil.4.1" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.4.1" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ο ∷ ὶ ∷ []) "Phil.4.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.1" ∷ word (ἐ ∷ π ∷ ι ∷ π ∷ ό ∷ θ ∷ η ∷ τ ∷ ο ∷ ι ∷ []) "Phil.4.1" ∷ word (χ ∷ α ∷ ρ ∷ ὰ ∷ []) "Phil.4.1" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.1" ∷ word (σ ∷ τ ∷ έ ∷ φ ∷ α ∷ ν ∷ ό ∷ ς ∷ []) "Phil.4.1" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.4.1" ∷ word (ο ∷ ὕ ∷ τ ∷ ω ∷ ς ∷ []) "Phil.4.1" ∷ word (σ ∷ τ ∷ ή ∷ κ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.4.1" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.1" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phil.4.1" ∷ word (ἀ ∷ γ ∷ α ∷ π ∷ η ∷ τ ∷ ο ∷ ί ∷ []) "Phil.4.1" ∷ word (Ε ∷ ὐ ∷ ο ∷ δ ∷ ί ∷ α ∷ ν ∷ []) "Phil.4.2" ∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ῶ ∷ []) "Phil.4.2" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.2" ∷ word (Σ ∷ υ ∷ ν ∷ τ ∷ ύ ∷ χ ∷ η ∷ ν ∷ []) "Phil.4.2" ∷ word (π ∷ α ∷ ρ ∷ α ∷ κ ∷ α ∷ ∙λ ∷ ῶ ∷ []) "Phil.4.2" ∷ word (τ ∷ ὸ ∷ []) "Phil.4.2" ∷ word (α ∷ ὐ ∷ τ ∷ ὸ ∷ []) "Phil.4.2" ∷ word (φ ∷ ρ ∷ ο ∷ ν ∷ ε ∷ ῖ ∷ ν ∷ []) "Phil.4.2" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.2" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phil.4.2" ∷ word (ν ∷ α ∷ ὶ ∷ []) "Phil.4.3" ∷ word (ἐ ∷ ρ ∷ ω ∷ τ ∷ ῶ ∷ []) "Phil.4.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.3" ∷ word (σ ∷ έ ∷ []) "Phil.4.3" ∷ word (γ ∷ ν ∷ ή ∷ σ ∷ ι ∷ ε ∷ []) "Phil.4.3" ∷ word (σ ∷ ύ ∷ ζ ∷ υ ∷ γ ∷ ε ∷ []) "Phil.4.3" ∷ word (σ ∷ υ ∷ ∙λ ∷ ∙λ ∷ α ∷ μ ∷ β ∷ ά ∷ ν ∷ ο ∷ υ ∷ []) "Phil.4.3" ∷ word (α ∷ ὐ ∷ τ ∷ α ∷ ῖ ∷ ς ∷ []) "Phil.4.3" ∷ word (α ∷ ἵ ∷ τ ∷ ι ∷ ν ∷ ε ∷ ς ∷ []) "Phil.4.3" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.3" ∷ word (τ ∷ ῷ ∷ []) "Phil.4.3" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ῳ ∷ []) "Phil.4.3" ∷ word (σ ∷ υ ∷ ν ∷ ή ∷ θ ∷ ∙λ ∷ η ∷ σ ∷ ά ∷ ν ∷ []) "Phil.4.3" ∷ word (μ ∷ ο ∷ ι ∷ []) "Phil.4.3" ∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "Phil.4.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.3" ∷ word (Κ ∷ ∙λ ∷ ή ∷ μ ∷ ε ∷ ν ∷ τ ∷ ο ∷ ς ∷ []) "Phil.4.3" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.3" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Phil.4.3" ∷ word (∙λ ∷ ο ∷ ι ∷ π ∷ ῶ ∷ ν ∷ []) "Phil.4.3" ∷ word (σ ∷ υ ∷ ν ∷ ε ∷ ρ ∷ γ ∷ ῶ ∷ ν ∷ []) "Phil.4.3" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.4.3" ∷ word (ὧ ∷ ν ∷ []) "Phil.4.3" ∷ word (τ ∷ ὰ ∷ []) "Phil.4.3" ∷ word (ὀ ∷ ν ∷ ό ∷ μ ∷ α ∷ τ ∷ α ∷ []) "Phil.4.3" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.3" ∷ word (β ∷ ί ∷ β ∷ ∙λ ∷ ῳ ∷ []) "Phil.4.3" ∷ word (ζ ∷ ω ∷ ῆ ∷ ς ∷ []) "Phil.4.3" ∷ word (Χ ∷ α ∷ ί ∷ ρ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.4.4" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.4" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phil.4.4" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ο ∷ τ ∷ ε ∷ []) "Phil.4.4" ∷ word (π ∷ ά ∷ ∙λ ∷ ι ∷ ν ∷ []) "Phil.4.4" ∷ word (ἐ ∷ ρ ∷ ῶ ∷ []) "Phil.4.4" ∷ word (χ ∷ α ∷ ί ∷ ρ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.4.4" ∷ word (τ ∷ ὸ ∷ []) "Phil.4.5" ∷ word (ἐ ∷ π ∷ ι ∷ ε ∷ ι ∷ κ ∷ ὲ ∷ ς ∷ []) "Phil.4.5" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.4.5" ∷ word (γ ∷ ν ∷ ω ∷ σ ∷ θ ∷ ή ∷ τ ∷ ω ∷ []) "Phil.4.5" ∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "Phil.4.5" ∷ word (ἀ ∷ ν ∷ θ ∷ ρ ∷ ώ ∷ π ∷ ο ∷ ι ∷ ς ∷ []) "Phil.4.5" ∷ word (ὁ ∷ []) "Phil.4.5" ∷ word (κ ∷ ύ ∷ ρ ∷ ι ∷ ο ∷ ς ∷ []) "Phil.4.5" ∷ word (ἐ ∷ γ ∷ γ ∷ ύ ∷ ς ∷ []) "Phil.4.5" ∷ word (μ ∷ η ∷ δ ∷ ὲ ∷ ν ∷ []) "Phil.4.6" ∷ word (μ ∷ ε ∷ ρ ∷ ι ∷ μ ∷ ν ∷ ᾶ ∷ τ ∷ ε ∷ []) "Phil.4.6" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ []) "Phil.4.6" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.6" ∷ word (π ∷ α ∷ ν ∷ τ ∷ ὶ ∷ []) "Phil.4.6" ∷ word (τ ∷ ῇ ∷ []) "Phil.4.6" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ ε ∷ υ ∷ χ ∷ ῇ ∷ []) "Phil.4.6" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.6" ∷ word (τ ∷ ῇ ∷ []) "Phil.4.6" ∷ word (δ ∷ ε ∷ ή ∷ σ ∷ ε ∷ ι ∷ []) "Phil.4.6" ∷ word (μ ∷ ε ∷ τ ∷ []) "Phil.4.6" ∷ word (ε ∷ ὐ ∷ χ ∷ α ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ί ∷ α ∷ ς ∷ []) "Phil.4.6" ∷ word (τ ∷ ὰ ∷ []) "Phil.4.6" ∷ word (α ∷ ἰ ∷ τ ∷ ή ∷ μ ∷ α ∷ τ ∷ α ∷ []) "Phil.4.6" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.4.6" ∷ word (γ ∷ ν ∷ ω ∷ ρ ∷ ι ∷ ζ ∷ έ ∷ σ ∷ θ ∷ ω ∷ []) "Phil.4.6" ∷ word (π ∷ ρ ∷ ὸ ∷ ς ∷ []) "Phil.4.6" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Phil.4.6" ∷ word (θ ∷ ε ∷ ό ∷ ν ∷ []) "Phil.4.6" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.7" ∷ word (ἡ ∷ []) "Phil.4.7" ∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ []) "Phil.4.7" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.4.7" ∷ word (θ ∷ ε ∷ ο ∷ ῦ ∷ []) "Phil.4.7" ∷ word (ἡ ∷ []) "Phil.4.7" ∷ word (ὑ ∷ π ∷ ε ∷ ρ ∷ έ ∷ χ ∷ ο ∷ υ ∷ σ ∷ α ∷ []) "Phil.4.7" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Phil.4.7" ∷ word (ν ∷ ο ∷ ῦ ∷ ν ∷ []) "Phil.4.7" ∷ word (φ ∷ ρ ∷ ο ∷ υ ∷ ρ ∷ ή ∷ σ ∷ ε ∷ ι ∷ []) "Phil.4.7" ∷ word (τ ∷ ὰ ∷ ς ∷ []) "Phil.4.7" ∷ word (κ ∷ α ∷ ρ ∷ δ ∷ ί ∷ α ∷ ς ∷ []) "Phil.4.7" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.4.7" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.7" ∷ word (τ ∷ ὰ ∷ []) "Phil.4.7" ∷ word (ν ∷ ο ∷ ή ∷ μ ∷ α ∷ τ ∷ α ∷ []) "Phil.4.7" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.4.7" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.7" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phil.4.7" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.4.7" ∷ word (Τ ∷ ὸ ∷ []) "Phil.4.8" ∷ word (∙λ ∷ ο ∷ ι ∷ π ∷ ό ∷ ν ∷ []) "Phil.4.8" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "Phil.4.8" ∷ word (ὅ ∷ σ ∷ α ∷ []) "Phil.4.8" ∷ word (ἐ ∷ σ ∷ τ ∷ ὶ ∷ ν ∷ []) "Phil.4.8" ∷ word (ἀ ∷ ∙λ ∷ η ∷ θ ∷ ῆ ∷ []) "Phil.4.8" ∷ word (ὅ ∷ σ ∷ α ∷ []) "Phil.4.8" ∷ word (σ ∷ ε ∷ μ ∷ ν ∷ ά ∷ []) "Phil.4.8" ∷ word (ὅ ∷ σ ∷ α ∷ []) "Phil.4.8" ∷ word (δ ∷ ί ∷ κ ∷ α ∷ ι ∷ α ∷ []) "Phil.4.8" ∷ word (ὅ ∷ σ ∷ α ∷ []) "Phil.4.8" ∷ word (ἁ ∷ γ ∷ ν ∷ ά ∷ []) "Phil.4.8" ∷ word (ὅ ∷ σ ∷ α ∷ []) "Phil.4.8" ∷ word (π ∷ ρ ∷ ο ∷ σ ∷ φ ∷ ι ∷ ∙λ ∷ ῆ ∷ []) "Phil.4.8" ∷ word (ὅ ∷ σ ∷ α ∷ []) "Phil.4.8" ∷ word (ε ∷ ὔ ∷ φ ∷ η ∷ μ ∷ α ∷ []) "Phil.4.8" ∷ word (ε ∷ ἴ ∷ []) "Phil.4.8" ∷ word (τ ∷ ι ∷ ς ∷ []) "Phil.4.8" ∷ word (ἀ ∷ ρ ∷ ε ∷ τ ∷ ὴ ∷ []) "Phil.4.8" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.8" ∷ word (ε ∷ ἴ ∷ []) "Phil.4.8" ∷ word (τ ∷ ι ∷ ς ∷ []) "Phil.4.8" ∷ word (ἔ ∷ π ∷ α ∷ ι ∷ ν ∷ ο ∷ ς ∷ []) "Phil.4.8" ∷ word (τ ∷ α ∷ ῦ ∷ τ ∷ α ∷ []) "Phil.4.8" ∷ word (∙λ ∷ ο ∷ γ ∷ ί ∷ ζ ∷ ε ∷ σ ∷ θ ∷ ε ∷ []) "Phil.4.8" ∷ word (ἃ ∷ []) "Phil.4.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.9" ∷ word (ἐ ∷ μ ∷ ά ∷ θ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.4.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.9" ∷ word (π ∷ α ∷ ρ ∷ ε ∷ ∙λ ∷ ά ∷ β ∷ ε ∷ τ ∷ ε ∷ []) "Phil.4.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.9" ∷ word (ἠ ∷ κ ∷ ο ∷ ύ ∷ σ ∷ α ∷ τ ∷ ε ∷ []) "Phil.4.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.9" ∷ word (ε ∷ ἴ ∷ δ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.4.9" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.9" ∷ word (ἐ ∷ μ ∷ ο ∷ ί ∷ []) "Phil.4.9" ∷ word (τ ∷ α ∷ ῦ ∷ τ ∷ α ∷ []) "Phil.4.9" ∷ word (π ∷ ρ ∷ ά ∷ σ ∷ σ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.4.9" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.9" ∷ word (ὁ ∷ []) "Phil.4.9" ∷ word (θ ∷ ε ∷ ὸ ∷ ς ∷ []) "Phil.4.9" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.4.9" ∷ word (ε ∷ ἰ ∷ ρ ∷ ή ∷ ν ∷ η ∷ ς ∷ []) "Phil.4.9" ∷ word (ἔ ∷ σ ∷ τ ∷ α ∷ ι ∷ []) "Phil.4.9" ∷ word (μ ∷ ε ∷ θ ∷ []) "Phil.4.9" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.4.9" ∷ word (Ἐ ∷ χ ∷ ά ∷ ρ ∷ η ∷ ν ∷ []) "Phil.4.10" ∷ word (δ ∷ ὲ ∷ []) "Phil.4.10" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.10" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ῳ ∷ []) "Phil.4.10" ∷ word (μ ∷ ε ∷ γ ∷ ά ∷ ∙λ ∷ ω ∷ ς ∷ []) "Phil.4.10" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.4.10" ∷ word (ἤ ∷ δ ∷ η ∷ []) "Phil.4.10" ∷ word (π ∷ ο ∷ τ ∷ ὲ ∷ []) "Phil.4.10" ∷ word (ἀ ∷ ν ∷ ε ∷ θ ∷ ά ∷ ∙λ ∷ ε ∷ τ ∷ ε ∷ []) "Phil.4.10" ∷ word (τ ∷ ὸ ∷ []) "Phil.4.10" ∷ word (ὑ ∷ π ∷ ὲ ∷ ρ ∷ []) "Phil.4.10" ∷ word (ἐ ∷ μ ∷ ο ∷ ῦ ∷ []) "Phil.4.10" ∷ word (φ ∷ ρ ∷ ο ∷ ν ∷ ε ∷ ῖ ∷ ν ∷ []) "Phil.4.10" ∷ word (ἐ ∷ φ ∷ []) "Phil.4.10" ∷ word (ᾧ ∷ []) "Phil.4.10" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.10" ∷ word (ἐ ∷ φ ∷ ρ ∷ ο ∷ ν ∷ ε ∷ ῖ ∷ τ ∷ ε ∷ []) "Phil.4.10" ∷ word (ἠ ∷ κ ∷ α ∷ ι ∷ ρ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ ε ∷ []) "Phil.4.10" ∷ word (δ ∷ έ ∷ []) "Phil.4.10" ∷ word (ο ∷ ὐ ∷ χ ∷ []) "Phil.4.11" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.4.11" ∷ word (κ ∷ α ∷ θ ∷ []) "Phil.4.11" ∷ word (ὑ ∷ σ ∷ τ ∷ έ ∷ ρ ∷ η ∷ σ ∷ ι ∷ ν ∷ []) "Phil.4.11" ∷ word (∙λ ∷ έ ∷ γ ∷ ω ∷ []) "Phil.4.11" ∷ word (ἐ ∷ γ ∷ ὼ ∷ []) "Phil.4.11" ∷ word (γ ∷ ὰ ∷ ρ ∷ []) "Phil.4.11" ∷ word (ἔ ∷ μ ∷ α ∷ θ ∷ ο ∷ ν ∷ []) "Phil.4.11" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.11" ∷ word (ο ∷ ἷ ∷ ς ∷ []) "Phil.4.11" ∷ word (ε ∷ ἰ ∷ μ ∷ ι ∷ []) "Phil.4.11" ∷ word (α ∷ ὐ ∷ τ ∷ ά ∷ ρ ∷ κ ∷ η ∷ ς ∷ []) "Phil.4.11" ∷ word (ε ∷ ἶ ∷ ν ∷ α ∷ ι ∷ []) "Phil.4.11" ∷ word (ο ∷ ἶ ∷ δ ∷ α ∷ []) "Phil.4.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.12" ∷ word (τ ∷ α ∷ π ∷ ε ∷ ι ∷ ν ∷ ο ∷ ῦ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Phil.4.12" ∷ word (ο ∷ ἶ ∷ δ ∷ α ∷ []) "Phil.4.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.12" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ε ∷ ύ ∷ ε ∷ ι ∷ ν ∷ []) "Phil.4.12" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.12" ∷ word (π ∷ α ∷ ν ∷ τ ∷ ὶ ∷ []) "Phil.4.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.12" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.12" ∷ word (π ∷ ᾶ ∷ σ ∷ ι ∷ ν ∷ []) "Phil.4.12" ∷ word (μ ∷ ε ∷ μ ∷ ύ ∷ η ∷ μ ∷ α ∷ ι ∷ []) "Phil.4.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.12" ∷ word (χ ∷ ο ∷ ρ ∷ τ ∷ ά ∷ ζ ∷ ε ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Phil.4.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.12" ∷ word (π ∷ ε ∷ ι ∷ ν ∷ ᾶ ∷ ν ∷ []) "Phil.4.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.12" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ε ∷ ύ ∷ ε ∷ ι ∷ ν ∷ []) "Phil.4.12" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.12" ∷ word (ὑ ∷ σ ∷ τ ∷ ε ∷ ρ ∷ ε ∷ ῖ ∷ σ ∷ θ ∷ α ∷ ι ∷ []) "Phil.4.12" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Phil.4.13" ∷ word (ἰ ∷ σ ∷ χ ∷ ύ ∷ ω ∷ []) "Phil.4.13" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.13" ∷ word (τ ∷ ῷ ∷ []) "Phil.4.13" ∷ word (ἐ ∷ ν ∷ δ ∷ υ ∷ ν ∷ α ∷ μ ∷ ο ∷ ῦ ∷ ν ∷ τ ∷ ί ∷ []) "Phil.4.13" ∷ word (μ ∷ ε ∷ []) "Phil.4.13" ∷ word (π ∷ ∙λ ∷ ὴ ∷ ν ∷ []) "Phil.4.14" ∷ word (κ ∷ α ∷ ∙λ ∷ ῶ ∷ ς ∷ []) "Phil.4.14" ∷ word (ἐ ∷ π ∷ ο ∷ ι ∷ ή ∷ σ ∷ α ∷ τ ∷ ε ∷ []) "Phil.4.14" ∷ word (σ ∷ υ ∷ γ ∷ κ ∷ ο ∷ ι ∷ ν ∷ ω ∷ ν ∷ ή ∷ σ ∷ α ∷ ν ∷ τ ∷ έ ∷ ς ∷ []) "Phil.4.14" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.4.14" ∷ word (τ ∷ ῇ ∷ []) "Phil.4.14" ∷ word (θ ∷ ∙λ ∷ ί ∷ ψ ∷ ε ∷ ι ∷ []) "Phil.4.14" ∷ word (Ο ∷ ἴ ∷ δ ∷ α ∷ τ ∷ ε ∷ []) "Phil.4.15" ∷ word (δ ∷ ὲ ∷ []) "Phil.4.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.15" ∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "Phil.4.15" ∷ word (Φ ∷ ι ∷ ∙λ ∷ ι ∷ π ∷ π ∷ ή ∷ σ ∷ ι ∷ ο ∷ ι ∷ []) "Phil.4.15" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.4.15" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.15" ∷ word (ἀ ∷ ρ ∷ χ ∷ ῇ ∷ []) "Phil.4.15" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.4.15" ∷ word (ε ∷ ὐ ∷ α ∷ γ ∷ γ ∷ ε ∷ ∙λ ∷ ί ∷ ο ∷ υ ∷ []) "Phil.4.15" ∷ word (ὅ ∷ τ ∷ ε ∷ []) "Phil.4.15" ∷ word (ἐ ∷ ξ ∷ ῆ ∷ ∙λ ∷ θ ∷ ο ∷ ν ∷ []) "Phil.4.15" ∷ word (ἀ ∷ π ∷ ὸ ∷ []) "Phil.4.15" ∷ word (Μ ∷ α ∷ κ ∷ ε ∷ δ ∷ ο ∷ ν ∷ ί ∷ α ∷ ς ∷ []) "Phil.4.15" ∷ word (ο ∷ ὐ ∷ δ ∷ ε ∷ μ ∷ ί ∷ α ∷ []) "Phil.4.15" ∷ word (μ ∷ ο ∷ ι ∷ []) "Phil.4.15" ∷ word (ἐ ∷ κ ∷ κ ∷ ∙λ ∷ η ∷ σ ∷ ί ∷ α ∷ []) "Phil.4.15" ∷ word (ἐ ∷ κ ∷ ο ∷ ι ∷ ν ∷ ώ ∷ ν ∷ η ∷ σ ∷ ε ∷ ν ∷ []) "Phil.4.15" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.4.15" ∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ν ∷ []) "Phil.4.15" ∷ word (δ ∷ ό ∷ σ ∷ ε ∷ ω ∷ ς ∷ []) "Phil.4.15" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.15" ∷ word (∙λ ∷ ή ∷ μ ∷ ψ ∷ ε ∷ ω ∷ ς ∷ []) "Phil.4.15" ∷ word (ε ∷ ἰ ∷ []) "Phil.4.15" ∷ word (μ ∷ ὴ ∷ []) "Phil.4.15" ∷ word (ὑ ∷ μ ∷ ε ∷ ῖ ∷ ς ∷ []) "Phil.4.15" ∷ word (μ ∷ ό ∷ ν ∷ ο ∷ ι ∷ []) "Phil.4.15" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.4.16" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.16" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.16" ∷ word (Θ ∷ ε ∷ σ ∷ σ ∷ α ∷ ∙λ ∷ ο ∷ ν ∷ ί ∷ κ ∷ ῃ ∷ []) "Phil.4.16" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.16" ∷ word (ἅ ∷ π ∷ α ∷ ξ ∷ []) "Phil.4.16" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.16" ∷ word (δ ∷ ὶ ∷ ς ∷ []) "Phil.4.16" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.4.16" ∷ word (τ ∷ ὴ ∷ ν ∷ []) "Phil.4.16" ∷ word (χ ∷ ρ ∷ ε ∷ ί ∷ α ∷ ν ∷ []) "Phil.4.16" ∷ word (μ ∷ ο ∷ ι ∷ []) "Phil.4.16" ∷ word (ἐ ∷ π ∷ έ ∷ μ ∷ ψ ∷ α ∷ τ ∷ ε ∷ []) "Phil.4.16" ∷ word (ο ∷ ὐ ∷ χ ∷ []) "Phil.4.17" ∷ word (ὅ ∷ τ ∷ ι ∷ []) "Phil.4.17" ∷ word (ἐ ∷ π ∷ ι ∷ ζ ∷ η ∷ τ ∷ ῶ ∷ []) "Phil.4.17" ∷ word (τ ∷ ὸ ∷ []) "Phil.4.17" ∷ word (δ ∷ ό ∷ μ ∷ α ∷ []) "Phil.4.17" ∷ word (ἀ ∷ ∙λ ∷ ∙λ ∷ ὰ ∷ []) "Phil.4.17" ∷ word (ἐ ∷ π ∷ ι ∷ ζ ∷ η ∷ τ ∷ ῶ ∷ []) "Phil.4.17" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Phil.4.17" ∷ word (κ ∷ α ∷ ρ ∷ π ∷ ὸ ∷ ν ∷ []) "Phil.4.17" ∷ word (τ ∷ ὸ ∷ ν ∷ []) "Phil.4.17" ∷ word (π ∷ ∙λ ∷ ε ∷ ο ∷ ν ∷ ά ∷ ζ ∷ ο ∷ ν ∷ τ ∷ α ∷ []) "Phil.4.17" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.4.17" ∷ word (∙λ ∷ ό ∷ γ ∷ ο ∷ ν ∷ []) "Phil.4.17" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.4.17" ∷ word (ἀ ∷ π ∷ έ ∷ χ ∷ ω ∷ []) "Phil.4.18" ∷ word (δ ∷ ὲ ∷ []) "Phil.4.18" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Phil.4.18" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.18" ∷ word (π ∷ ε ∷ ρ ∷ ι ∷ σ ∷ σ ∷ ε ∷ ύ ∷ ω ∷ []) "Phil.4.18" ∷ word (π ∷ ε ∷ π ∷ ∙λ ∷ ή ∷ ρ ∷ ω ∷ μ ∷ α ∷ ι ∷ []) "Phil.4.18" ∷ word (δ ∷ ε ∷ ξ ∷ ά ∷ μ ∷ ε ∷ ν ∷ ο ∷ ς ∷ []) "Phil.4.18" ∷ word (π ∷ α ∷ ρ ∷ ὰ ∷ []) "Phil.4.18" ∷ word (Ἐ ∷ π ∷ α ∷ φ ∷ ρ ∷ ο ∷ δ ∷ ί ∷ τ ∷ ο ∷ υ ∷ []) "Phil.4.18" ∷ word (τ ∷ ὰ ∷ []) "Phil.4.18" ∷ word (π ∷ α ∷ ρ ∷ []) "Phil.4.18" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.4.18" ∷ word (ὀ ∷ σ ∷ μ ∷ ὴ ∷ ν ∷ []) "Phil.4.18" ∷ word (ε ∷ ὐ ∷ ω ∷ δ ∷ ί ∷ α ∷ ς ∷ []) "Phil.4.18" ∷ word (θ ∷ υ ∷ σ ∷ ί ∷ α ∷ ν ∷ []) "Phil.4.18" ∷ word (δ ∷ ε ∷ κ ∷ τ ∷ ή ∷ ν ∷ []) "Phil.4.18" ∷ word (ε ∷ ὐ ∷ ά ∷ ρ ∷ ε ∷ σ ∷ τ ∷ ο ∷ ν ∷ []) "Phil.4.18" ∷ word (τ ∷ ῷ ∷ []) "Phil.4.18" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "Phil.4.18" ∷ word (ὁ ∷ []) "Phil.4.19" ∷ word (δ ∷ ὲ ∷ []) "Phil.4.19" ∷ word (θ ∷ ε ∷ ό ∷ ς ∷ []) "Phil.4.19" ∷ word (μ ∷ ο ∷ υ ∷ []) "Phil.4.19" ∷ word (π ∷ ∙λ ∷ η ∷ ρ ∷ ώ ∷ σ ∷ ε ∷ ι ∷ []) "Phil.4.19" ∷ word (π ∷ ᾶ ∷ σ ∷ α ∷ ν ∷ []) "Phil.4.19" ∷ word (χ ∷ ρ ∷ ε ∷ ί ∷ α ∷ ν ∷ []) "Phil.4.19" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.4.19" ∷ word (κ ∷ α ∷ τ ∷ ὰ ∷ []) "Phil.4.19" ∷ word (τ ∷ ὸ ∷ []) "Phil.4.19" ∷ word (π ∷ ∙λ ∷ ο ∷ ῦ ∷ τ ∷ ο ∷ ς ∷ []) "Phil.4.19" ∷ word (α ∷ ὐ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.4.19" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.19" ∷ word (δ ∷ ό ∷ ξ ∷ ῃ ∷ []) "Phil.4.19" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.19" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phil.4.19" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.4.19" ∷ word (τ ∷ ῷ ∷ []) "Phil.4.20" ∷ word (δ ∷ ὲ ∷ []) "Phil.4.20" ∷ word (θ ∷ ε ∷ ῷ ∷ []) "Phil.4.20" ∷ word (κ ∷ α ∷ ὶ ∷ []) "Phil.4.20" ∷ word (π ∷ α ∷ τ ∷ ρ ∷ ὶ ∷ []) "Phil.4.20" ∷ word (ἡ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.4.20" ∷ word (ἡ ∷ []) "Phil.4.20" ∷ word (δ ∷ ό ∷ ξ ∷ α ∷ []) "Phil.4.20" ∷ word (ε ∷ ἰ ∷ ς ∷ []) "Phil.4.20" ∷ word (τ ∷ ο ∷ ὺ ∷ ς ∷ []) "Phil.4.20" ∷ word (α ∷ ἰ ∷ ῶ ∷ ν ∷ α ∷ ς ∷ []) "Phil.4.20" ∷ word (τ ∷ ῶ ∷ ν ∷ []) "Phil.4.20" ∷ word (α ∷ ἰ ∷ ώ ∷ ν ∷ ω ∷ ν ∷ []) "Phil.4.20" ∷ word (ἀ ∷ μ ∷ ή ∷ ν ∷ []) "Phil.4.20" ∷ word (Ἀ ∷ σ ∷ π ∷ ά ∷ σ ∷ α ∷ σ ∷ θ ∷ ε ∷ []) "Phil.4.21" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ α ∷ []) "Phil.4.21" ∷ word (ἅ ∷ γ ∷ ι ∷ ο ∷ ν ∷ []) "Phil.4.21" ∷ word (ἐ ∷ ν ∷ []) "Phil.4.21" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ῷ ∷ []) "Phil.4.21" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.4.21" ∷ word (ἀ ∷ σ ∷ π ∷ ά ∷ ζ ∷ ο ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Phil.4.21" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.4.21" ∷ word (ο ∷ ἱ ∷ []) "Phil.4.21" ∷ word (σ ∷ ὺ ∷ ν ∷ []) "Phil.4.21" ∷ word (ἐ ∷ μ ∷ ο ∷ ὶ ∷ []) "Phil.4.21" ∷ word (ἀ ∷ δ ∷ ε ∷ ∙λ ∷ φ ∷ ο ∷ ί ∷ []) "Phil.4.21" ∷ word (ἀ ∷ σ ∷ π ∷ ά ∷ ζ ∷ ο ∷ ν ∷ τ ∷ α ∷ ι ∷ []) "Phil.4.22" ∷ word (ὑ ∷ μ ∷ ᾶ ∷ ς ∷ []) "Phil.4.22" ∷ word (π ∷ ά ∷ ν ∷ τ ∷ ε ∷ ς ∷ []) "Phil.4.22" ∷ word (ο ∷ ἱ ∷ []) "Phil.4.22" ∷ word (ἅ ∷ γ ∷ ι ∷ ο ∷ ι ∷ []) "Phil.4.22" ∷ word (μ ∷ ά ∷ ∙λ ∷ ι ∷ σ ∷ τ ∷ α ∷ []) "Phil.4.22" ∷ word (δ ∷ ὲ ∷ []) "Phil.4.22" ∷ word (ο ∷ ἱ ∷ []) "Phil.4.22" ∷ word (ἐ ∷ κ ∷ []) "Phil.4.22" ∷ word (τ ∷ ῆ ∷ ς ∷ []) "Phil.4.22" ∷ word (Κ ∷ α ∷ ί ∷ σ ∷ α ∷ ρ ∷ ο ∷ ς ∷ []) "Phil.4.22" ∷ word (ο ∷ ἰ ∷ κ ∷ ί ∷ α ∷ ς ∷ []) "Phil.4.22" ∷ word (ἡ ∷ []) "Phil.4.23" ∷ word (χ ∷ ά ∷ ρ ∷ ι ∷ ς ∷ []) "Phil.4.23" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.4.23" ∷ word (κ ∷ υ ∷ ρ ∷ ί ∷ ο ∷ υ ∷ []) "Phil.4.23" ∷ word (Ἰ ∷ η ∷ σ ∷ ο ∷ ῦ ∷ []) "Phil.4.23" ∷ word (Χ ∷ ρ ∷ ι ∷ σ ∷ τ ∷ ο ∷ ῦ ∷ []) "Phil.4.23" ∷ word (μ ∷ ε ∷ τ ∷ ὰ ∷ []) "Phil.4.23" ∷ word (τ ∷ ο ∷ ῦ ∷ []) "Phil.4.23" ∷ word (π ∷ ν ∷ ε ∷ ύ ∷ μ ∷ α ∷ τ ∷ ο ∷ ς ∷ []) "Phil.4.23" ∷ word (ὑ ∷ μ ∷ ῶ ∷ ν ∷ []) "Phil.4.23" ∷ []
{ "alphanum_fraction": 0.343901484, "avg_line_length": 45.2406841784, "ext": "agda", "hexsha": "b735e16ba7d937da68872976071ba9b4cf6c09d3", "lang": "Agda", "max_forks_count": 5, "max_forks_repo_forks_event_max_datetime": "2017-06-11T11:25:09.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-27T22:34:13.000Z", "max_forks_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "scott-fleischman/GreekGrammar", "max_forks_repo_path": "agda/Text/Greek/SBLGNT/Phil.agda", "max_issues_count": 13, "max_issues_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_issues_repo_issues_event_max_datetime": "2020-09-07T11:58:38.000Z", "max_issues_repo_issues_event_min_datetime": "2015-05-28T20:04:08.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "scott-fleischman/GreekGrammar", "max_issues_repo_path": "agda/Text/Greek/SBLGNT/Phil.agda", "max_line_length": 90, "max_stars_count": 44, "max_stars_repo_head_hexsha": "915c46c27c7f8aad5907474d8484f2685a4cd6a7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "scott-fleischman/GreekGrammar", "max_stars_repo_path": "agda/Text/Greek/SBLGNT/Phil.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-06T15:41:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-29T14:48:51.000Z", "num_tokens": 51070, "size": 74059 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Orders.Total.Definition module Orders.Total.Lemmas {a b : _} {A : Set a} (order : TotalOrder A {b}) where open TotalOrder order equivMin : {x y : A} → (x < y) → min x y ≡ x equivMin {x} {y} x<y with totality x y equivMin {x} {y} x<y | inl (inl x₁) = refl equivMin {x} {y} x<y | inl (inr y<x) = exFalso (irreflexive (<Transitive x<y y<x)) equivMin {x} {y} x<y | inr x=y rewrite x=y = refl equivMin' : {x y : A} → (min x y ≡ x) → (x < y) || (x ≡ y) equivMin' {x} {y} minEq with totality x y equivMin' {x} {y} minEq | inl (inl x<y) = inl x<y equivMin' {x} {y} minEq | inl (inr y<x) = exFalso (irreflexive (identityOfIndiscernablesLeft _<_ y<x minEq)) equivMin' {x} {y} minEq | inr x=y = inr x=y minCommutes : (x y : A) → (min x y) ≡ (min y x) minCommutes x y with totality x y minCommutes x y | inl (inl x<y) with totality y x minCommutes x y | inl (inl x<y) | inl (inl y<x) = exFalso (irreflexive (<Transitive y<x x<y)) minCommutes x y | inl (inl x<y) | inl (inr x<y') = refl minCommutes x y | inl (inl x<y) | inr y=x = equalityCommutative y=x minCommutes x y | inl (inr y<x) with totality y x minCommutes x y | inl (inr y<x) | inl (inl y<x') = refl minCommutes x y | inl (inr y<x) | inl (inr x<y) = exFalso (irreflexive (<Transitive y<x x<y)) minCommutes x y | inl (inr y<x) | inr y=x = refl minCommutes x y | inr x=y with totality y x minCommutes x y | inr x=y | inl (inl x₁) = x=y minCommutes x y | inr x=y | inl (inr x₁) = refl minCommutes x y | inr x=y | inr x₁ = x=y minIdempotent : (x : A) → min x x ≡ x minIdempotent x with totality x x minIdempotent x | inl (inl x₁) = refl minIdempotent x | inl (inr x₁) = refl minIdempotent x | inr x₁ = refl swapMin : {x y z : A} → (min x (min y z)) ≡ min y (min x z) swapMin {x} {y} {z} with totality y z swapMin {x} {y} {z} | inl (inl y<z) with totality x z swapMin {x} {y} {z} | inl (inl y<z) | inl (inl x<z) = minCommutes x y swapMin {x} {y} {z} | inl (inl y<z) | inl (inr z<x) with totality x y swapMin {x} {y} {z} | inl (inl y<z) | inl (inr z<x) | inl (inl x<y) = exFalso (irreflexive (<Transitive y<z (<Transitive z<x x<y))) swapMin {x} {y} {z} | inl (inl y<z) | inl (inr z<x) | inl (inr y<x) = equalityCommutative (equivMin y<z) swapMin {x} {y} {z} | inl (inl y<z) | inl (inr z<x) | inr x=y rewrite x=y = equalityCommutative (equivMin y<z) swapMin {x} {y} {z} | inl (inl y<z) | inr x=z = minCommutes x y swapMin {x} {y} {z} | inl (inr z<y) with totality x z swapMin {x} {y} {z} | inl (inr z<y) | inl (inl x<z) rewrite minCommutes y x = equalityCommutative (equivMin (<Transitive x<z z<y)) swapMin {x} {y} {z} | inl (inr z<y) | inl (inr z<x) with totality y z swapMin {x} {y} {z} | inl (inr z<y) | inl (inr z<x) | inl (inl y<z) = exFalso (irreflexive (<Transitive z<y y<z)) swapMin {x} {y} {z} | inl (inr z<y) | inl (inr z<x) | inl (inr z<y') = refl swapMin {x} {y} {z} | inl (inr z<y) | inl (inr z<x) | inr y=z = equalityCommutative y=z swapMin {x} {y} {z} | inl (inr z<y) | inr x=z rewrite x=z | minCommutes y z = equalityCommutative (equivMin z<y) swapMin {x} {y} {z} | inr y=z with totality x z swapMin {x} {y} {z} | inr y=z | inl (inl x<z) = minCommutes x y swapMin {x} {y} {z} | inr y=z | inl (inr z<x) rewrite y=z | minIdempotent z | minCommutes x z = equivMin z<x swapMin {x} {y} {z} | inr y=z | inr x=z = minCommutes x y minMin : {x y : A} → (min x (min x y)) ≡ min x y minMin {x} {y} with totality x y minMin {x} {y} | inl (inl x<y) = minIdempotent x minMin {x} {y} | inl (inr y<x) with totality x y minMin {x} {y} | inl (inr y<x) | inl (inl x<y) = exFalso (irreflexive (<Transitive y<x x<y)) minMin {x} {y} | inl (inr y<x) | inl (inr y<x') = refl minMin {x} {y} | inl (inr y<x) | inr x=y = x=y minMin {x} {y} | inr x=y = minIdempotent x minFromBoth : {l x y : A} → (l < x) → (l < y) → (l < (min x y)) minFromBoth {a} {x = x} {y} prX prY with totality x y minFromBoth {a} prX prY | inl (inl x<y) = prX minFromBoth {a} prX prY | inl (inr y<x) = prY minFromBoth {a} prX prY | inr x=y = prX
{ "alphanum_fraction": 0.6086419753, "avg_line_length": 51.2658227848, "ext": "agda", "hexsha": "f63668100e42d5b9e118a43405424fb26a45bd8a", "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": "Orders/Total/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": "Orders/Total/Lemmas.agda", "max_line_length": 131, "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": "Orders/Total/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": 1823, "size": 4050 }
module Dave.LeibnizEquality where open import Dave.Equality public _≐_ : ∀ {A : Set} (x y : A) → Set₁ _≐_ {A} x y = ∀ (P : A → Set) → P x → P y refl-≐ : ∀ {A : Set} {x : A} → x ≐ x refl-≐ P Px = Px trans-≐ : ∀ {A : Set} {x y z : A} → x ≐ y → y ≐ z → x ≐ z trans-≐ x≐y y≐z P Px = y≐z P (x≐y P Px) sym-≐ : ∀ {A : Set} {x y : A} → x ≐ y → y ≐ x sym-≐ {A} {x} {y} x≐y P = Qy where Q : A → Set Q z = P z → P x Qx : Q x Qx = refl-≐ P Qy : Q y Qy = x≐y Q Qx ≡→≐ : ∀ {A : Set} {x y : A} → x ≡ y → x ≐ y ≡→≐ x≡y P = subst P x≡y ≐→≡ : ∀ {A : Set} {x y : A} → x ≐ y → x ≡ y ≐→≡ {A} {x} {y} x≐y = Qy where Q : A → Set Q z = x ≡ z Qx : Q x Qx = refl Qy : Q y Qy = x≐y Q Qx
{ "alphanum_fraction": 0.3212258797, "avg_line_length": 25.9117647059, "ext": "agda", "hexsha": "a23f5a9198df1454935735cf7085df5257f59453", "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": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DavidStahl97/formal-proofs", "max_forks_repo_path": "Dave/LeibnizEquality.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "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": "DavidStahl97/formal-proofs", "max_issues_repo_path": "Dave/LeibnizEquality.agda", "max_line_length": 61, "max_stars_count": null, "max_stars_repo_head_hexsha": "05213fb6ab1f51f770f9858b61526ba950e06232", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DavidStahl97/formal-proofs", "max_stars_repo_path": "Dave/LeibnizEquality.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 423, "size": 881 }
------------------------------------------------------------------------ -- Code used to construct tactics aimed at making equational reasoning -- proofs more readable ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} open import Equality module Tactic.By {c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where open Derived-definitions-and-properties eq import Agda.Builtin.Bool as B open import Agda.Builtin.Nat using (_==_) open import Agda.Builtin.String open import Prelude open import List eq open import Monad eq open import Monad.State eq hiding (set) open import TC-monad eq as TC hiding (Type) -- Constructs the type of a "cong" function for functions with the -- given number of arguments. The first argument must be a function -- that constructs the type of equalities between its two arguments. type-of-cong : (Term → Term → TC.Type) → ℕ → TC.Type type-of-cong equality n = levels (suc n) where -- The examples below are given for n = 3. -- Generates x₁ x₂ x₃ or y₁ y₂ y₃. arguments : ℕ → ℕ → List (Arg Term) arguments delta (suc m) = varg (var (delta + 2 * m + 1 + n) []) ∷ arguments delta m arguments delta zero = [] -- Generates x₁ ≡ y₁ → x₂ ≡ y₂ → x₃ ≡ y₃ → f x₁ x₂ x₃ ≡ f y₁ y₂ y₃. equalities : ℕ → TC.Type equalities (suc m) = pi (varg (equality (var (1 + 2 * m + 1 + (n ∸ suc m)) []) (var (0 + 2 * m + 1 + (n ∸ suc m)) []))) $ abs "x≡y" $ equalities m equalities zero = equality (var n (arguments 1 n)) (var n (arguments 0 n)) -- Generates A → B → C → D. function-type : ℕ → TC.Type function-type (suc m) = pi (varg (var (3 * n) [])) (abs "_" (function-type m)) function-type zero = var (3 * n) [] -- Generates ∀ {x₁ y₁ x₂ y₂ x₃ y₃} → … variables : ℕ → TC.Type variables (suc m) = pi (harg unknown) $ abs "x" $ pi (harg unknown) $ abs "y" $ variables m variables zero = pi (varg (function-type n)) $ abs "f" $ equalities n -- Generates -- {A : Set a} {B : Set b} {C : Set c} {D : Set d} → …. types : ℕ → TC.Type types (suc m) = pi (harg (agda-sort (set (var n [])))) $ abs "A" $ types m types zero = variables n -- Generates {a b c d : Level} → …. levels : ℕ → TC.Type levels (suc n) = pi (harg (def (quote Level) [])) $ abs "a" $ levels n levels zero = types (suc n) -- Used to mark the subterms that should be rewritten by the ⟨by⟩ -- tactic. -- -- The idea to mark subterms in this way is taken from Bradley -- Hardy, who used it in the Holes library -- (https://github.com/bch29/agda-holes). ⟨_⟩ : ∀ {a} {A : Type a} → A → A ⟨_⟩ = id {-# NOINLINE ⟨_⟩ #-} module _ (deconstruct-equality : TC.Type → TC (Maybe (Term × TC.Type × Term × Term))) -- Tries to deconstruct a type which is expected to be an equality, -- _≡_ {a = a} {A = A} x y, but in reduced form. Upon success the -- level a, the type A, the left-hand side x, and the right-hand -- side y are returned. If it is hard to determine a or A, then -- unknown can be returned instead. If the type does not have the -- right form, then nothing is returned. where private -- A variant of blockOnMeta which can print a debug message. blockOnMeta′ : {A : Type} → String → Meta → TC A blockOnMeta′ s m = do debugPrint "by" 20 (strErr "by/⟨by⟩ is blocking on meta" ∷ strErr (primShowMeta m) ∷ strErr "in" ∷ strErr s ∷ []) blockOnMeta m -- A variant of deconstruct-equality with the following -- differences: -- * If the type is a meta-variable, then the computation blocks. -- * If the type does not have the right form (and is not a -- meta-variable), then a type error is raised, and the given -- list is used as the error message. deconstruct-equality′ : List ErrorPart → TC.Type → TC (Term × TC.Type × Term × Term) deconstruct-equality′ err (meta m _) = blockOnMeta′ "deconstruct-equality′" m deconstruct-equality′ err t = do just r ← deconstruct-equality t where nothing → typeError err return r -- The computation apply-to-metas A t tries to apply the term t to -- as many fresh meta-variables as possible (based on its type, -- A). The type of the resulting term is returned. apply-to-metas : TC.Type → Term → TC (TC.Type × Term) apply-to-metas A t = apply A t =<< compute-args fuel [] A where -- Fuel, used to ensure termination. fuel : ℕ fuel = 100 mutual compute-args : ℕ → List (Arg Term) → TC.Type → TC (List (Arg Term)) compute-args zero _ _ = typeError (strErr "apply-to-metas failed" ∷ []) compute-args (suc n) args τ = compute-args′ n args =<< reduce τ compute-args′ : ℕ → List (Arg Term) → TC.Type → TC (List (Arg Term)) compute-args′ n args (pi a@(arg i _) (abs _ τ)) = extendContext a $ compute-args n (arg i unknown ∷ args) τ compute-args′ n args (meta x _) = blockOnMeta′ "apply-to-metas" x compute-args′ n args _ = return (reverse args) -- The ⟨by⟩ tactic. -- -- The tactic ⟨by⟩ t is intended for use with goals of the form -- C [ ⟨ e₁ ⟩ ] ≡ e₂ (with some limitations). The tactic tries to -- generate the term cong (λ x → C [ x ]) t′, where t′ is t applied -- to as many meta-variables as possible (based on its type), and if -- that term fails to unify with the goal type, then the term -- cong (λ x → C [ x ]) (sym t′) is generated instead. module ⟨By⟩ {Ctxt : Type} (context : TC Ctxt) -- A "context" type and a computation that computes some information -- related to the current context. The information is only -- guaranteed to be valid in the current context. (sym : Ctxt → Term → Term) -- An implementation of symmetry. (cong : Ctxt → Term → Term → Term → Term → Term) -- An implementation of cong. Arguments: left-hand side, -- right-hand side, function, equality. (cong-with-lhs-and-rhs : Bool) -- Should the cong function be applied to the "left-hand side" and -- the "right-hand side" (the two sides of the inferred type of -- the constructed equality proof), or should those arguments be -- left for Agda's unification machinery? where private -- A non-macro variant of ⟨by⟩ that returns the (first) -- constructed term. ⟨by⟩-tactic : ∀ {a} {A : Type a} → A → Term → TC Term ⟨by⟩-tactic {A = A} t goal = do -- To avoid wasted work the first block below, which can block -- the tactic, is run before the second one. goal-type ← reduce =<< inferType goal _ , _ , lhs , _ ← deconstruct-equality′ err₁ goal-type f ← construct-context lhs A ← quoteTC A t ← quoteTC t A , t ← apply-to-metas A t if not cong-with-lhs-and-rhs then conclude unknown unknown f t else do A ← reduce A _ , _ , lhs , rhs ← deconstruct-equality′ err₂ A conclude lhs rhs f t where err₁ = strErr "⟨by⟩: ill-formed goal" ∷ [] err₂ = strErr "⟨by⟩: ill-formed proof" ∷ [] try : Term → TC ⊤ try t = do debugPrint "by" 10 $ strErr "Term tried by ⟨by⟩:" ∷ termErr t ∷ [] unify t goal conclude : Term → Term → Term → Term → TC Term conclude lhs rhs f t = do ctxt ← context let t₁ = cong ctxt lhs rhs f t t₂ = cong ctxt rhs lhs f (sym ctxt t) catchTC (try t₁) (try t₂) return t₁ mutual -- The natural number argument is the variable that should -- be used for the hole. The natural number in the state is -- the number of occurrences of the marker that have been -- found. -- The code traverses arguments from right to left: in some -- cases it is better to block on the last meta-variable -- than the first one (because the first one might get -- instantiated before the last one, so when the last one is -- instantiated all the others have hopefully already been -- instantiated). context-term : ℕ → Term → StateT ℕ TC Term context-term n = λ where (def f args) → if eq-Name f (quote ⟨_⟩) then modify suc >> return (var n []) else def f ⟨$⟩ context-args n args (var x args) → var (weaken-var n 1 x) ⟨$⟩ context-args n args (con c args) → con c ⟨$⟩ context-args n args (lam v t) → lam v ⟨$⟩ context-abs n t (pi a b) → flip pi ⟨$⟩ context-abs n b ⊛ context-arg n a (meta m _) → liftʳ $ blockOnMeta′ "construct-context" m t → return (weaken-term n 1 t) context-abs : ℕ → Abs Term → StateT ℕ TC (Abs Term) context-abs n (abs s t) = abs s ⟨$⟩ context-term (suc n) t context-arg : ℕ → Arg Term → StateT ℕ TC (Arg Term) context-arg n (arg i t) = arg i ⟨$⟩ context-term n t context-args : ℕ → List (Arg Term) → StateT ℕ TC (List (Arg Term)) context-args n = λ where [] → return [] (a ∷ as) → flip _∷_ ⟨$⟩ context-args n as ⊛ context-arg n a construct-context : Term → TC Term construct-context lhs = do debugPrint "by" 20 (strErr "⟨by⟩ was given the left-hand side" ∷ termErr lhs ∷ []) body , n ← run (context-term 0 lhs) 0 case n of λ where (suc _) → return (lam visible (abs "x" body)) zero → typeError $ strErr "⟨by⟩: no occurrence of ⟨_⟩ found" ∷ [] macro -- The ⟨by⟩ tactic. ⟨by⟩ : ∀ {a} {A : Type a} → A → Term → TC ⊤ ⟨by⟩ t goal = do ⟨by⟩-tactic t goal return _ -- Unit tests can be found in Tactic.By.Parametrised.Tests, -- Tactic.By.Propositional, Tactic.By.Path and Tactic.By.Id. -- If ⟨by⟩ t would have been successful, then debug-⟨by⟩ t -- raises an error message that includes the (first) term that -- would have been constructed by ⟨by⟩. debug-⟨by⟩ : ∀ {a} {A : Type a} → A → Term → TC ⊤ debug-⟨by⟩ t goal = do t ← ⟨by⟩-tactic t goal typeError (strErr "Term found by ⟨by⟩:" ∷ termErr t ∷ []) -- The by tactic. module By (sym : Term → Term) -- An implementation of symmetry. (equality : Term → Term → TC.Type) -- Constructs the type of equalities between its two arguments. (refl : Term → Term → Term → Term) -- An implementation of reflexivity. Should take a level a, a type -- A : Set a, and a value x : A, and return a proof of x ≡ x. (make-cong : ℕ → TC Name) -- The computation make-cong n should generate a "cong" function -- for functions with n arguments. The type of this function -- should match that generated by type-of-cong equality n. (The -- functions are used fully applied, and implicit arguments are -- not given explicitly, so hopefully the ordering of implicit -- arguments with respect to each other and the explicit arguments -- does not matter.) (extra-check-in-try-refl : Bool) -- When the by tactic tries to solve a subgoal using reflexivity, -- should it make sure that, afterwards, the goal meta-variable -- reduces to something that is not a meta-variable? where private -- The call by-tactic t goal tries to use (non-dependent) "cong" -- functions, reflexivity and t (via refine) to solve the given -- goal (which must be an equality). -- -- The constructed term is returned. by-tactic : ∀ {a} {A : Type a} → A → Term → TC Term by-tactic {A = A} t goal = do A ← quoteTC A t ← quoteTC t _ , t ← apply-to-metas A t by-tactic′ fuel t goal where -- Fuel, used to ensure termination. (Termination could -- perhaps be proved in some way, but using fuel was easier.) fuel : ℕ fuel = 100 -- The tactic's main loop. by-tactic′ : ℕ → Term → Term → TC Term by-tactic′ zero _ _ = typeError (strErr "by: no more fuel" ∷ []) by-tactic′ (suc n) t goal = do goal-type ← reduce =<< inferType goal block-if-meta goal-type catchTC (try-refl goal-type) $ catchTC (try t) $ catchTC (try (sym t)) $ try-cong goal-type where -- Error messages. ill-formed : List ErrorPart ill-formed = strErr "by: ill-formed goal" ∷ [] failure : {A : Type} → TC A failure = typeError (strErr "by failed" ∷ []) -- Blocks if the goal type is not sufficiently concrete. -- Raises a type error if the goal type is not an equality. block-if-meta : TC.Type → TC ⊤ block-if-meta type = do eq ← deconstruct-equality′ ill-formed type case eq of λ where (_ , _ , meta m _ , _) → blockOnMeta′ "block-if-meta (left)" m (_ , _ , _ , meta m _) → blockOnMeta′ "block-if-meta (right)" m _ → return _ -- Tries to solve the goal using reflexivity. try-refl : TC.Type → TC Term try-refl type = do a , A , lhs , _ ← deconstruct-equality′ ill-formed type let t′ = refl a A lhs unify t′ goal if not extra-check-in-try-refl then return t′ else do -- If unification succeeds, but the goal is solved by a -- meta-variable, then this attempt is aborted. (A check -- similar to this one was suggested by Ulf Norell.) -- Potential future improvement: If unification results -- in unsolved constraints, block until progress has -- been made on those constraints. goal ← reduce goal case goal of λ where (meta _ _) → failure _ → return t′ -- Tries to solve the goal using the given term. try : Term → TC Term try t = do unify t goal return t -- Tries to solve the goal using one of the "cong" -- functions. try-cong : TC.Type → TC Term try-cong type = do _ , _ , y , z ← deconstruct-equality′ ill-formed type head , ys , zs ← heads y z args ← arguments ys zs cong ← make-cong (length args) let t = def cong (varg head ∷ args) unify t goal return t where -- Checks if the heads are equal. If they are, then the -- function figures out how many arguments are equal, and -- returns the (unique) head applied to these arguments, -- plus two lists containing the remaining arguments. heads : Term → Term → TC (Term × List (Arg Term) × List (Arg Term)) heads = λ { (def y ys) (def z zs) → helper (primQNameEquality y z) (def y) (def z) ys zs ; (con y ys) (con z zs) → helper (primQNameEquality y z) (con y) (con z) ys zs ; (var y ys) (var z zs) → helper (y == z) (var y) (var z) ys zs ; _ _ → failure } where find-equal-arguments : List (Arg Term) → List (Arg Term) → List (Arg Term) × List (Arg Term) × List (Arg Term) find-equal-arguments [] zs = [] , [] , zs find-equal-arguments ys [] = [] , ys , [] find-equal-arguments (y ∷ ys) (z ∷ zs) with eq-Arg y z ... | false = [] , y ∷ ys , z ∷ zs ... | true with find-equal-arguments ys zs ... | (es , ys′ , zs′) = y ∷ es , ys′ , zs′ helper : B.Bool → _ → _ → _ → _ → _ helper B.false y z _ _ = typeError (strErr "by: distinct heads:" ∷ termErr (y []) ∷ termErr (z []) ∷ []) helper B.true y _ ys zs = let es , ys′ , zs′ = find-equal-arguments ys zs in return (y es , ys′ , zs′) -- Tries to prove that the argument lists are equal. arguments : List (Arg Term) → List (Arg Term) → TC (List (Arg Term)) arguments [] [] = return [] arguments (arg (arg-info visible _) y ∷ ys) (arg (arg-info visible _) z ∷ zs) = do -- Relevance is ignored. goal ← checkType unknown (equality y z) t ← by-tactic′ n t goal args ← arguments ys zs return (varg t ∷ args) -- Hidden and instance arguments are ignored. arguments (arg (arg-info hidden _) _ ∷ ys) zs = arguments ys zs arguments (arg (arg-info instance′ _) _ ∷ ys) zs = arguments ys zs arguments ys (arg (arg-info hidden _) _ ∷ zs) = arguments ys zs arguments ys (arg (arg-info instance′ _) _ ∷ zs) = arguments ys zs arguments _ _ = failure macro -- The call by t tries to use t (along with congruence, -- reflexivity and symmetry) to solve the goal, which must be an -- equality. by : ∀ {a} {A : Type a} → A → Term → TC ⊤ by t goal = do by-tactic t goal return _ -- Unit tests can be found in Tactic.By.Propositional, -- Tactic.By.Path and Tactic.By.Id. -- If by t would have been successful, then debug-by t raises an -- error message that includes the term that would have been -- constructed by by. debug-by : ∀ {a} {A : Type a} → A → Term → TC ⊤ debug-by t goal = do t ← by-tactic t goal typeError (strErr "Term found by by:" ∷ termErr t ∷ []) -- A definition that provides no information. Intended to be used -- together with the by tactic: "by definition". definition : ⊤ definition = _ -- A module that exports both tactics. The "context" type is not -- supported. module Tactics (deconstruct-equality : TC.Type → TC (Maybe (Term × TC.Type × Term × Term))) (equality : Term → Term → TC.Type) (refl : Term → Term → Term → Term) (sym : Term → Term) (cong : Term → Term → Term → Term → Term) (cong-with-lhs-and-rhs : Bool) (make-cong : ℕ → TC Name) (extra-check-in-try-refl : Bool) where open ⟨By⟩ deconstruct-equality (return tt) (λ _ → sym) (λ _ → cong) cong-with-lhs-and-rhs public open By deconstruct-equality sym equality refl make-cong extra-check-in-try-refl public
{ "alphanum_fraction": 0.5365778689, "avg_line_length": 36.9696969697, "ext": "agda", "hexsha": "56ab20724fd920e99f8acf4310740e7b31126b86", "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/Tactic/By.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/Tactic/By.agda", "max_line_length": 78, "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/Tactic/By.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": 5324, "size": 19520 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Unit.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Nat open import Cubical.Data.Unit.Base open import Cubical.Data.Prod.Base open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv isContrUnit : isContr Unit isContrUnit = tt , λ {tt → refl} isPropUnit : isProp Unit isPropUnit _ _ i = tt -- definitionally equal to: isContr→isProp isContrUnit isSetUnit : isSet Unit isSetUnit = isProp→isSet isPropUnit isOfHLevelUnit : (n : HLevel) → isOfHLevel n Unit isOfHLevelUnit n = isContr→isOfHLevel n isContrUnit diagonal-unit : Unit ≡ Unit × Unit diagonal-unit = isoToPath (iso (λ x → tt , tt) (λ x → tt) (λ {(tt , tt) i → tt , tt}) λ {tt i → tt}) fibId : ∀ {ℓ} (A : Type ℓ) → (fiber (λ (x : A) → tt) tt) ≡ A fibId A = isoToPath (iso fst (λ a → a , refl) (λ _ → refl) (λ a i → fst a , isOfHLevelSuc 1 isPropUnit _ _ (snd a) refl i))
{ "alphanum_fraction": 0.6598939929, "avg_line_length": 29.7894736842, "ext": "agda", "hexsha": "8964cc811a205cff1c6af85dab0e221caecaa290", "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/Unit/Properties.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/Unit/Properties.agda", "max_line_length": 100, "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/Unit/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 355, "size": 1132 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Relation.Binary.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.HITs.SetQuotients.Base open import Cubical.HITs.PropositionalTruncation.Base open import Cubical.Foundations.Equiv.Fiberwise open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism private variable ℓA ℓA' ℓ ℓ' ℓ≅A ℓ≅A' ℓB : Level -- Rel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ')) -- Rel A B ℓ' = A → B → Type ℓ' Rel : (A : Type ℓA) (B : Type ℓB) (ℓ : Level) → Type (ℓ-max (ℓ-suc ℓ) (ℓ-max ℓA ℓB)) Rel A B ℓ = A → B → Type ℓ PropRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ')) PropRel A B ℓ' = Σ[ R ∈ Rel A B ℓ' ] ∀ a b → isProp (R a b) idPropRel : ∀ {ℓ} (A : Type ℓ) → PropRel A A ℓ idPropRel A .fst a a' = ∥ a ≡ a' ∥ idPropRel A .snd _ _ = squash invPropRel : ∀ {ℓ ℓ'} {A B : Type ℓ} → PropRel A B ℓ' → PropRel B A ℓ' invPropRel R .fst b a = R .fst a b invPropRel R .snd b a = R .snd a b compPropRel : ∀ {ℓ ℓ' ℓ''} {A B C : Type ℓ} → PropRel A B ℓ' → PropRel B C ℓ'' → PropRel A C (ℓ-max ℓ (ℓ-max ℓ' ℓ'')) compPropRel R S .fst a c = ∥ Σ[ b ∈ _ ] (R .fst a b × S .fst b c) ∥ compPropRel R S .snd _ _ = squash graphRel : ∀ {ℓ} {A B : Type ℓ} → (A → B) → Rel A B ℓ graphRel f a b = f a ≡ b module _ {ℓ ℓ' : Level} {A : Type ℓ} (_R_ : Rel A A ℓ') where -- R is reflexive isRefl : Type (ℓ-max ℓ ℓ') isRefl = (a : A) → a R a -- R is symmetric isSym : Type (ℓ-max ℓ ℓ') isSym = (a b : A) → a R b → b R a -- R is transitive isTrans : Type (ℓ-max ℓ ℓ') isTrans = (a b c : A) → a R b → b R c → a R c record isEquivRel : Type (ℓ-max ℓ ℓ') where constructor equivRel field reflexive : isRefl symmetric : isSym transitive : isTrans isPropValued : Type (ℓ-max ℓ ℓ') isPropValued = (a b : A) → isProp (a R b) isEffective : Type (ℓ-max ℓ ℓ') isEffective = (a b : A) → isEquiv (eq/ {R = _R_} a b) -- the total space corresponding to the binary relation w.r.t. a relSinglAt : (a : A) → Type (ℓ-max ℓ ℓ') relSinglAt a = Σ[ a' ∈ A ] (a R a') -- the statement that the total space is contractible at any a contrRelSingl : Type (ℓ-max ℓ ℓ') contrRelSingl = (a : A) → isContr (relSinglAt a) -- assume a reflexive binary relation module _ (ρ : isRefl) where -- identity is the least reflexive relation ≡→R : {a a' : A} → a ≡ a' → a R a' -- ≡→R {a} {a'} p = subst (λ z → a R z) p (ρ a) ≡→R {a} {a'} p = J (λ z q → a R z) (ρ a) p -- what it means for a reflexive binary relation to be univalent isUnivalent : Type (ℓ-max ℓ ℓ') isUnivalent = (a a' : A) → isEquiv (≡→R {a} {a'}) -- helpers for contrRelSingl→isUnivalent private module _ (a : A) where -- wrapper for ≡→R f = λ (a' : A) (p : a ≡ a') → ≡→R {a} {a'} p -- the corresponding total map that univalence -- of R will be reduced to totf : singl a → Σ[ a' ∈ A ] (a R a') totf (a' , p) = (a' , f a' p) -- if the total space corresponding to R is contractible -- then R is univalent -- because the singleton at a is also contractible contrRelSingl→isUnivalent : contrRelSingl → isUnivalent contrRelSingl→isUnivalent c a = q where abstract q = fiberEquiv (λ a' → a ≡ a') (λ a' → a R a') (f a) (snd (propBiimpl→Equiv (isContr→isProp (isContrSingl a)) (isContr→isProp (c a)) (totf a) (λ _ → fst (isContrSingl a)))) -- converse map. proof idea: -- equivalences preserve contractability, -- singletons are contractible -- and by the univalence assumption the total map is an equivalence isUnivalent→contrRelSingl : isUnivalent → contrRelSingl isUnivalent→contrRelSingl u a = q where abstract q = isContrRespectEquiv (totf a , totalEquiv (a ≡_) (a R_) (f a) λ a' → u a a') (isContrSingl a) isUnivalent' : Type (ℓ-max ℓ ℓ') isUnivalent' = (a a' : A) → (a ≡ a') ≃ a R a' private module _ (e : isUnivalent') (a : A) where -- wrapper for ≡→R g = λ (a' : A) (p : a ≡ a') → e a a' .fst p -- the corresponding total map that univalence -- of R will be reduced to totg : singl a → Σ[ a' ∈ A ] (a R a') totg (a' , p) = (a' , g a' p) isUnivalent'→contrRelSingl : isUnivalent' → contrRelSingl isUnivalent'→contrRelSingl u a = q where abstract q = isContrRespectEquiv (totg u a , totalEquiv (a ≡_) (a R_) (g u a) λ a' → u a a' .snd) (isContrSingl a) isUnivalent'→isUnivalent : isUnivalent' → isUnivalent isUnivalent'→isUnivalent u = contrRelSingl→isUnivalent (isUnivalent'→contrRelSingl u) isUnivalent→isUnivalent' : isUnivalent → isUnivalent' isUnivalent→isUnivalent' u a a' = ≡→R {a} {a'} , u a a' record RelIso {A : Type ℓA} (_≅_ : Rel A A ℓ≅A) {A' : Type ℓA'} (_≅'_ : Rel A' A' ℓ≅A') : Type (ℓ-max (ℓ-max ℓA ℓA') (ℓ-max ℓ≅A ℓ≅A')) where constructor reliso field fun : A → A' inv : A' → A rightInv : (a' : A') → fun (inv a') ≅' a' leftInv : (a : A) → inv (fun a) ≅ a RelIso→Iso : {A : Type ℓA} {A' : Type ℓA'} (_≅_ : Rel A A ℓ≅A) (_≅'_ : Rel A' A' ℓ≅A') {ρ : isRefl _≅_} {ρ' : isRefl _≅'_} (uni : isUnivalent _≅_ ρ) (uni' : isUnivalent _≅'_ ρ') (f : RelIso _≅_ _≅'_) → Iso A A' Iso.fun (RelIso→Iso _ _ _ _ f) = RelIso.fun f Iso.inv (RelIso→Iso _ _ _ _ f) = RelIso.inv f Iso.rightInv (RelIso→Iso _ _≅'_ {ρ' = ρ'} _ uni' f) a' = invEquiv (≡→R _≅'_ ρ' , uni' (RelIso.fun f (RelIso.inv f a')) a') .fst (RelIso.rightInv f a') Iso.leftInv (RelIso→Iso _≅_ _ {ρ = ρ} uni _ f) a = invEquiv (≡→R _≅_ ρ , uni (RelIso.inv f (RelIso.fun f a)) a) .fst (RelIso.leftInv f a) EquivRel : ∀ {ℓ} (A : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ')) EquivRel A ℓ' = Σ[ R ∈ Rel A A ℓ' ] isEquivRel R EquivPropRel : ∀ {ℓ} (A : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ')) EquivPropRel A ℓ' = Σ[ R ∈ PropRel A A ℓ' ] isEquivRel (R .fst)
{ "alphanum_fraction": 0.53311308, "avg_line_length": 35.0473684211, "ext": "agda", "hexsha": "c5e9d4b4bdce777d289c8df7c666a0d1072ac021", "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/Relation/Binary/Base.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/Relation/Binary/Base.agda", "max_line_length": 106, "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/Relation/Binary/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2520, "size": 6659 }
{-# OPTIONS --cubical --no-import-sorts #-} module Number.Bundles2 where open import Agda.Primitive renaming (_⊔_ to ℓ-max; lsuc to ℓ-suc; lzero to ℓ-zero) open import Cubical.Foundations.Everything renaming (_⁻¹ to _⁻¹ᵖ; assoc to ∙-assoc) -- open import Cubical.Foundations.Logic -- open import Cubical.Structures.Ring -- open import Cubical.Structures.Group -- open import Cubical.Structures.AbGroup open import Cubical.Relation.Nullary.Base -- ¬_ open import Cubical.Relation.Binary.Base open import Cubical.Data.Sum.Base renaming (_⊎_ to infixr 4 _⊎_) open import Cubical.Data.Sigma.Base renaming (_×_ to infixr 4 _×_) open import Cubical.Data.Empty renaming (elim to ⊥-elim; ⊥ to ⊥⊥) -- `⊥` and `elim` open import Cubical.Foundations.Logic renaming (¬_ to ¬ᵖ_; inl to inlᵖ; inr to inrᵖ) open import Function.Base using (it; _∋_) open import Cubical.HITs.PropositionalTruncation --.Properties open import Utils using (!_; !!_) open import MoreLogic.Reasoning open import MoreLogic.Definitions open import MoreLogic.Properties open import MorePropAlgebra.Definitions hiding (_≤''_) open import MorePropAlgebra.Consequences open import Number.Structures2 {- | name | struct | apart | abs | order | cauchy | sqrt₀⁺ | exp | final name | |------|---------------------|-------|-----|-------|--------|---------|-----|------------------------------------------------------------------------| | ℕ | CommSemiring | (✓) | (✓) | lin. | | (on x²) | | LinearlyOrderedCommSemiring | | ℤ | CommRing | (✓) | (✓) | lin. | | (on x²) | | LinearlyOrderedCommRing | | ℚ | Field | (✓) | (✓) | lin. | | (on x²) | (✓) | LinearlyOrderedField | | ℝ | Field | (✓) | (✓) | part. | ✓ | ✓ | (✓) | CompletePartiallyOrderedFieldWithSqrt | | ℂ | euclidean 2-Product | (✓) | (✓) | | (✓) | | ? | EuclideanTwoProductOfCompletePartiallyOrderedFieldWithSqrt | | R | Ring | ✓ | ✓ | | | | ? | ApartnessRingWithAbsIntoCompletePartiallyOrderedFieldWithSqrt | | G | Group | ✓ | ✓ | | | | ? | ApartnessGroupWithAbsIntoCompletePartiallyOrderedFieldWithSqrt | | K | Field | ✓ | ✓ | | ✓ | | ? | CompleteApartnessFieldWithAbsIntoCompletePartiallyOrderedFieldWithSqrt | -} record LinearlyOrderedCommSemiring {ℓ ℓ'} : Type (ℓ-suc (ℓ-max ℓ ℓ')) where constructor linearlyorderedcommsemiring field Carrier : Type ℓ 0f 1f : Carrier _+_ : Carrier → Carrier → Carrier _·_ : Carrier → Carrier → Carrier min max : Carrier → Carrier → Carrier _<_ : hPropRel Carrier Carrier ℓ' is-LinearlyOrderedCommSemiring : [ isLinearlyOrderedCommSemiring 0f 1f _+_ _·_ _<_ min max ] -- defines `_≤_` and `_#_` infixl 7 _·_ infixl 5 _+_ infixl 4 _<_ open IsLinearlyOrderedCommSemiring is-LinearlyOrderedCommSemiring public record LinearlyOrderedCommRing {ℓ ℓ'} : Type (ℓ-suc (ℓ-max ℓ ℓ')) where constructor linearlyorderedcommring field Carrier : Type ℓ 0f 1f : Carrier _+_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier _·_ : Carrier → Carrier → Carrier min max : Carrier → Carrier → Carrier _<_ : hPropRel Carrier Carrier ℓ' is-LinearlyOrderedCommRing : [ isLinearlyOrderedCommRing 0f 1f _+_ _·_ -_ _<_ min max ] -- defines `_≤_` and `_#_` infixl 7 _·_ infix 6 -_ infixl 5 _+_ infixl 4 _<_ open IsLinearlyOrderedCommRing is-LinearlyOrderedCommRing public record LinearlyOrderedField {ℓ ℓ'} : Type (ℓ-suc (ℓ-max ℓ ℓ')) where constructor linearlyorderedfield field Carrier : Type ℓ 0f 1f : Carrier _+_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier _·_ : Carrier → Carrier → Carrier min max : Carrier → Carrier → Carrier _<_ : hPropRel Carrier Carrier ℓ' is-LinearlyOrderedField : [ isLinearlyOrderedField 0f 1f _+_ _·_ -_ _<_ min max ] -- defines `_≤_` and `_#_` infixl 7 _·_ infix 6 -_ infixl 5 _+_ infixl 4 _<_ open IsLinearlyOrderedField is-LinearlyOrderedField public -- NOTE: this smells like "CPO" https://en.wikipedia.org/wiki/Complete_partial_order record CompletePartiallyOrderedFieldWithSqrt {ℓ ℓ' : Level} : Type (ℓ-suc (ℓ-max ℓ ℓ')) where field Carrier : Type ℓ is-set : isSet Carrier 0f : Carrier 1f : Carrier _<_ : hPropRel Carrier Carrier ℓ' min : Carrier → Carrier → Carrier max : Carrier → Carrier → Carrier _+_ : Carrier → Carrier → Carrier _·_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier <-irrefl : [ isIrrefl _<_ ] <-trans : [ isTrans _<_ ] <-cotrans : [ isCotrans _<_ ] -- NOTE: these intermediate definitions are restricted and behave like let-definitions -- e.g. they show up in goal contexts and they do not allow for `where` blocks _-_ : Carrier → Carrier → Carrier a - b = a + (- b) <-asym : [ isAsym _<_ ] <-asym = irrefl+trans⇒asym _<_ <-irrefl <-trans _#_ : hPropRel Carrier Carrier ℓ' x # y = [ <-asym x y ] (x < y) ⊎ᵖ (y < x) field #-tight : [ isTightˢ''' _#_ is-set ] _≤_ : hPropRel Carrier Carrier ℓ' x ≤ y = ¬ᵖ(y < x) _>_ = flip _<_ _≥_ = flip _≤_ ≤-refl : [ isRefl _≤_ ] ≤-refl = <-irrefl ≤-trans : [ isTrans _≤_ ] ≤-trans = <-cotrans⇒≤-trans _<_ <-cotrans -- if x > y then x > y ≥ x, wich contradicts 4. Hence ¬(x > y). Similarly, ¬(y > x), so ¬(x ≠ y) and therefore by axiom R2(3), x = y. -- NOTE: this makes use of #-tight to proof ≤-antisym -- but we are alrady using ≤-antisym to proof #-tight -- so I guess that we have to assume one of them? -- Bridges lists tightness a property of _<_, so he seems to assume #-tight -- Booij assumes `≤-isLattice : IsLattice _≤_ min max` which gives ≤-refl, ≤-antisym and ≤-trans and proofs #-tight from it -- ≤-antisym : (∀ x y → [ ¬ᵖ (x # y) ] → x ≡ y) → [ isAntisymˢ is-set _≤_ ] ≤-antisym : [ isAntisymˢ _≤_ is-set ] ≤-antisym = fst (isTightˢ'''⇔isAntisymˢ _<_ is-set <-asym) #-tight -- NOTE: we have `R3-8 = ∀[ x ] ∀[ y ] (¬(x ≤ y) ⇔ ¬ ¬(y < x))` -- so I guess that we do not have `dne-over-< : ¬ ¬(y < x) ⇔ (y < x)` -- and that would be my plan to prove `≤-cotrans` with `<-asym` -- ≤-cotrans : [ isCotrans _≤_ ] -- ≤-cotrans x y x≤y z = [ (x ≤ z) ⊔ (z ≤ y) ] ∋ {! (≤-antisym x y x≤y) !} abs : Carrier → Carrier abs x = max x (- x) field -- `R3.12` in [Bridges 1999] -- bridges-R2-2 : ∀ x y → [ y < x ] → ∀ z → [ (z < x) ⊔ (y < z) ] sqrt : (x : Carrier) → {{ ! [ 0f ≤ x ] }} → Carrier 0≤sqrt : ∀ x → {{ p : ! [ 0f ≤ x ] }} → [ 0f ≤ sqrt x {{p}} ] 0≤x² : ∀ x → [ 0f ≤ (x · x) ] instance _ = λ {x} → !! 0≤x² x field -- NOTE: all "interface" instance arguments (i.e. those that appear in the goal) need to be passed in as arguments -- sqrt-of-² : ∀ x → {{ p₁ : ! [ 0f ≤ x ] }} → {{ p₂ : ! [ 0f ≤ x · x ] }} → sqrt (x · x) {{p₂}} ≡ x -- sqrt-unique-existence : ∀ x → {{ p : ! [ 0f ≤ x ] }} → Σ[ y ∈ Carrier ] y · y ≡ x -- sqrt-uniqueness : ∀ x y z → {{ p : ! [ 0f ≤ x ] }} → y · y ≡ x → z · z ≡ x → y ≡ z ·-uniqueness : ∀ x y → {{ p₁ : ! [ 0f ≤ x ] }} → {{ p₂ : ! [ 0f ≤ y ] }} → x · x ≡ y · y → x ≡ y sqrt-existence : ∀ x → {{ p : ! [ 0f ≤ x ] }} → sqrt x {{p}} · sqrt x {{p}} ≡ x sqrt-preserves-· : ∀ x y → {{ p₁ : ! [ 0f ≤ x ] }} → {{ p₁ : ! [ 0f ≤ y ] }} → {{ p₁ : ! [ 0f ≤ x · y ] }} → sqrt (x · y) ≡ sqrt x · sqrt y sqrt0≡0 : {{ p : ! [ 0f ≤ 0f ] }} → sqrt 0f {{p}} ≡ 0f sqrt1≡1 : {{ p : ! [ 0f ≤ 1f ] }} → sqrt 1f {{p}} ≡ 1f -- √x √x = x ⇒ √xx = x -- √x √x √x √x = x x -- √(√x √x √x √x) = √(x x) -- ²-of-sqrt' : ∀ x → {{ p : ! [ 0f ≤ x ] }} → sqrt x {{p}} · sqrt x {{p}} ≡ x -- ²-of-sqrt' x {{p}} = let y = sqrt x; instance q = !! 0≤sqrt x in transport ( -- sqrt (y · y) ≡ y ≡⟨ {! !} ⟩ -- sqrt (y · y) · sqrt (y · y) ≡ y · sqrt (y · y) ≡⟨ {! !} ⟩ -- sqrt (y · y) · sqrt (y · y) ≡ y · y ≡⟨ {! λ x → x !} ⟩ -- sqrt x · sqrt x ≡ x ∎) (sqrt-of-² y) -- {! !} ⇒⟨ {! !} ⟩ -- {! !} ◼) {! (sqrt-of-² y ) !} -- sqrt (x · x) ≡ x -- sqrt (x · x) · sqrt (x · x) ≡ x · sqrt (x · x) -- sqrt (x · x) · sqrt (x · x) ≡ x · x -- x = sqrt y -- sqrt y · sqrt y ≡ y sqrt-test : (x y z : Carrier) → [ 0f ≤ x ] → [ 0f ≤ y ] → Carrier sqrt-test x y z 0≤x 0≤y = let instance _ = !! 0≤x instance _ = !! 0≤y in (sqrt x) + (sqrt y) + (sqrt (z · z)) field _⁻¹ : (x : Carrier) → {{p : [ x # 0f ]}} → Carrier _/_ : (x y : Carrier) → {{p : [ y # 0f ]}} → Carrier (x / y) {{p}} = x · (y ⁻¹) {{p}} infix 9 _⁻¹ infixl 7 _·_ infixl 7 _/_ infix 6 -_ infix 5 _-_ infixl 5 _+_ infixl 4 _#_ infixl 4 _≤_ infixl 4 _<_ open import MorePropAlgebra.Bridges1999 -- mkBridges : ∀{ℓ ℓ'} → CompletePartiallyOrderedFieldWithSqrt {ℓ} {ℓ'} → BooijResults {ℓ} {ℓ'} -- mkBridges CPOFS = record { CompletePartiallyOrderedFieldWithSqrt CPOFS } -----------8<--------------------------------------------8<------------------------------------------8<------------------ {- currently, we have that IsAbs works on "rigs" (rings where `-_` is not necessary) but in our applications, we do want to take the square root immediately on modules therefore, `abs` is defined here as always mapping into `CompletePartiallyOrderedFieldWithSqrt` although more general `abs`es would be possible -} module _ -- mathematical structures with `abs` into the real numbers {ℝℓ ℝℓ' : Level} (ℝbundle : CompletePartiallyOrderedFieldWithSqrt {ℝℓ} {ℝℓ'}) where module ℝ = CompletePartiallyOrderedFieldWithSqrt ℝbundle open ℝ using () renaming (Carrier to ℝ; is-set to is-setʳ; _≤_ to _≤ʳ_; 0f to 0ʳ; 1f to 1ʳ; _+_ to _+ʳ_; _·_ to _·ʳ_; -_ to -ʳ_; _-_ to _-ʳ_) -- this makes the complex numbers ℂ module EuclideanTwoProductOfCompletePartiallyOrderedFieldWithSqrt where Carrier : Type ℝℓ Carrier = ℝ × ℝ re im : Carrier → ℝ re = fst im = snd 0f : Carrier 0f = 0ʳ , 0ʳ 1f : Carrier 1f = 1ʳ , 0ʳ _+_ : Carrier → Carrier → Carrier (ar , ai) + (br , bi) = (ar +ʳ br) , (ai +ʳ bi) _·_ : Carrier → Carrier → Carrier (ar , ai) · (br , bi) = (ar ·ʳ br -ʳ ai ·ʳ bi) , (ar ·ʳ bi +ʳ br ·ʳ ai) -_ : Carrier → Carrier - (ar , ai) = (-ʳ ar , -ʳ ai) is-set : isSet Carrier is-set = isSetΣ ℝ.is-set (λ _ → ℝ.is-set) -- this makes the `R` in `RModule` record ApartnessRingWithAbsIntoCompletePartiallyOrderedFieldWithSqrt {ℓ ℓ' : Level} : Type (ℓ-suc (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℝℓ ℝℓ'))) where field Carrier : Type ℓ 0f : Carrier 1f : Carrier _+_ : Carrier → Carrier → Carrier _·_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier _#_ : hPropRel Carrier Carrier ℓ' abs : Carrier → ℝ -- this makes the `G` in `GModule` record ApartnessGroupWithAbsIntoCompletePartiallyOrderedFieldWithSqrt {ℓ ℓ' : Level} : Type (ℓ-suc (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℝℓ ℝℓ'))) where field Carrier : Type ℓ 1f : Carrier _·_ : Carrier → Carrier → Carrier _⁻¹ : Carrier → Carrier _#_ : hPropRel Carrier Carrier ℓ' abs : Carrier → ℝ -- this makes the `K` in `KModule` record CompleteApartnessFieldWithAbsIntoCompletePartiallyOrderedFieldWithSqrt {ℓ ℓ' : Level} : Type (ℓ-suc (ℓ-max (ℓ-max ℓ ℓ') (ℓ-max ℝℓ ℝℓ'))) where field Carrier : Type ℓ 0f : Carrier 1f : Carrier _+_ : Carrier → Carrier → Carrier _·_ : Carrier → Carrier → Carrier -_ : Carrier → Carrier _#_ : hPropRel Carrier Carrier ℓ' _⁻¹ : (x : Carrier) → {{p : [ x # 0f ]}} → Carrier abs : Carrier → ℝ is-set : isSet Carrier is-abs : [ isAbs is-set 0f _+_ _·_ is-setʳ 0ʳ _+ʳ_ _·ʳ_ _≤ʳ_ abs ] -- TODO: complete this
{ "alphanum_fraction": 0.5355151515, "avg_line_length": 40.1785714286, "ext": "agda", "hexsha": "a702489c70b3ae203093550f214fd8c7a25a565c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mchristianl/synthetic-reals", "max_forks_repo_path": "agda/Number/Bundles2.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mchristianl/synthetic-reals", "max_issues_repo_path": "agda/Number/Bundles2.agda", "max_line_length": 151, "max_stars_count": 3, "max_stars_repo_head_hexsha": "10206b5c3eaef99ece5d18bf703c9e8b2371bde4", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mchristianl/synthetic-reals", "max_stars_repo_path": "agda/Number/Bundles2.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-19T12:15:21.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-31T18:15:26.000Z", "num_tokens": 4510, "size": 12375 }
-- {-# OPTIONS -v tc.meta.assign:50 #-} module Issue483c where import Common.Level data _≡_ {A : Set}(a : A) : A → Set where refl : a ≡ a data ⊥ : Set where record ⊤ : Set where refute : .⊥ → ⊥ refute () mk⊤ : ⊥ → ⊤ mk⊤ () X : .⊤ → ⊥ bad : .(x : ⊥) → X (mk⊤ x) ≡ refute x X = _ bad x = refl false : ⊥ false = X _
{ "alphanum_fraction": 0.5076452599, "avg_line_length": 13.08, "ext": "agda", "hexsha": "9dbba5aeb06c29c0d2c157252665848f3deb091f", "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/Issue483c.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/Issue483c.agda", "max_line_length": 41, "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/Issue483c.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": 145, "size": 327 }
------------------------------------------------------------------------ -- Lemmas related to bisimilarity and CCS, implemented using the -- coinductive definition of bisimilarity ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} open import Prelude module Bisimilarity.CCS {ℓ} {Name : Type ℓ} where open import Equality.Propositional open import Prelude.Size import Bisimilarity.Equational-reasoning-instances import Bisimilarity.CCS.General open import Equational-reasoning open import Labelled-transition-system.CCS Name open import Bisimilarity CCS import Labelled-transition-system.Equational-reasoning-instances CCS as Dummy ------------------------------------------------------------------------ -- Congruence lemmas -- Some lemmas used to prove the congruence results below as well as -- similar results in Similarity.CCS. module Cong-lemmas ({R} R′ : Proc ∞ → Proc ∞ → Type ℓ) ⦃ _ : Convertible R R′ ⦄ ⦃ _ : Convertible R′ R′ ⦄ ⦃ _ : Convertible _∼_ R′ ⦄ ⦃ _ : Transitive R′ R′ ⦄ (left-to-right : ∀ {P Q} → R P Q → ∀ {P′ μ} → P [ μ ]⟶ P′ → ∃ λ Q′ → Q [ μ ]⟶ Q′ × R′ P′ Q′) where private infix -2 R′:_ R′:_ : ∀ {P Q} → R′ P Q → R′ P Q R′:_ = id infix -3 lr-result lr-result : ∀ {P′ Q Q′} μ → R′ P′ Q′ → Q [ μ ]⟶ Q′ → ∃ λ Q′ → Q [ μ ]⟶ Q′ × R′ P′ Q′ lr-result _ P′∼′Q′ Q⟶Q′ = _ , Q⟶Q′ , P′∼′Q′ syntax lr-result μ P′∼′Q′ Q⟶Q′ = P′∼′Q′ [ μ ]⟵ Q⟶Q′ ∣-cong : (∀ {P P′ Q Q′} → R′ P P′ → R′ Q Q′ → R′ (P ∣ Q) (P′ ∣ Q′)) → ∀ {P₁ P₂ Q₁ Q₂ S₁ μ} → R P₁ P₂ → R Q₁ Q₂ → P₁ ∣ Q₁ [ μ ]⟶ S₁ → ∃ λ S₂ → P₂ ∣ Q₂ [ μ ]⟶ S₂ × R′ S₁ S₂ ∣-cong _∣-cong′_ P₁∼P₂ Q₁∼Q₂ = λ where (par-left tr) → Σ-map (_∣ _) (Σ-map par-left (_∣-cong′ convert Q₁∼Q₂)) (left-to-right P₁∼P₂ tr) (par-right tr) → Σ-map (_ ∣_) (Σ-map par-right (convert P₁∼P₂ ∣-cong′_)) (left-to-right Q₁∼Q₂ tr) (par-τ tr₁ tr₂) → Σ-zip _∣_ (Σ-zip par-τ _∣-cong′_) (left-to-right P₁∼P₂ tr₁) (left-to-right Q₁∼Q₂ tr₂) ⊕-cong : ∀ {P₁ P₁′ P₂ P₂′ S μ} → R P₁ P₁′ → R P₂ P₂′ → P₁ ⊕ P₂ [ μ ]⟶ S → ∃ λ S′ → P₁′ ⊕ P₂′ [ μ ]⟶ S′ × R′ S S′ ⊕-cong {P₁} {P₁′} {P₂} {P₂′} {S} {μ} P₁∼P₁′ P₂∼P₂′ = λ where (sum-left P₁⟶S) → case left-to-right P₁∼P₁′ P₁⟶S of λ where (S′ , P₁′⟶S′ , S∼′S′) → S ∼⟨ S∼′S′ ⟩■ S′ [ μ ]⟵ ←⟨ ⟶: sum-left P₁′⟶S′ ⟩■ P₁′ ⊕ P₂′ (sum-right P₂⟶S) → case left-to-right P₂∼P₂′ P₂⟶S of λ where (S′ , P₂′⟶S′ , S∼′S′) → S ∼⟨ S∼′S′ ⟩■ S′ [ μ ]⟵ ←⟨ ⟶: sum-right P₂′⟶S′ ⟩■ P₁′ ⊕ P₂′ ·-cong : ∀ {P₁ P₂ Q₁ μ μ′} → R′ (force P₁) (force P₂) → μ · P₁ [ μ′ ]⟶ Q₁ → ∃ λ Q₂ → μ · P₂ [ μ′ ]⟶ Q₂ × R′ Q₁ Q₂ ·-cong {P₁} {P₂} {μ = μ} P₁∼P₂ action = force P₁ ∼⟨ P₁∼P₂ ⟩■ force P₂ [ μ ]⟵ ←⟨ ⟶: action ⟩■ μ · P₂ ⟨ν⟩-cong : (∀ {a P P′} → R′ P P′ → R′ (⟨ν a ⟩ P) (⟨ν a ⟩ P′)) → ∀ {a μ P P′ Q} → R P P′ → ⟨ν a ⟩ P [ μ ]⟶ Q → ∃ λ Q′ → ⟨ν a ⟩ P′ [ μ ]⟶ Q′ × R′ Q Q′ ⟨ν⟩-cong ⟨ν⟩-cong′ {a} {μ} {P′ = P′} P∼P′ (restriction {P′ = Q} a∉μ P⟶Q) = case left-to-right P∼P′ P⟶Q of λ where (Q′ , P′⟶Q′ , Q∼′Q′) → ⟨ν a ⟩ Q ∼⟨ ⟨ν⟩-cong′ Q∼′Q′ ⟩■ ⟨ν a ⟩ Q′ [ μ ]⟵ ←⟨ ⟶: restriction a∉μ P′⟶Q′ ⟩■ ⟨ν a ⟩ P′ !-cong : (∀ {μ P P₀} → ! P [ μ ]⟶ P₀ → (∃ λ P′ → P [ μ ]⟶ P′ × P₀ ∼ ! P ∣ P′) ⊎ (μ ≡ τ × ∃ λ P′ → ∃ λ P″ → ∃ λ a → P [ name a ]⟶ P′ × P [ name (co a) ]⟶ P″ × P₀ ∼ (! P ∣ P′) ∣ P″)) → (∀ {P P′ Q Q′} → R′ P P′ → R′ Q Q′ → R′ (P ∣ Q) (P′ ∣ Q′)) → (∀ {P P′} → R′ P P′ → R′ (! P) (! P′)) → ∀ {P P′ Q μ} → R P P′ → ! P [ μ ]⟶ Q → ∃ λ Q′ → ! P′ [ μ ]⟶ Q′ × R′ Q Q′ !-cong 6-1-3-2 _∣-cong′_ !-cong′_ {P} {P′} {Q} {μ} P∼P′ !P⟶Q = case 6-1-3-2 !P⟶Q of λ where (inj₁ (P″ , P⟶P″ , Q∼!P∣P″)) → let Q′ , P′⟶Q′ , P″∼′Q′ = left-to-right P∼P′ P⟶P″ in Q ∼⟨ R′: convert Q∼!P∣P″ ⟩ ! P ∣ P″ ∼⟨ (!-cong′ convert P∼P′) ∣-cong′ P″∼′Q′ ⟩■ ! P′ ∣ Q′ [ μ ]⟵ ←⟨ ⟶: replication (par-right P′⟶Q′) ⟩■ ! P′ (inj₂ (refl , P″ , P‴ , a , P⟶P″ , P⟶P‴ , Q∼!P∣P″∣P‴)) → let Q′ , P′⟶Q′ , P″∼′Q′ = left-to-right P∼P′ P⟶P″ Q″ , P′⟶Q″ , P‴∼′Q″ = left-to-right P∼P′ P⟶P‴ in Q ∼⟨ R′: convert Q∼!P∣P″∣P‴ ⟩ (! P ∣ P″) ∣ P‴ ∼⟨ ((!-cong′ convert P∼P′) ∣-cong′ P″∼′Q′) ∣-cong′ P‴∼′Q″ ⟩■ (! P′ ∣ Q′) ∣ Q″ [ τ ]⟵ ←⟨ ⟶: replication (par-τ (replication (par-right P′⟶Q′)) P′⟶Q″) ⟩■ ! P′ private module CL {i} = Cong-lemmas [ i ]_∼′_ left-to-right ------------------------------------------------------------------------ -- Various lemmas related to _∣_ mutual -- _∣_ is commutative. ∣-comm : ∀ {P Q i} → [ i ] P ∣ Q ∼ Q ∣ P ∣-comm {i = i} = ⟨ lr , Σ-map id (Σ-map id symmetric) ∘ lr ⟩ where lr : ∀ {P P′ Q μ} → P ∣ Q [ μ ]⟶ P′ → ∃ λ Q′ → Q ∣ P [ μ ]⟶ Q′ × [ i ] P′ ∼′ Q′ lr (par-left tr) = _ , par-right tr , ∣-comm′ lr (par-right tr) = _ , par-left tr , ∣-comm′ lr (par-τ tr₁ tr₂) = _ , par-τ tr₂ (subst (λ a → _ [ name a ]⟶ _) (sym $ co-involutive _) tr₁) , ∣-comm′ ∣-comm′ : ∀ {P Q i} → [ i ] P ∣ Q ∼′ Q ∣ P force ∣-comm′ = ∣-comm mutual -- _∣_ is associative. ∣-assoc : ∀ {P Q R i} → [ i ] P ∣ (Q ∣ R) ∼ (P ∣ Q) ∣ R ∣-assoc {i = i} = ⟨ lr , rl ⟩ where lr : ∀ {P Q R P′ μ} → P ∣ (Q ∣ R) [ μ ]⟶ P′ → ∃ λ Q′ → (P ∣ Q) ∣ R [ μ ]⟶ Q′ × [ i ] P′ ∼′ Q′ lr (par-left tr) = _ , par-left (par-left tr) , ∣-assoc′ lr (par-right (par-left tr)) = _ , par-left (par-right tr) , ∣-assoc′ lr (par-right (par-right tr)) = _ , par-right tr , ∣-assoc′ lr (par-right (par-τ tr₁ tr₂)) = _ , par-τ (par-right tr₁) tr₂ , ∣-assoc′ lr (par-τ tr₁ (par-left tr₂)) = _ , par-left (par-τ tr₁ tr₂) , ∣-assoc′ lr (par-τ tr₁ (par-right tr₂)) = _ , par-τ (par-left tr₁) tr₂ , ∣-assoc′ rl : ∀ {P Q R Q′ μ} → (P ∣ Q) ∣ R [ μ ]⟶ Q′ → ∃ λ P′ → P ∣ (Q ∣ R) [ μ ]⟶ P′ × [ i ] P′ ∼′ Q′ rl (par-left (par-left tr)) = _ , par-left tr , ∣-assoc′ rl (par-left (par-right tr)) = _ , par-right (par-left tr) , ∣-assoc′ rl (par-left (par-τ tr₁ tr₂)) = _ , par-τ tr₁ (par-left tr₂) , ∣-assoc′ rl (par-right tr) = _ , par-right (par-right tr) , ∣-assoc′ rl (par-τ (par-left tr₁) tr₂) = _ , par-τ tr₁ (par-right tr₂) , ∣-assoc′ rl (par-τ (par-right tr₁) tr₂) = _ , par-right (par-τ tr₁ tr₂) , ∣-assoc′ ∣-assoc′ : ∀ {P Q R i} → [ i ] P ∣ (Q ∣ R) ∼′ (P ∣ Q) ∣ R force ∣-assoc′ = ∣-assoc -- ∅ is a left identity of _∣_. ∣-left-identity : ∀ {i P} → [ i ] ∅ ∣ P ∼ P ∣-left-identity = ⟨ (λ { (par-right tr) → (_ , tr , λ { .force → ∣-left-identity }) ; (par-left ()) ; (par-τ () _) }) , (λ tr → (_ , par-right tr , λ { .force → ∣-left-identity })) ⟩ ∣-left-identity′ : ∀ {P i} → [ i ] ∅ ∣ P ∼′ P force ∣-left-identity′ = ∣-left-identity -- ∅ is a right identity of _∣_. ∣-right-identity : ∀ {P} → P ∣ ∅ ∼ P ∣-right-identity {P} = P ∣ ∅ ∼⟨ ∣-comm ⟩ ∅ ∣ P ∼⟨ ∣-left-identity ⟩■ P mutual -- _∣_ preserves bisimilarity. infix 6 _∣-cong_ _∣-cong′_ _∣-cong_ : ∀ {i P P′ Q Q′} → [ i ] P ∼ Q → [ i ] P′ ∼ Q′ → [ i ] P ∣ P′ ∼ Q ∣ Q′ P∼Q ∣-cong P′∼Q′ = ⟨ lr P∼Q P′∼Q′ , Σ-map id (Σ-map id symmetric) ∘ lr (symmetric P∼Q) (symmetric P′∼Q′) ⟩ where lr = CL.∣-cong _∣-cong′_ _∣-cong′_ : ∀ {i P P′ Q Q′} → [ i ] P ∼′ Q → [ i ] P′ ∼′ Q′ → [ i ] P ∣ P′ ∼′ Q ∣ Q′ force (P∼P′ ∣-cong′ Q∼Q′) = force P∼P′ ∣-cong force Q∼Q′ -- An alternative proof that is closer to the one in the paper. infix 6 _∣-congP_ _∣-congP_ : ∀ {i P P′ Q Q′} → [ i ] P ∼ Q → [ i ] P′ ∼ Q′ → [ i ] P ∣ P′ ∼ Q ∣ Q′ _∣-congP_ {i} = λ p q → ⟨ lr p q , Σ-map id (Σ-map id symmetric) ∘ lr (symmetric p) (symmetric q) ⟩ where lr : ∀ {P P′ P″ Q Q′ μ} → [ i ] P ∼ Q → [ i ] P′ ∼ Q′ → P ∣ P′ [ μ ]⟶ P″ → ∃ λ Q″ → Q ∣ Q′ [ μ ]⟶ Q″ × [ i ] P″ ∼′ Q″ lr p q (par-left tr) = let (_ , tr′ , p′) = left-to-right p tr in (_ , par-left tr′ , λ { .force → force p′ ∣-congP q }) lr p q (par-right tr) = let (_ , tr′ , q′) = left-to-right q tr in (_ , par-right tr′ , λ { .force → p ∣-congP force q′ }) lr p q (par-τ tr₁ tr₂) = let (_ , tr₁′ , p′) = left-to-right p tr₁ (_ , tr₂′ , q′) = left-to-right q tr₂ in (_ , par-τ tr₁′ tr₂′ , λ { .force → force p′ ∣-congP force q′ }) ------------------------------------------------------------------------ -- Exercise 6.1.2 from "Enhancements of the bisimulation proof method" -- by Pous and Sangiorgi private -- A compact proof. 6-1-2-compact : ∀ {P i} → [ i ] ! P ∣ P ∼ ! P 6-1-2-compact = ⟨ (λ tr → _ , replication tr , reflexive) , (λ { (replication tr) → _ , tr , reflexive }) ⟩ -- A less compact proof. 6-1-2 : ∀ {P i} → [ i ] ! P ∣ P ∼ ! P 6-1-2 {P} = ⟨ (λ {P′} {μ} tr → P′ ∼⟨ ∼′: reflexive ⟩■ P′ [ μ ]⟵⟨ replication tr ⟩ ! P) , (λ { {q′ = P′} {μ = μ} (replication tr) → ! P ∣ P [ μ ]⟶⟨ tr ⟩ʳˡ P′ ∼⟨ ∼′: reflexive ⟩■ P′ }) ⟩ ------------------------------------------------------------------------ -- Exercise 6.1.3 (2) from "Enhancements of the bisimulation proof -- method" by Pous and Sangiorgi, plus some rearrangement lemmas private module 6-1-3-2 = Bisimilarity.CCS.General.6-1-3-2 (record { _∼_ = _∼_ ; step-∼ = step-∼ ; finally-∼ = Equational-reasoning.finally₂ ; reflexive = reflexive ; symmetric = symmetric ; ∣-comm = ∣-comm ; ∣-assoc = ∣-assoc ; _∣-cong_ = _∣-cong_ ; 6-1-2 = 6-1-2 }) 6-1-3-2 : ∀ {P μ R} → ! P [ μ ]⟶ R → (∃ λ P′ → P [ μ ]⟶ P′ × R ∼ ! P ∣ P′) ⊎ (μ ≡ τ × ∃ λ P′ → ∃ λ P″ → ∃ λ a → P [ name a ]⟶ P′ × P [ name (co a) ]⟶ P″ × R ∼ (! P ∣ P′) ∣ P″) 6-1-3-2 = 6-1-3-2.6-1-3-2 swap-rightmost : ∀ {P Q R} → (P ∣ Q) ∣ R ∼ (P ∣ R) ∣ Q swap-rightmost = 6-1-3-2.swap-rightmost swap-in-the-middle : ∀ {P Q R S} → (P ∣ Q) ∣ (R ∣ S) ∼ (P ∣ R) ∣ (Q ∣ S) swap-in-the-middle {P} {Q} {R} {S} = (P ∣ Q) ∣ (R ∣ S) ∼⟨ swap-rightmost ⟩ (P ∣ (R ∣ S)) ∣ Q ∼⟨ ∣-assoc ∣-cong reflexive ⟩ ((P ∣ R) ∣ S) ∣ Q ∼⟨ symmetric ∣-assoc ⟩ (P ∣ R) ∣ (S ∣ Q) ∼⟨ reflexive ∣-cong ∣-comm ⟩■ (P ∣ R) ∣ (Q ∣ S) ------------------------------------------------------------------------ -- More preservation lemmas -- _⊕_ preserves bisimilarity. infix 8 _⊕-cong_ _⊕-cong′_ _⊕-cong_ : ∀ {i P P′ Q Q′} → [ i ] P ∼ P′ → [ i ] Q ∼ Q′ → [ i ] P ⊕ Q ∼ P′ ⊕ Q′ _⊕-cong_ {i} P∼P′ Q∼Q′ = ⟨ CL.⊕-cong P∼P′ Q∼Q′ , Σ-map id (Σ-map id symmetric) ∘ CL.⊕-cong {i = i} (symmetric P∼P′) (symmetric Q∼Q′) ⟩ _⊕-cong′_ : ∀ {i P P′ Q Q′} → [ i ] P ∼′ P′ → [ i ] Q ∼′ Q′ → [ i ] P ⊕ Q ∼′ P′ ⊕ Q′ force (P∼P′ ⊕-cong′ Q∼Q′) = force P∼P′ ⊕-cong force Q∼Q′ -- _·_ preserves bisimilarity. infix 12 _·-cong_ _·-cong′_ _·-cong_ : ∀ {i μ μ′ P P′} → μ ≡ μ′ → [ i ] force P ∼′ force P′ → [ i ] μ · P ∼ μ′ · P′ refl ·-cong P∼P′ = ⟨ CL.·-cong P∼P′ , Σ-map id (Σ-map id symmetric) ∘ CL.·-cong (symmetric P∼P′) ⟩ _·-cong′_ : ∀ {i μ μ′ P P′} → μ ≡ μ′ → [ i ] force P ∼′ force P′ → [ i ] μ · P ∼′ μ′ · P′ force (μ≡μ′ ·-cong′ P∼P′) = μ≡μ′ ·-cong P∼P′ -- An alternative proof that is closer to the one in the paper. ·-congP : ∀ {i μ P Q} → [ i ] force P ∼′ force Q → [ i ] μ · P ∼ μ · Q ·-congP p = ⟨ (λ { action → _ , action , p }) , (λ { action → _ , action , p }) ⟩ -- _∙_ preserves bisimilarity. infix 12 _∙-cong_ _∙-cong′_ _∙-cong_ : ∀ {i μ μ′ P P′} → μ ≡ μ′ → [ i ] P ∼ P′ → [ i ] μ ∙ P ∼ μ′ ∙ P′ refl ∙-cong P∼P′ = refl ·-cong convert {a = ℓ} P∼P′ _∙-cong′_ : ∀ {i μ μ′ P P′} → μ ≡ μ′ → [ i ] P ∼′ P′ → [ i ] μ ∙ P ∼′ μ′ ∙ P′ force (μ≡μ′ ∙-cong′ P∼P′) = μ≡μ′ ∙-cong force P∼P′ -- _∙ turns equality into bisimilarity. infix 12 _∙-cong _∙-cong′ _∙-cong : ∀ {μ μ′} → μ ≡ μ′ → μ ∙ ∼ μ′ ∙ refl ∙-cong = reflexive _∙-cong′ : ∀ {μ μ′} → μ ≡ μ′ → μ ∙ ∼′ μ′ ∙ refl ∙-cong′ = reflexive mutual -- !_ preserves bisimilarity. infix 10 !-cong_ !-cong′_ !-cong_ : ∀ {i P P′} → [ i ] P ∼ P′ → [ i ] ! P ∼ ! P′ !-cong P∼P′ = ⟨ lr P∼P′ , Σ-map id (Σ-map id symmetric) ∘ lr (symmetric P∼P′) ⟩ where lr = CL.!-cong 6-1-3-2 _∣-cong′_ !-cong′_ !-cong′_ : ∀ {i P P′} → [ i ] P ∼′ P′ → [ i ] ! P ∼′ ! P′ force (!-cong′ P∼P′) = !-cong force P∼P′ -- An alternative proof that is closer to the one in the paper. !-congP : ∀ {i P Q} → [ i ] P ∼ Q → [ i ] ! P ∼ ! Q !-congP {i} = λ p → ⟨ lr p , Σ-map id (Σ-map id symmetric) ∘ lr (symmetric p) ⟩ where lr : ∀ {P Q R μ} → [ i ] P ∼ Q → ! P [ μ ]⟶ R → ∃ λ S → ! Q [ μ ]⟶ S × [ i ] R ∼′ S lr {P} {Q} {R} P∼Q !P⟶R with 6-1-3-2 !P⟶R ... | inj₁ (P′ , P⟶P′ , R∼!P∣P′) = let (Q′ , Q⟶Q′ , P′∼′Q′) = left-to-right P∼Q P⟶P′ in ( ! Q ∣ Q′ , replication (par-right Q⟶Q′) , (R ∼⟨ R∼!P∣P′ ⟩ ! P ∣ P′ ∼⟨ (λ { .force → !-congP P∼Q }) ∣-cong′ P′∼′Q′ ⟩ ! Q ∣ Q′ ■ ) ) ... | inj₂ (refl , P′ , P″ , a , P⟶P′ , P⟶P″ , R∼!P∣P′∣P″) = let (Q′ , Q⟶Q′ , P′∼′Q′) = left-to-right P∼Q P⟶P′ (Q″ , Q⟶Q″ , P″∼′Q″) = left-to-right P∼Q P⟶P″ in ( (! Q ∣ Q′) ∣ Q″ , replication (par-τ (replication (par-right Q⟶Q′)) Q⟶Q″) , (R ∼⟨ R∼!P∣P′∣P″ ⟩ (! P ∣ P′) ∣ P″ ∼⟨ ((λ { .force → !-congP P∼Q }) ∣-cong′ P′∼′Q′) ∣-cong′ P″∼′Q″ ⟩ (! Q ∣ Q′) ∣ Q″ ■ ) ) mutual -- ⟨ν_⟩ preserves bisimilarity. ⟨ν_⟩-cong : ∀ {i a a′ P P′} → a ≡ a′ → [ i ] P ∼ P′ → [ i ] ⟨ν a ⟩ P ∼ ⟨ν a′ ⟩ P′ ⟨ν refl ⟩-cong = λ P∼P′ → ⟨ lr P∼P′ , Σ-map id (Σ-map id symmetric) ∘ lr (symmetric P∼P′) ⟩ where lr = CL.⟨ν⟩-cong ⟨ν refl ⟩-cong′ ⟨ν_⟩-cong′ : ∀ {i a a′ P P′} → a ≡ a′ → [ i ] P ∼′ P′ → [ i ] ⟨ν a ⟩ P ∼′ ⟨ν a′ ⟩ P′ force (⟨ν a≡a′ ⟩-cong′ P∼P′) = ⟨ν a≡a′ ⟩-cong (force P∼P′) -- _[_] preserves bisimilarity. (This result is related to Exercise -- 6.2.10 in "Enhancements of the bisimulation proof method" -- by Pous and Sangiorgi.) infix 5 _[_]-cong _[_]-cong′ _[_]-cong : ∀ {i n Ps Qs} (C : Context ∞ n) → (∀ x → [ i ] Ps x ∼ Qs x) → [ i ] C [ Ps ] ∼ C [ Qs ] hole x [ Ps∼Qs ]-cong = Ps∼Qs x ∅ [ Ps∼Qs ]-cong = reflexive C₁ ∣ C₂ [ Ps∼Qs ]-cong = (C₁ [ Ps∼Qs ]-cong) ∣-cong (C₂ [ Ps∼Qs ]-cong) C₁ ⊕ C₂ [ Ps∼Qs ]-cong = (C₁ [ Ps∼Qs ]-cong) ⊕-cong (C₂ [ Ps∼Qs ]-cong) μ · C [ Ps∼Qs ]-cong = refl ·-cong λ { .force → force C [ Ps∼Qs ]-cong } ⟨ν a ⟩ C [ Ps∼Qs ]-cong = ⟨ν refl ⟩-cong (C [ Ps∼Qs ]-cong) ! C [ Ps∼Qs ]-cong = !-cong (C [ Ps∼Qs ]-cong) _[_]-cong′ : ∀ {i n Ps Qs} (C : Context ∞ n) → (∀ x → [ i ] Ps x ∼′ Qs x) → [ i ] C [ Ps ] ∼′ C [ Qs ] force (C [ Ps∼Qs ]-cong′) = C [ (λ x → force (Ps∼Qs x)) ]-cong -- The proof of _[_]-cong uses 6-1-3-2 (in !-cong_). The following -- direct proof does not use 6-1-3-2 (but it does use -- extensionality). module _ (ext : Proc-extensionality) where mutual infix 5 _[_]-cong₂ _[_]-cong₂′ _[_]-cong₂ : ∀ {i n Ps Qs} (C : Context ∞ n) → (∀ x → [ i ] Ps x ∼ Qs x) → [ i ] C [ Ps ] ∼ C [ Qs ] _[_]-cong₂ {i} C Ps∼Qs = ⟨ lr C Ps∼Qs , Σ-map id (Σ-map id symmetric) ∘ lr C (symmetric ∘ Ps∼Qs) ⟩ where infix 5 _[_][_]-cong₁ _[_][_]-cong₂ _[_][_]-cong₁ : ∀ {n P Q Ps Qs} → (C : Context ∞ (suc n)) → [ i ] P ∼′ Q → (∀ x → [ i ] Ps x ∼ Qs x) → [ i ] C [ [ const P , Ps ] ] ∼′ C [ [ const Q , Qs ] ] force (C [ P∼′Q ][ Ps∼Qs ]-cong₁) = C [ [ const (force P∼′Q) , Ps∼Qs ] ]-cong₂ _[_][_]-cong₂ : ∀ {P Q R S} → (C : Context ∞ 2) → [ i ] P ∼′ Q → [ i ] R ∼′ S → [ i ] C [ [ const P , [ const R , (λ ()) ] ] ] ∼′ C [ [ const Q , [ const S , (λ ()) ] ] ] force (C [ P∼′Q ][ R∼′S ]-cong₂) = C [ [ const (force P∼′Q) , [ const (force R∼′S) , (λ ()) ] ] ]-cong₂ lr : ∀ {n Ps Qs P′ μ} (C : Context ∞ n) → (∀ x → [ i ] Ps x ∼ Qs x) → C [ Ps ] [ μ ]⟶ P′ → ∃ λ Q′ → C [ Qs ] [ μ ]⟶ Q′ × [ i ] P′ ∼′ Q′ lr (hole x) Ps∼Qs tr = left-to-right (Ps∼Qs x) tr lr ∅ Ps∼Qs () lr (C₁ ∣ C₂) Ps∼Qs (par-left tr) = Σ-map (_∣ _) (Σ-map par-left (λ b → subst (λ P → [ i ] _ ∼′ _ ∣ P) (ext $ weaken-[] C₂) $ subst (λ P → [ i ] _ ∣ P ∼′ _) (ext $ weaken-[] C₂) $ hole fzero ∣ weaken C₂ [ b ][ Ps∼Qs ]-cong₁)) (lr C₁ Ps∼Qs tr) lr (C₁ ∣ C₂) Ps∼Qs (par-right tr) = Σ-map (_ ∣_) (Σ-map par-right (λ b → subst (λ P → [ i ] _ ∼′ P ∣ _) (ext $ weaken-[] C₁) $ subst (λ P → [ i ] P ∣ _ ∼′ _) (ext $ weaken-[] C₁) $ weaken C₁ ∣ hole fzero [ b ][ Ps∼Qs ]-cong₁)) (lr C₂ Ps∼Qs tr) lr (C₁ ∣ C₂) Ps∼Qs (par-τ tr₁ tr₂) = Σ-zip _∣_ (Σ-zip par-τ (λ b₁ b₂ → hole fzero ∣ hole (fsuc fzero) [ b₁ ][ b₂ ]-cong₂)) (lr C₁ Ps∼Qs tr₁) (lr C₂ Ps∼Qs tr₂) lr (C₁ ⊕ C₂) Ps∼Qs (sum-left tr) = Σ-map id (Σ-map sum-left id) (lr C₁ Ps∼Qs tr) lr (C₁ ⊕ C₂) Ps∼Qs (sum-right tr) = Σ-map id (Σ-map sum-right id) (lr C₂ Ps∼Qs tr) lr (μ · C) Ps∼Qs action = _ , action , λ { .force → force C [ Ps∼Qs ]-cong₂ } lr (⟨ν a ⟩ C) Ps∼Qs (restriction a∉ tr) = Σ-map ⟨ν a ⟩ (Σ-map (restriction a∉) (λ b → ⟨ν a ⟩ (hole fzero) [ b ][ Ps∼Qs ]-cong₁)) (lr C Ps∼Qs tr) lr (! C) Ps∼Qs (replication tr) = Σ-map id (Σ-map replication id) (lr (! C ∣ C) Ps∼Qs tr) _[_]-cong₂′ : ∀ {i n Ps Qs} (C : Context ∞ n) → (∀ x → [ i ] Ps x ∼′ Qs x) → [ i ] C [ Ps ] ∼′ C [ Qs ] force (C [ Ps∼′Qs ]-cong₂′) = C [ (λ x → force (Ps∼′Qs x)) ]-cong₂ -- A variant of _[_]-cong for weakly guarded contexts. -- -- Note that the input uses the primed variant of bisimilarity. -- -- I got the idea for this lemma from Lemma 23 in Schäfer and Smolka's -- "Tower Induction and Up-to Techniques for CCS with Fixed Points". infix 5 _[_]-cong-w _[_]-cong-w : ∀ {i n Ps Qs} {C : Context ∞ n} → Weakly-guarded C → (∀ x → [ i ] Ps x ∼′ Qs x) → [ i ] C [ Ps ] ∼ C [ Qs ] ∅ [ Ps∼Qs ]-cong-w = reflexive W₁ ∣ W₂ [ Ps∼Qs ]-cong-w = (W₁ [ Ps∼Qs ]-cong-w) ∣-cong (W₂ [ Ps∼Qs ]-cong-w) action {C = C} [ Ps∼Qs ]-cong-w = refl ·-cong (force C [ Ps∼Qs ]-cong′) ⟨ν⟩ W [ Ps∼Qs ]-cong-w = ⟨ν refl ⟩-cong (W [ Ps∼Qs ]-cong-w) ! W [ Ps∼Qs ]-cong-w = !-cong (W [ Ps∼Qs ]-cong-w) W₁ ⊕ W₂ [ Ps∼Qs ]-cong-w = (W₁ [ Ps∼Qs ]-cong-w) ⊕-cong (W₂ [ Ps∼Qs ]-cong-w) -- Very strong bisimilarity is contained in bisimilarity. mutual ≡→∼ : ∀ {i P Q} → Equal i P Q → [ i ] P ∼ Q ≡→∼ ∅ = reflexive ≡→∼ (eq₁ ∣ eq₂) = ≡→∼ eq₁ ∣-cong ≡→∼ eq₂ ≡→∼ (eq₁ ⊕ eq₂) = ≡→∼ eq₁ ⊕-cong ≡→∼ eq₂ ≡→∼ (refl · eq) = refl ·-cong ≡→∼′ eq ≡→∼ (⟨ν refl ⟩ eq) = ⟨ν refl ⟩-cong (≡→∼ eq) ≡→∼ (! eq) = !-cong ≡→∼ eq ≡→∼′ : ∀ {i P Q} → Equal′ i P Q → [ i ] P ∼′ Q force (≡→∼′ eq) = ≡→∼ (force eq) ------------------------------------------------------------------------ -- Unique solutions -- If the set of equations corresponding (in a certain sense) to a -- family of weakly guarded contexts has two families of solutions, -- then those solutions are pairwise bisimilar. -- -- This result is very similar to a proposition in Milner's -- "Communication and Concurrency". mutual unique-solutions : ∀ {i n} {Ps Qs : Fin n → Proc ∞} {C : Fin n → Context ∞ n} → (∀ x → Weakly-guarded (C x)) → (∀ x → [ i ] Ps x ∼ C x [ Ps ]) → (∀ x → [ i ] Qs x ∼ C x [ Qs ]) → ∀ x → [ i ] Ps x ∼ Qs x unique-solutions {i} {Ps = Ps} {Qs} {C} w ∼C[Ps] ∼C[Qs] x = Ps x ∼⟨ ∼C[Ps] x ⟩ C x [ Ps ] ∼⟨ ∼: ⟨ lr ∼C[Ps] ∼C[Qs] , Σ-map id (Σ-map id symmetric) ∘ lr ∼C[Qs] ∼C[Ps] ⟩ ⟩ C x [ Qs ] ∼⟨ symmetric (∼C[Qs] x) ⟩■ Qs x where lr : ∀ {Ps Qs μ P} → (∀ x → [ i ] Ps x ∼ C x [ Ps ]) → (∀ x → [ i ] Qs x ∼ C x [ Qs ]) → C x [ Ps ] [ μ ]⟶ P → ∃ λ Q → C x [ Qs ] [ μ ]⟶ Q × [ i ] P ∼′ Q lr {Ps} {Qs} {μ} ∼C[Ps] ∼C[Qs] ⟶P = case 6-2-15 (C x) (w x) ⟶P of λ where (C′ , refl , trs) → C′ [ Ps ] ∼⟨ C′ [ unique-solutions′ w ∼C[Ps] ∼C[Qs] ]-cong′ ⟩■ C′ [ Qs ] [ μ ]⟵⟨ trs Qs ⟩ C x [ Qs ] unique-solutions′ : ∀ {i n} {Ps Qs : Fin n → Proc ∞} {C : Fin n → Context ∞ n} → (∀ x → Weakly-guarded (C x)) → (∀ x → [ i ] Ps x ∼ C x [ Ps ]) → (∀ x → [ i ] Qs x ∼ C x [ Qs ]) → ∀ x → [ i ] Ps x ∼′ Qs x force (unique-solutions′ w ∼C[Ps] ∼C[Qs] x) = unique-solutions w ∼C[Ps] ∼C[Qs] x -- For every family of weakly guarded contexts there is a family of -- processes that satisfies the corresponding equations. solutions-exist : ∀ {n} {C : Fin n → Context ∞ n} → (∀ x → Weakly-guarded (C x)) → ∃ λ Ps → ∀ x → Ps x ∼ C x [ Ps ] solutions-exist {n} {C} w = Ps , Ps∼ where mutual Ps : ∀ {i} → Fin n → Proc i Ps x = P₁ (w x) P₁ : ∀ {i} {C : Context ∞ n} → Weakly-guarded C → Proc i P₁ ∅ = ∅ P₁ (w₁ ∣ w₂) = P₁ w₁ ∣ P₁ w₂ P₁ (w₁ ⊕ w₂) = P₁ w₁ ⊕ P₁ w₂ P₁ (action {μ = μ} {C = C}) = μ · λ { .force → P₂ (force C) } P₁ (⟨ν⟩ {a = a} w) = ⟨ν a ⟩ (P₁ w) P₁ (! w) = ! P₁ w P₂ : ∀ {i} → Context ∞ n → Proc i P₂ (hole x) = Ps x P₂ ∅ = ∅ P₂ (C₁ ∣ C₂) = P₂ C₁ ∣ P₂ C₂ P₂ (C₁ ⊕ C₂) = P₂ C₁ ⊕ P₂ C₂ P₂ (μ · C) = μ · λ { .force → P₂ (force C) } P₂ (⟨ν a ⟩ C) = ⟨ν a ⟩ (P₂ C) P₂ (! C) = ! P₂ C P₂∼ : ∀ {i} (C : Context ∞ n) → [ i ] P₂ C ∼ C [ Ps ] P₂∼ (hole x) = reflexive P₂∼ ∅ = reflexive P₂∼ (C₁ ∣ C₂) = P₂∼ C₁ ∣-cong P₂∼ C₂ P₂∼ (C₁ ⊕ C₂) = P₂∼ C₁ ⊕-cong P₂∼ C₂ P₂∼ (μ · C) = refl ·-cong λ { .force → P₂∼ (force C) } P₂∼ (⟨ν a ⟩ C) = ⟨ν refl ⟩-cong (P₂∼ C) P₂∼ (! C) = !-cong P₂∼ C P₁∼ : {C : Context ∞ n} (w : Weakly-guarded C) → P₁ w ∼ C [ Ps ] P₁∼ ∅ = reflexive P₁∼ (w₁ ∣ w₂) = P₁∼ w₁ ∣-cong P₁∼ w₂ P₁∼ (w₁ ⊕ w₂) = P₁∼ w₁ ⊕-cong P₁∼ w₂ P₁∼ (action {C = C}) = refl ·-cong λ { .force → P₂∼ (force C) } P₁∼ (⟨ν⟩ {a = a} w) = ⟨ν refl ⟩-cong (P₁∼ w) P₁∼ (! w) = !-cong P₁∼ w Ps∼ : ∀ x → Ps x ∼ C x [ Ps ] Ps∼ x = P₁∼ (w x) ------------------------------------------------------------------------ -- Some lemmas related to _⊕_ -- _⊕_ is idempotent. ⊕-idempotent : ∀ {P} → P ⊕ P ∼ P ⊕-idempotent {P} = ⟨ lr , (λ {R} P⟶R → P ⊕ P ⟶⟨ sum-left P⟶R ⟩ʳˡ R ∼⟨ ∼′: reflexive ⟩■ R) ⟩ where lr : ∀ {Q μ} → P ⊕ P [ μ ]⟶ Q → ∃ λ R → P [ μ ]⟶ R × Q ∼′ R lr {Q} (sum-left P⟶Q) = Q ∼⟨ ∼′: reflexive ⟩■ Q ⟵⟨ P⟶Q ⟩ P lr {Q} (sum-right P⟶Q) = Q ∼⟨ ∼′: reflexive ⟩■ Q ⟵⟨ P⟶Q ⟩ P ⊕-idempotent′ : ∀ {P} → P ⊕ P ∼′ P force ⊕-idempotent′ = ⊕-idempotent -- _⊕_ is commutative. ⊕-comm : ∀ {P Q} → P ⊕ Q ∼ Q ⊕ P ⊕-comm = ⟨ lr , Σ-map id (Σ-map id symmetric) ∘ lr ⟩ where lr : ∀ {P Q R μ} → P ⊕ Q [ μ ]⟶ R → ∃ λ R′ → Q ⊕ P [ μ ]⟶ R′ × R ∼′ R′ lr {P} {Q} {R} = λ where (sum-left P⟶R) → R ■ ⟵⟨ sum-right P⟶R ⟩ Q ⊕ P (sum-right Q⟶R) → R ■ ⟵⟨ sum-left Q⟶R ⟩ Q ⊕ P
{ "alphanum_fraction": 0.4063456606, "avg_line_length": 32.0185430464, "ext": "agda", "hexsha": "b91eed7d8394ccb9668baa06bfcc590a7f733642", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/up-to", "max_forks_repo_path": "src/Bisimilarity/CCS.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/up-to", "max_issues_repo_path": "src/Bisimilarity/CCS.agda", "max_line_length": 145, "max_stars_count": null, "max_stars_repo_head_hexsha": "b936ff85411baf3401ad85ce85d5ff2e9aa0ca14", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/up-to", "max_stars_repo_path": "src/Bisimilarity/CCS.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11616, "size": 24174 }
-- A certified implementation of the extended Euclidian algorithm, -- which in addition to the gcd also computes the coefficients of -- Bézout's identity. That is, integers x and y, such that -- ax + by = gcd a b. -- See https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm -- for details. module Numeric.Nat.GCD.Extended where open import Prelude open import Control.WellFounded open import Numeric.Nat.Divide open import Numeric.Nat.DivMod open import Numeric.Nat.GCD open import Tactic.Nat open import Tactic.Cong -- Bézout coefficients always have opposite signs, so we can represent -- a Bézout identity using only natural numbers, keeping track of which -- coefficient is the positive one. data BézoutIdentity (d a b : Nat) : Set where bézoutL : (x y : Nat) → a * x ≡ d + b * y → BézoutIdentity d a b bézoutR : (x y : Nat) → b * y ≡ d + a * x → BézoutIdentity d a b -- The result of the extended gcd algorithm is the same as for the normal -- one plus a BézoutIdentity. record ExtendedGCD (a b : Nat) : Set where no-eta-equality constructor gcd-res field d : Nat isGCD : IsGCD d a b bézout : BézoutIdentity d a b private -- This is what the recursive calls compute. At the top we get -- ExtendedGCD′ a b a b, which we can turn into ExtendedGCD a b. -- We need this because the correctness of the Bézout coefficients -- is established going down and the correctness of the gcd going -- up. record ExtendedGCD′ (a b r₀ r₁ : Nat) : Set where no-eta-equality constructor gcd-res field d : Nat isGCD : IsGCD d r₀ r₁ bézout : BézoutIdentity d a b -- Erasing the proof objects. eraseBézout : ∀ {a b d} → BézoutIdentity d a b → BézoutIdentity d a b eraseBézout (bézoutL x y eq) = bézoutL x y (eraseEquality eq) eraseBézout (bézoutR x y eq) = bézoutR x y (eraseEquality eq) -- Convert from ExtendedGCD′ as we erase, because why not. eraseExtendedGCD : ∀ {a b} → ExtendedGCD′ a b a b → ExtendedGCD a b eraseExtendedGCD (gcd-res d p i) = gcd-res d (eraseIsGCD p) (eraseBézout i) private -- The algorithm computes a sequence of coefficients xᵢ and yᵢ (sᵢ and tᵢ on -- Wikipedia) that terminates in the Bézout coefficients for a and b. The -- invariant is that they satisfy the Bézout identity for the current remainder. -- Moreover, at each step they flip sign, so we can represent two consecutive -- pairs of coefficients as follows. data BézoutState (a b r₀ r₁ : Nat) : Set where bézoutLR : ∀ x₀ x₁ y₀ y₁ (eq₀ : a * x₀ ≡ r₀ + b * y₀) (eq₁ : b * y₁ ≡ r₁ + a * x₁) → BézoutState a b r₀ r₁ bézoutRL : ∀ x₀ x₁ y₀ y₁ (eq₀ : b * y₀ ≡ r₀ + a * x₀) (eq₁ : a * x₁ ≡ r₁ + b * y₁) → BézoutState a b r₀ r₁ -- In the base case the last remainder is 0, and the second to last is the gcd, -- so we get the Bézout coefficients from the first components in the state. getBézoutIdentity : ∀ {d a b} → BézoutState a b d 0 → BézoutIdentity d a b getBézoutIdentity (bézoutLR x₀ _ y₀ _ eq₀ _) = bézoutL x₀ y₀ eq₀ getBézoutIdentity (bézoutRL x₀ _ y₀ _ eq₀ _) = bézoutR x₀ y₀ eq₀ -- It's important for compile time performance to be strict in the computed -- coefficients. Can't do a dependent force here due to the proof object. Note -- that we only have to be strict in x₁ and y₁, since x₀ and y₀ are simply -- the x₁ and y₁ of the previous state. forceState : ∀ {a b r₀ r₁} {C : Set} → BézoutState a b r₀ r₁ → (BézoutState a b r₀ r₁ → C) → C forceState (bézoutLR x₀ x₁ y₀ y₁ eq₀ eq₁) k = force′ x₁ λ x₁′ eqx → force′ y₁ λ y₁′ eqy → k (bézoutLR x₀ x₁′ y₀ y₁′ eq₀ (case eqx of λ where refl → case eqy of λ where refl → eq₁)) forceState (bézoutRL x₀ x₁ y₀ y₁ eq₀ eq₁) k = force′ x₁ λ x₁′ eqx → force′ y₁ λ y₁′ eqy → k (bézoutRL x₀ x₁′ y₀ y₁′ eq₀ (case eqx of λ where refl → case eqy of λ where refl → eq₁)) -- We're starting of the algorithm with two first remainders being a and b themselves. -- The corresponding coefficients are x₀, x₁ = 1, 0 and y₀, y₁ = 0, 1. initialState : ∀ {a b} → BézoutState a b a b initialState = bézoutLR 1 0 0 1 auto auto module _ {r₀ r₁ r₂} q where -- The proof that new coefficients satisfy the invariant. -- Note alternating sign: x₀ pos, x₁ neg, x₂ pos. lemma : (a b x₀ x₁ y₀ y₁ : Nat) → q * r₁ + r₂ ≡ r₀ → a * x₀ ≡ r₀ + b * y₀ → b * y₁ ≡ r₁ + a * x₁ → a * (x₀ + q * x₁) ≡ r₂ + b * (y₀ + q * y₁) lemma a b x₀ x₁ y₀ y₁ refl eq₀ eq₁ = a * (x₀ + q * x₁) ≡⟨ by eq₀ ⟩ r₂ + b * y₀ + q * (r₁ + a * x₁) ≡⟨ by-cong eq₁ ⟩ r₂ + b * y₀ + q * (b * y₁) ≡⟨ auto ⟩ r₂ + b * (y₀ + q * y₁) ∎ -- The sequence of coefficients is defined by -- xᵢ₊₁ = xᵢ₋₁ + q * xᵢ -- yᵢ₊₁ = yᵢ₋₁ + q * yᵢ -- where q is defined by the step in the normal Euclidian algorithm -- rᵢ₊₁ = rᵢ₋₁ + q * rᵢ bézoutState-step : ∀ {a b} → q * r₁ + r₂ ≡ r₀ → BézoutState a b r₀ r₁ → BézoutState a b r₁ r₂ bézoutState-step {a} {b} eq (bézoutLR x₀ x₁ y₀ y₁ eq₀ eq₁) = bézoutRL x₁ (x₀ + q * x₁) y₁ (y₀ + q * y₁) eq₁ (lemma a b x₀ x₁ y₀ y₁ eq eq₀ eq₁) bézoutState-step {a} {b} eq (bézoutRL x₀ x₁ y₀ y₁ eq₀ eq₁) = bézoutLR x₁ (x₀ + q * x₁) y₁ (y₀ + q * y₁) eq₁ (lemma b a y₀ y₁ x₀ x₁ eq eq₀ eq₁) extendedGCD-step : ∀ {a b} → q * r₁ + r₂ ≡ r₀ → ExtendedGCD′ a b r₁ r₂ → ExtendedGCD′ a b r₀ r₁ extendedGCD-step eq (gcd-res d p i) = gcd-res d (isGCD-step q eq p) i private extendedGCD-acc : {a b : Nat} → (r₀ r₁ : Nat) → BézoutState a b r₀ r₁ → Acc _<_ r₁ → ExtendedGCD′ a b r₀ r₁ extendedGCD-acc r₀ zero s _ = gcd-res r₀ (is-gcd (factor 1 auto) (factor! 0) λ k p _ → p) (getBézoutIdentity s) extendedGCD-acc r₀ (suc r₁) s (acc wf) = forceState s λ s → -- make sure to be strict in xᵢ and yᵢ case r₀ divmod suc r₁ of λ where (qr q r₂ lt eq) → extendedGCD-step q eq (extendedGCD-acc (suc r₁) r₂ (bézoutState-step q eq s) (wf r₂ lt)) -- The extended Euclidian algorithm. Easily handles inputs of several hundred digits. extendedGCD : (a b : Nat) → ExtendedGCD a b extendedGCD a b = eraseExtendedGCD (extendedGCD-acc a b initialState (wfNat b))
{ "alphanum_fraction": 0.6337200064, "avg_line_length": 45.273381295, "ext": "agda", "hexsha": "b65173f9789956f160bb149d2b534738931a1c03", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "lclem/agda-prelude", "max_forks_repo_path": "src/Numeric/Nat/GCD/Extended.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "lclem/agda-prelude", "max_issues_repo_path": "src/Numeric/Nat/GCD/Extended.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "lclem/agda-prelude", "max_stars_repo_path": "src/Numeric/Nat/GCD/Extended.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2328, "size": 6293 }
module Naturals where import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎) -- type definition data ℕ : Set where zero : ℕ suc : ℕ → ℕ -- bind builtin (aka Haskell integers) to my natural type {-# BUILTIN NATURAL ℕ #-} -- define addition proof -- base case for identity rule -- inductive case for associative rule _+_ : ℕ → ℕ → ℕ zero + n = n suc m + n = suc (m + n) -- 2 + 3 proposition is reflexive -- that means addition is a binary -- relation that relates to itself _ : 2 + 3 ≡ 5 _ = refl -- same for 3 + 4 propositon -- i manually proved it _ : 3 + 4 ≡ 7 _ = begin 3 + 4 ≡⟨⟩ suc (2 + 4) ≡⟨⟩ suc (suc (1 + 4)) ≡⟨⟩ suc (suc (suc (0 + 4))) ≡⟨⟩ suc (suc (suc 0)) + suc 3 ≡⟨⟩ suc (suc (suc 0)) + suc (suc 2) ≡⟨⟩ suc (suc (suc 0)) + suc (suc (suc 1)) ≡⟨⟩ suc (suc (suc 0)) + suc (suc (suc (suc 0))) ≡⟨⟩ 7 ∎ -- after addition we can efine -- multiplication in terms of it -- note the base case and the inductive case _*_ : ℕ → ℕ → ℕ zero * n = zero suc m * n = n + (m * n) _ = begin 2 * 3 ≡⟨⟩ 3 + (1 * 3) ≡⟨⟩ 3 + (3 + (0 * 3)) ≡⟨⟩ 3 + (3 + 0) ≡⟨⟩ 6 ∎ _ = begin 3 * 4 ≡⟨⟩ 4 + (2 * 4) ≡⟨⟩ 4 + (4 + (1 * 4)) ≡⟨⟩ 4 + (4 + (4 + (0 * 4))) ≡⟨⟩ 12 ∎ -- with multiplication we then can -- define exponentiation -- note that `m ^ zero` ‌/= `zero ^ m` _^_ : ℕ → ℕ → ℕ n ^ zero = 1 m ^ suc n = m * (m ^ n) _ : 3 ^ 4 ≡ 81 _ = begin 3 ^ 4 ≡⟨⟩ 3 * (3 ^ 3) ≡⟨⟩ 3 * (3 * (3 ^ 2)) ≡⟨⟩ 3 * (3 * (3 * (3 ^ 1))) ≡⟨⟩ 3 * (3 * (3 * (3 * (3 ^ 0)))) ≡⟨⟩ 81 ∎ _∸_ : ℕ → ℕ → ℕ m ∸ zero = m zero ∸ suc n = zero suc m ∸ suc n = m ∸ n _ : 3 ∸ 2 ≡ 1 _ = begin 3 ∸ 2 ≡⟨⟩ 2 ∸ 1 ≡⟨⟩ 1 ∸ 0 ≡⟨⟩ 1 ∎ _ : 2 ∸ 3 ≡ 0 _ = begin 2 ∸ 3 ≡⟨⟩ 1 ∸ 2 ≡⟨⟩ 0 ∸ 1 ≡⟨⟩ 0 ∎ _ : 5 ∸ 3 ≡ 2 _ = begin 5 ∸ 3 ≡⟨⟩ 4 ∸ 2 ≡⟨⟩ 3 ∸ 1 ≡⟨⟩ 2 ∸ 0 ≡⟨⟩ 2 ∎ _ : 3 ∸ 5 ≡ 0 _ = begin 3 ∸ 5 ≡⟨⟩ 2 ∸ 4 ≡⟨⟩ 1 ∸ 3 ≡⟨⟩ 0 ∸ 2 ≡⟨⟩ 0 ∎ -- here we define the precedence -- of operators. all they are left associative -- and addiction and monus have precedence less -- than multiplication infixl 6 _+_ _∸_ infixl 7 _*_ infixl 8 _^_ -- binding aforementioned operators -- to the relevant Haskell integer operators {-# BUILTIN NATPLUS _+_ #-} {-# BUILTIN NATTIMES _*_ #-} {-# BUILTIN NATMINUS _∸_ #-}
{ "alphanum_fraction": 0.4664793256, "avg_line_length": 14.0734463277, "ext": "agda", "hexsha": "c1e72f49fbea01fc07f658061a7ed621eb309ed2", "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": "0bedfbd7156e631a2ea563cbe812588c9fdb8b37", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "matdsoupe/paradigmas", "max_forks_repo_path": "funcional/agda/plfa/parte1/Naturals.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0bedfbd7156e631a2ea563cbe812588c9fdb8b37", "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": "matdsoupe/paradigmas", "max_issues_repo_path": "funcional/agda/plfa/parte1/Naturals.agda", "max_line_length": 57, "max_stars_count": null, "max_stars_repo_head_hexsha": "0bedfbd7156e631a2ea563cbe812588c9fdb8b37", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "matdsoupe/paradigmas", "max_stars_repo_path": "funcional/agda/plfa/parte1/Naturals.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1260, "size": 2491 }
{-# OPTIONS --safe --warning=error #-} open import Sets.Cardinality.Infinite.Definition open import Sets.EquivalenceRelations open import Setoids.Setoids open import Groups.FreeGroup.Definition open import Groups.Homomorphisms.Definition open import Groups.Definition open import Decidable.Sets open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import LogicalFormulae open import Semirings.Definition open import Functions.Definition open import Functions.Lemmas open import Groups.Isomorphisms.Definition open import Groups.FreeGroup.Word open import Groups.FreeGroup.Group open import Groups.FreeGroup.UniversalProperty open import Groups.Abelian.Definition open import Groups.QuotientGroup.Definition open import Groups.Lemmas open import Groups.Homomorphisms.Lemmas module Groups.FreeGroup.Lemmas {a : _} {A : Set a} (decA : DecidableSet A) where freeGroupNonAbelian : AbelianGroup (freeGroup decA) → (a : A) → Sg (A → True) Bijection freeGroupNonAbelian record { commutative = commutative } a = (λ _ → record {}) , b where b : Bijection (λ _ → record {}) Bijection.inj b {x} {y} _ with decA x y ... | inl pr = pr ... | inr neq = exFalso (neq (ofLetterInjective (prependLetterInjective' decA t))) where t : prependLetter {decA = decA} (ofLetter x) (prependLetter (ofLetter y) empty (wordEmpty refl)) (wordEnding (succIsPositive 0) refl) ≡ prependLetter (ofLetter y) (prependLetter (ofLetter x) empty (wordEmpty refl)) (wordEnding (succIsPositive 0) refl) t = commutative {prependLetter (ofLetter x) empty (wordEmpty refl)} {prependLetter (ofLetter y) empty (wordEmpty refl)} Bijection.surj b record {} = a , refl private iso : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → Bijection f → ReducedWord decA → ReducedWord decB iso decB {f} bij = universalPropertyFunction decA (freeGroup decB) λ a → freeEmbedding decB (f a) isoHom : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → GroupHom (freeGroup decA) (freeGroup decB) (iso decB bij) isoHom decB {f} bij = universalPropertyHom decA (freeGroup decB) λ a → iso decB bij (freeEmbedding decA a) iso2 : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → Bijection f → ReducedWord decB → ReducedWord decA iso2 decB {f} bij = universalPropertyFunction decB (freeGroup decA) λ b → freeEmbedding decA (Invertible.inverse (bijectionImpliesInvertible bij) b) iso2Hom : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → GroupHom (freeGroup decB) (freeGroup decA) (iso2 decB bij) iso2Hom decB {f} bij = universalPropertyHom decB (freeGroup decA) λ b → iso2 decB bij (freeEmbedding decB b) fixesF : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : A) → iso2 decB bij (iso decB bij (freeEmbedding decA x)) ≡ freeEmbedding decA x fixesF decB {f} bij x with Bijection.surj bij (f x) ... | _ , pr rewrite Bijection.inj bij pr = refl fixesF' : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : B) → iso decB bij (iso2 decB bij (freeEmbedding decB x)) ≡ freeEmbedding decB x fixesF' decB {f} bij x with Bijection.surj bij x ... | _ , pr rewrite pr = refl uniq : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decA) → x ≡ universalPropertyFunction decA (freeGroup decA) (λ x → iso2 decB bij (iso decB bij (freeEmbedding decA x))) x uniq decB {f} bij x = universalPropertyUniqueness decA (freeGroup decA) (λ x → iso2 decB bij (iso decB bij (freeEmbedding decA x))) {id} (record { wellDefined = id ; groupHom = refl }) (fixesF decB bij) x uniqLemm : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decA) → iso2 decB bij (iso decB bij x) ≡ universalPropertyFunction decA (freeGroup decA) (λ x → iso2 decB bij (iso decB bij (freeEmbedding decA x))) x uniqLemm decB {f} bij x = universalPropertyUniqueness decA (freeGroup decA) (λ i → freeEmbedding decA (underlying (Bijection.surj bij (f i)))) {λ i → iso2 decB bij (iso decB bij i)} (groupHomsCompose (isoHom decB bij) (iso2Hom decB bij)) (λ _ → refl) x uniq! : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decA) → iso2 decB bij (iso decB bij x) ≡ x uniq! decB bij x = transitivity (uniqLemm decB bij x) (equalityCommutative (uniq decB bij x)) uniq' : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decB) → x ≡ universalPropertyFunction decB (freeGroup decB) (λ x → iso decB bij (iso2 decB bij (freeEmbedding decB x))) x uniq' decB {f} bij x = universalPropertyUniqueness decB (freeGroup decB) (λ x → iso decB bij (iso2 decB bij (freeEmbedding decB x))) {id} (record { wellDefined = id ; groupHom = refl }) (fixesF' decB bij) x uniq'Lemm : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decB) → iso decB bij (iso2 decB bij x) ≡ universalPropertyFunction decB (freeGroup decB) (λ x → iso decB bij (iso2 decB bij (freeEmbedding decB x))) x uniq'Lemm decB {f} bij x = universalPropertyUniqueness decB (freeGroup decB) (λ i → freeEmbedding decB (f (Invertible.inverse (bijectionImpliesInvertible bij) i))) {λ i → iso decB bij (iso2 decB bij i)} (groupHomsCompose (iso2Hom decB bij) (isoHom decB bij)) (λ _ → refl) x uniq'! : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → (bij : Bijection f) → (x : ReducedWord decB) → iso decB bij (iso2 decB bij x) ≡ x uniq'! decB bij x = transitivity (uniq'Lemm decB bij x) (equalityCommutative (uniq' decB bij x)) inBijection : {b : _} {B : Set b} (decB : DecidableSet B) {f : A → B} (bij : Bijection f) → Bijection (iso decB bij) inBijection decB bij = invertibleImpliesBijection (record { inverse = iso2 decB bij ; isLeft = uniq'! decB bij ; isRight = uniq! decB bij }) freeGroupFunctorWellDefined : {b : _} {B : Set b} (decB : DecidableSet B) → {f : A → B} → Bijection f → GroupsIsomorphic (freeGroup decA) (freeGroup decB) GroupsIsomorphic.isomorphism (freeGroupFunctorWellDefined decB {f} bij) = iso decB bij GroupIso.groupHom (GroupsIsomorphic.proof (freeGroupFunctorWellDefined decB {f} bij)) = universalPropertyHom decA (freeGroup decB) λ a → freeEmbedding decB (f a) SetoidInjection.wellDefined (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof (freeGroupFunctorWellDefined decB {f} bij)))) refl = refl SetoidInjection.injective (SetoidBijection.inj (GroupIso.bij (GroupsIsomorphic.proof (freeGroupFunctorWellDefined decB {f} bij)))) {x} {y} pr = Bijection.inj (inBijection decB bij) pr SetoidSurjection.wellDefined (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof (freeGroupFunctorWellDefined decB {f} bij)))) refl = refl SetoidSurjection.surjective (SetoidBijection.surj (GroupIso.bij (GroupsIsomorphic.proof (freeGroupFunctorWellDefined decB {f} bij)))) {x} = Bijection.surj (inBijection decB bij) x {- freeGroupFunctorInjective : {b : _} {B : Set b} (decB : DecidableSet B) → GroupsIsomorphic (freeGroup decA) (freeGroup decB) → Sg (A → B) (λ f → Bijection f) freeGroupFunctorInjective decB iso = {!!} everyGroupQuotientOfFreeGroup : {b : _} → (S : Setoid {a} {b} A) → {_+_ : A → A → A} → (G : Group S _+_) → GroupsIsomorphic G (quotientGroupByHom (freeGroup decA) (universalPropertyHom decA {!!} {!!})) everyGroupQuotientOfFreeGroup = {!!} everyFGGroupQuotientOfFGFreeGroup : {!!} everyFGGroupQuotientOfFGFreeGroup = {!!} freeGroupTorsionFree : {!!} freeGroupTorsionFree = {!!} -} private mapNToGrp : (a : A) → (n : ℕ) → ReducedWord decA mapNToGrpLen : (a : A) → (n : ℕ) → wordLength decA (mapNToGrp a n) ≡ n mapNToGrpFirstLetter : (a : A) → (n : ℕ) → .(pr : 0 <N wordLength decA (mapNToGrp a (succ n))) → firstLetter decA (mapNToGrp a (succ n)) pr ≡ (ofLetter a) lemma : (a : A) → (n : ℕ) → .(pr : 0 <N wordLength decA (mapNToGrp a (succ n))) → ofLetter a ≡ freeInverse (firstLetter decA (mapNToGrp a (succ n)) pr) → False lemma a zero _ () lemma a (succ n) _ () mapNToGrp a zero = empty mapNToGrp a 1 = prependLetter (ofLetter a) empty (wordEmpty refl) mapNToGrp a (succ (succ n)) = prependLetter (ofLetter a) (mapNToGrp a (succ n)) (wordEnding (identityOfIndiscernablesRight _<N_ (succIsPositive n) (equalityCommutative (mapNToGrpLen a (succ n)))) (freeCompletionEqualFalse decA λ p → lemma a n ((identityOfIndiscernablesRight _<N_ (succIsPositive n) (equalityCommutative (mapNToGrpLen a (succ n))))) p)) mapNToGrpFirstLetter a zero pr = refl mapNToGrpFirstLetter a (succ n) pr = refl mapNToGrpLen a zero = refl mapNToGrpLen a (succ zero) = refl mapNToGrpLen a (succ (succ n)) = applyEquality succ (mapNToGrpLen a (succ n)) mapNToGrpInj : (a : A) → (x y : ℕ) → mapNToGrp a x ≡ mapNToGrp a y → x ≡ y mapNToGrpInj a zero zero pr = refl mapNToGrpInj a zero (succ zero) () mapNToGrpInj a zero (succ (succ y)) () mapNToGrpInj a (succ zero) zero () mapNToGrpInj a (succ (succ x)) zero () mapNToGrpInj a (succ zero) (succ zero) pr = refl mapNToGrpInj a (succ zero) (succ (succ y)) pr = exFalso (naughtE (transitivity (applyEquality (wordLength decA) (prependLetterInjective decA pr)) (mapNToGrpLen a (succ y)))) mapNToGrpInj a (succ (succ x)) (succ 0) pr = exFalso (naughtE (transitivity (equalityCommutative (applyEquality (wordLength decA) (prependLetterInjective decA pr))) (mapNToGrpLen a (succ x)))) mapNToGrpInj a (succ (succ x)) (succ (succ y)) pr = applyEquality succ (mapNToGrpInj a (succ x) (succ y) (prependLetterInjective decA pr)) freeGroupInfinite : (nonempty : A) → DedekindInfiniteSet (ReducedWord decA) DedekindInfiniteSet.inj (freeGroupInfinite nonempty) = mapNToGrp nonempty DedekindInfiniteSet.isInjection (freeGroupInfinite nonempty) {x} {y} = mapNToGrpInj nonempty x y
{ "alphanum_fraction": 0.7013065937, "avg_line_length": 74.2330827068, "ext": "agda", "hexsha": "c5d18aae30192775739410458ff518da7619b4f0", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Groups/FreeGroup/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": "Groups/FreeGroup/Lemmas.agda", "max_line_length": 354, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Groups/FreeGroup/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": 3468, "size": 9873 }
open import Agda.Primitive.Cubical test : (J : IUniv) → J → J test J j = primHComp {φ = i0} (λ k → λ ()) j
{ "alphanum_fraction": 0.5925925926, "avg_line_length": 21.6, "ext": "agda", "hexsha": "12cc971a4528c03e002967bf350ffb1acc28098d", "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/IUnivNoHComp.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/IUnivNoHComp.agda", "max_line_length": 44, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/IUnivNoHComp.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": 45, "size": 108 }
{-# OPTIONS --allow-unsolved-metas #-} -- {-# OPTIONS -v tc.meta:45 #-} -- Andreas, 2014-12-07 found a bug in pruning open import Common.Prelude open import Common.Product open import Common.Equality postulate f : Bool → Bool test : let X : Bool → Bool → Bool X = _ Y : Bool Y = _ in ∀ b → Y ≡ f (X b (f (if true then true else b))) × (∀ a → X a (f b) ≡ f b) test b = refl , λ a → refl -- ERROR WAS: -- Cannot instantiate the metavariable _22 to solution f b since it -- contains the variable b which is not in scope of the metavariable -- or irrelevant in the metavariable but relevant in the solution -- when checking that the expression refl has type (_22 ≡ f b) -- Here, Agda complains although there is a solution -- X a b = b -- Y = f (f true) -- Looking at the first constraint -- Y = f (X b (f (if true then true else b))) -- agda prunes *both* arguments of X since they have rigid occurrences -- of b. However, the second occurrences goes away by normalization: -- Y = f (X b (f true)) -- For efficiency reasons, see issue 415 , Agda first does not -- normalize during occurs check. Thus, the free variable check for -- the arg (if true then true else b) returns b as rigid, which means -- we have a neutral term (f (...b...)) with a rigid occurrence of bad -- variable b, and we prune this argument of meta X. This is unsound, -- since the free variable check only returns a superset of the actual -- (semantic) variable dependencies. -- NOW: metas should be unsolved.
{ "alphanum_fraction": 0.6692708333, "avg_line_length": 29.5384615385, "ext": "agda", "hexsha": "c064ae1cc117bedb46492aba4ab4cfe4fceda770", "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/Issue1386.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/Issue1386.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/Succeed/Issue1386.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": 421, "size": 1536 }