Search is not available for this dataset
text
string
meta
dict
module Numeral.Finite.Sequence where import Lvl open import Data.Either as Either using (_โ€–_) open import Data.Either.Equiv as Either open import Data.Either.Equiv.Id open import Data.Either.Proofs as Either open import Data.Tuple as Tuple using (_โจฏ_ ; _,_) open import Data.Tuple.Equiv as Tuple open import Data.Tuple.Equiv.Id open import Data.Tuple.Proofs as Tuple open import Functional open import Function.Equals open import Function.Proofs open import Logic open import Logic.Predicate open import Logic.Propositional open import Numeral.Finite open import Numeral.Finite.Bound -- open import Numeral.Finite.Equiv import Numeral.Finite.Oper as ๐•Ÿ open import Numeral.Natural import Numeral.Natural.Oper as โ„• open import Numeral.Natural.Oper.Proofs.Order open import Relator.Equals open import Relator.Equals.Proofs.Equiv using () renaming ([โ‰ก]-equiv to Id-equiv ; [โ‰ก]-function to Id-function) open import Structure.Function open import Structure.Function.Domain open import Structure.Function.Domain.Proofs import Structure.Function.Names as Names open import Structure.Operator open import Structure.Relator open import Structure.Relator.Properties open import Structure.Setoid open import Syntax.Transitivity open import Type open import Type.Size private variable โ„“ โ„“โ‚ โ„“โ‚‚ โ„“โ‚‘ โ„“โ‚‘โ‚ โ„“โ‚‘โ‚‚ โ„“โ‚‘โ‚ƒ โ„“โ‚‘โ‚„ โ„“โ‚‘โ‚… โ„“โ‚‘โ‚† : Lvl.Level private variable A : Type{โ„“โ‚} private variable B : Type{โ„“โ‚‚} private variable a b : โ„• module Interleaving where join : (๐•Ÿ(a) โ€– ๐•Ÿ(b)) โ†’ ๐•Ÿ(a โ„•.+ b) join {๐ŸŽ} {๐’ b} (Either.Right n) = n join {๐’ a}{๐ŸŽ} (Either.Left n) = n join {๐’ a}{๐’ b} (Either.Left ๐ŸŽ) = ๐ŸŽ join {๐’ a}{๐’ b} (Either.Right ๐ŸŽ) = ๐’(๐ŸŽ) join {๐’ a}{๐’ b} (Either.Left (๐’ n)) = ๐’(๐’(join {a}{b} (Either.Left n))) join {๐’ a}{๐’ b} (Either.Right (๐’ n)) = ๐’(๐’(join {a}{b} (Either.Right n))) split : ๐•Ÿ(a โ„•.+ b) โ†’ (๐•Ÿ(a) โ€– ๐•Ÿ(b)) split {๐ŸŽ} {๐’ b} n = Either.Right n split {๐’ a} {๐ŸŽ} n = Either.Left n split {๐’ a} {๐’ b} ๐ŸŽ = Either.Left ๐ŸŽ split {๐’ a} {๐’ b} (๐’(๐ŸŽ)) = Either.Right ๐ŸŽ split {๐’ a} {๐’ b} (๐’(๐’(n))) = Either.map ๐’ ๐’ (split {a} {b} n) instance join-split-inverses : Inverseแตฃ(join{a}{b})(split{a}{b}) join-split-inverses {a}{b} = intro(proof{a}{b}) where proof : โˆ€{a b} โ†’ Names.Inverses(join{a}{b})(split{a}{b}) proof {๐ŸŽ} {๐’ b}{๐ŸŽ} = [โ‰ก]-intro proof {๐ŸŽ} {๐’ b}{๐’ n} = [โ‰ก]-intro proof {๐’ a}{๐ŸŽ} {๐ŸŽ} = [โ‰ก]-intro proof {๐’ a}{๐ŸŽ} {๐’ n} = [โ‰ก]-intro proof {๐’ a}{๐’ b}{๐ŸŽ} = [โ‰ก]-intro proof {๐’ a}{๐’ b}{๐’ ๐ŸŽ} = [โ‰ก]-intro proof {๐’ a}{๐’ b}{๐’(๐’ n)} with split{a}{b} n | proof {a}{b}{n} ... | Either.Left m | p = congruenceโ‚(๐’) (congruenceโ‚(๐’) p) ... | Either.Right m | p = congruenceโ‚(๐’) (congruenceโ‚(๐’) p) instance split-join-inverses : Inverseโ‚—(join{a}{b})(split{a}{b}) split-join-inverses {a}{b} = intro(proof{a}{b}) where proof : โˆ€{a b} โ†’ Names.Inverses(split{a}{b})(join{a}{b}) proof {๐ŸŽ} {๐ŸŽ} {Either.Left ()} proof {๐ŸŽ} {๐ŸŽ} {Either.Right ()} proof {๐ŸŽ} {๐’ b} {Either.Right n} = [โ‰ก]-intro proof {๐’ a} {๐ŸŽ} {Either.Left n} = [โ‰ก]-intro proof {๐’ a} {๐’ b} {Either.Left ๐ŸŽ} = [โ‰ก]-intro proof {๐’ a} {๐’ b} {Either.Right ๐ŸŽ} = [โ‰ก]-intro proof {๐’(๐’ a)} {๐’ ๐ŸŽ} {Either.Left (๐’ n)} = [โ‰ก]-intro proof {๐’ ๐ŸŽ} {๐’(๐’ b)} {Either.Right (๐’ n)} = [โ‰ก]-intro proof {๐’(๐’ a)} {๐’(๐’ b)} {Either.Left (๐’ n)} with join{๐’ a}{๐’ b} (Either.Left n) | proof {๐’ a}{๐’ b}{Either.Left n} ... | ๐ŸŽ | p = congruenceโ‚(Either.map ๐’ ๐’) p ... | ๐’(๐’ m) | p = congruenceโ‚(Either.map ๐’ ๐’) p proof {๐’(๐’ a)} {๐’(๐’ b)} {Either.Right (๐’ n)} with join{๐’ a}{๐’ b} (Either.Right n) | proof {๐’ a}{๐’ b}{Either.Right n} ... | ๐’(๐ŸŽ) | p = congruenceโ‚(Either.map ๐’ ๐’) p ... | ๐’(๐’ m) | p = congruenceโ‚(Either.map ๐’ ๐’) p instance split-join-inverse : Inverse(split{a}{b})(join{a}{b}) split-join-inverse = [โˆง]-intro join-split-inverses split-join-inverses instance split-bijective : Bijective(split{a}{b}) split-bijective = invertible-to-bijective โฆƒ inver = [โˆƒ]-intro join โฆƒ [โˆง]-intro Id-function split-join-inverse โฆ„ โฆ„ -- Interleaves two sequences into one, alternating between the elements and then putting the leftovers at the end. interleave : (๐•Ÿ(a) โ†’ A) โ†’ (๐•Ÿ(b) โ†’ B) โ†’ (๐•Ÿ(a โ„•.+ b) โ†’ (A โ€– B)) interleave af bf = Either.map af bf โˆ˜ Interleaving.split module _ โฆƒ equiv-A : Equiv{โ„“โ‚‘โ‚}(A) โฆ„ โฆƒ equiv-B : Equiv{โ„“โ‚‘โ‚‚}(B) โฆ„ โฆƒ equiv-AB : Equiv{โ„“โ‚‘}(A โ€– B) โฆ„ โฆƒ ext-AB : Either.Extensionality โฆƒ equiv-A โฆ„ โฆƒ equiv-B โฆ„ (equiv-AB) โฆ„ {af : ๐•Ÿ(a) โ†’ A} โฆƒ bij-af : Bijective โฆƒ Id-equiv โฆ„ โฆƒ equiv-A โฆ„ (af) โฆ„ {bf : ๐•Ÿ(b) โ†’ B} โฆƒ bij-bf : Bijective โฆƒ Id-equiv โฆ„ โฆƒ equiv-B โฆ„ (bf) โฆ„ where instance interleave-bijective : Bijective(interleave af bf) interleave-bijective = [โˆ˜]-bijective โฆƒ bij-f = Either.map-bijective โฆ„ โฆƒ bij-g = Interleaving.split-bijective โฆ„ module Concatenation where join : (๐•Ÿ(a) โ€– ๐•Ÿ(b)) โ†’ ๐•Ÿ(a โ„•.+ b) join {a} {b} (Either.Left n) = bound-[โ‰ค] [โ‰ค]-of-[+]โ‚— n join {a} {b} (Either.Right n) = a ๐•Ÿ.Unclosed.+โ‚™โ‚— n split : ๐•Ÿ(a โ„•.+ b) โ†’ (๐•Ÿ(a) โ€– ๐•Ÿ(b)) split {๐ŸŽ} {๐’ b} n = Either.Right n split {๐’ a}{๐ŸŽ} n = Either.Left n split {๐’ a}{๐’ b} ๐ŸŽ = Either.Left ๐ŸŽ split {๐’ a}{๐’ b} (๐’ n) = Either.mapLeft ๐’ (split {a}{๐’ b} n) open import Numeral.Finite.Category open import Structure.Category.Functor instance join-split-inverses : Inverseแตฃ(join{a}{b})(split{a}{b}) join-split-inverses {a}{b} = intro(proof{a}{b}) where proof : โˆ€{a b} โ†’ Names.Inverses(join{a}{b})(split{a}{b}) proof {๐ŸŽ} {๐’ b} {n} = [โ‰ก]-intro proof {๐’ a} {๐ŸŽ} {n} = _โŠœ_.proof (Functor.id-preserving bound-functor) proof {๐’ a} {๐’ b} {๐ŸŽ} = [โ‰ก]-intro proof {๐’ a} {๐’ b} {๐’ n} with split {a}{๐’ b} n | proof {a} {๐’ b} {n} ... | Either.Left _ | [โ‰ก]-intro = [โ‰ก]-intro ... | Either.Right _ | [โ‰ก]-intro = [โ‰ก]-intro instance split-join-inverses : Inverseโ‚—(join{a}{b})(split{a}{b}) split-join-inverses {a}{b} = intro(proof{a}{b}) where proof : โˆ€{a b} โ†’ Names.Inverses(split{a}{b})(join{a}{b}) proof {๐ŸŽ} {๐’ b} {Either.Right n} = [โ‰ก]-intro proof {๐’ a} {๐ŸŽ} {Either.Left n} = congruenceโ‚(Either.Left) (_โŠœ_.proof (Functor.id-preserving bound-functor)) proof {๐’ a} {๐’ b} {Either.Left ๐ŸŽ} = [โ‰ก]-intro proof {๐’ a} {๐’ b} {Either.Left (๐’ n)} = congruenceโ‚(Either.mapLeft ๐’) (proof{a}{๐’ b} {Either.Left n}) proof {๐’ a} {๐’ b} {Either.Right n} = congruenceโ‚(Either.mapLeft ๐’) (proof{a}{๐’ b} {Either.Right n}) instance split-join-inverse : Inverse(split{a}{b})(join{a}{b}) split-join-inverse = [โˆง]-intro join-split-inverses split-join-inverses instance split-bijective : Bijective(split{a}{b}) split-bijective = invertible-to-bijective โฆƒ inver = [โˆƒ]-intro join โฆƒ [โˆง]-intro Id-function split-join-inverse โฆ„ โฆ„ -- Concatenates two sequences into one, putting the elements of the first sequence first followed by the elements of the second sequence. concat : (๐•Ÿ(a) โ†’ A) โ†’ (๐•Ÿ(b) โ†’ B) โ†’ (๐•Ÿ(a โ„•.+ b) โ†’ (A โ€– B)) concat af bf = Either.map af bf โˆ˜ Concatenation.split module _ โฆƒ equiv-A : Equiv{โ„“โ‚‘โ‚}(A) โฆ„ โฆƒ equiv-B : Equiv{โ„“โ‚‘โ‚‚}(B) โฆ„ โฆƒ equiv-AB : Equiv{โ„“โ‚‘}(A โ€– B) โฆ„ โฆƒ ext-AB : Either.Extensionality โฆƒ equiv-A โฆ„ โฆƒ equiv-B โฆ„ (equiv-AB) โฆ„ {af : ๐•Ÿ(a) โ†’ A} โฆƒ bij-af : Bijective โฆƒ Id-equiv โฆ„ โฆƒ equiv-A โฆ„ (af) โฆ„ {bf : ๐•Ÿ(b) โ†’ B} โฆƒ bij-bf : Bijective โฆƒ Id-equiv โฆ„ โฆƒ equiv-B โฆ„ (bf) โฆ„ where instance concat-bijective : Bijective(concat af bf) concat-bijective = [โˆ˜]-bijective โฆƒ bij-f = Either.map-bijective โฆ„ โฆƒ bij-g = Concatenation.split-bijective โฆ„ module LinearSpaceFilling where join : (๐•Ÿ(a) โจฏ ๐•Ÿ(b)) โ†’ ๐•Ÿ(a โ„•.โ‹… b) join = Tuple.uncurry(๐•Ÿ.Exact._โ‹…_) -- split : ๐•Ÿ(a โ„•.โ‹… b) โ†’ (๐•Ÿ(a) โจฏ ๐•Ÿ(b)) -- split {a}{b} n = ({!n mod a!} , {!n / a!}) module BaseNumerals where -- TODO: Maybe try to use Numeral.FixedPositional -- When interpreting the function as a numeral in a certain base, the parameters mean the following: -- โ€ข `a` is the base. -- โ€ข `b` is the length of the numerals (the maximum number of digits). -- โ€ข The argument of the specified function is the position of the numeral. -- โ€ข The value of the specified function is the digit on the argument's position. {-join : (๐•Ÿ(a) โ† ๐•Ÿ(b)) โ†’ ๐•Ÿ(a โ„•.^ b) join {a}{๐ŸŽ} f = ๐ŸŽ join {a}{๐’ b} f = {!f(๐ŸŽ) ๐•Ÿ.Exact.+ ((join {a}{b} (f โˆ˜ ๐’)) ๐•Ÿ.Unclosed.โ‹…โ‚™แตฃ a)!}-} -- f(๐ŸŽ) ๐•Ÿ.Exact.โ‹… join {a}{b} (f โˆ˜ ๐’) -- 4321 -- 1โ‹…10โฐ + 2โ‹…10ยน + 3โ‹…10ยฒ + 4โ‹…10ยณ -- 1 + 10โ‹…(2 + 10โ‹…(3 + 10โ‹…(4 + 10โ‹…0))) -- TODO: Something is incorrect here. This is the type of the induction step: -- a + ๐’(aโ‹…(a ^ b)) -- ๐’(a + aโ‹…(a ^ b)) -- ๐’(a + (a ^ ๐’(b))) -- ๐’(a) + (a ^ ๐’(b)) {- open import Data.Boolean join : (๐•Ÿ(a) โ†’ Bool) โ†’ ๐•Ÿ(2 โ„•.^ a) join {๐ŸŽ} f = ๐ŸŽ join {๐’ a} f = {!(if f(๐ŸŽ) then ๐•Ÿ.๐’(๐•Ÿ.๐ŸŽ) else ๐•Ÿ.๐ŸŽ) ๐•Ÿ.Exact.+ join {a} (f โˆ˜ ๐•Ÿ.๐’)!} -} {- TODO: Old stuff below. Could be useful to have some properties of the interleave and concat functions -- Interleaves two sequences into one, alternating between the elements and then putting the leftovers at the end. interleave : (๐•Ÿ(a) โ†’ A) โ†’ (๐•Ÿ(b) โ†’ B) โ†’ (๐•Ÿ(a โ„•.+ b) โ†’ (A โ€– B)) interleave {a = ๐ŸŽ} {b = ๐’ b} af bf n = Either.Right(bf(n)) interleave {a = ๐’ a} {b = ๐ŸŽ} af bf n = Either.Left(af(n)) interleave {a = ๐’ a} {b = ๐’ b} af bf ๐ŸŽ = Either.Left(af(๐ŸŽ)) interleave {a = ๐’ a} {b = ๐’ b} af bf (๐’ ๐ŸŽ) = Either.Right(bf(๐ŸŽ)) interleave {a = ๐’ a} {b = ๐’ b} af bf (๐’(๐’ n)) = interleave {a = a}{b = b} (af โˆ˜ ๐’) (bf โˆ˜ ๐’) n -- Concatenates two sequences into one, putting the elements of the first sequence first followed by the elements of the second sequence. concat : (๐•Ÿ(a) โ†’ A) โ†’ (๐•Ÿ(b) โ†’ B) โ†’ (๐•Ÿ(a โ„•.+ b) โ†’ (A โ€– B)) concat {a = ๐ŸŽ} {b = ๐’ b} af bf n = Either.Right(bf(n)) concat {a = ๐’ a} {b = b} af bf ๐ŸŽ = Either.Left(af(๐ŸŽ)) concat {a = ๐’ a} {b = b} af bf (๐’ n) = concat {a = a} {b = b} (af โˆ˜ ๐’) bf n concat-is-left : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{n : ๐•Ÿ(a)} โ†’ (concat af bf (bound-[โ‰ค] [โ‰ค]-of-[+]โ‚— n) โ‰ก Either.Left(af(n))) concat-is-left {a = ๐’ a} {b} {af}{bf} {n = ๐ŸŽ} = [โ‰ก]-intro concat-is-left {a = ๐’ a} {๐ŸŽ} {af}{bf} {n = ๐’ n} = ([โ‰ก]-with(concat af bf) (p{n = n})) ๐Ÿ– concat-is-left {a = a} {b = ๐ŸŽ} {af = af โˆ˜ ๐’}{bf = bf} {n = n} where p : โˆ€{A}{n : ๐•Ÿ(A)} โ†’ (bound-[โ‰ค] ([โ‰ค]-of-[+]โ‚— {๐’ A}{๐ŸŽ}) (๐’(n)) โ‰ก ๐’(bound-[โ‰ค] [โ‰ค]-of-[+]โ‚— n)) p {.(๐’ _)} {๐ŸŽ} = [โ‰ก]-intro p {.(๐’ _)} {๐’ n} = [โ‰ก]-intro concat-is-left {a = ๐’ a} {๐’ b} {af}{bf} {n = ๐’ n} = concat-is-left {a = a} {b = ๐’ b} {af = af โˆ˜ ๐’}{bf = bf} {n = n} concat-is-left-on-0 : โˆ€{a}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(๐ŸŽ) โ†’ B}{n : ๐•Ÿ(a)} โ†’ (concat af bf n โ‰ก Either.Left(af(n))) concat-is-left-on-0 {a = ๐’ a} {n = ๐ŸŽ} = [โ‰ก]-intro concat-is-left-on-0 {a = ๐’ a} {n = ๐’ n} = concat-is-left-on-0 {a = a} {n = n} -- concat-is-right : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(๐’ b) โ†’ B}{n : ๐•Ÿ(b)} โ†’ (concat af bf (maximum{n = a} ๐•Ÿ.+ n) โ‰ก Either.Right(bf(bound-๐’ n))) concat-left-pattern : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{n : ๐•Ÿ(a โ„•.+ b)}{aa} โ†’ (concat af bf n โ‰ก Either.Left(aa)) โ†’ โˆƒ(k โ†ฆ (af(k) โ‰ก aa)) concat-left-pattern {a = ๐ŸŽ} {๐ŸŽ} {af} {bf} {} concat-left-pattern {a = ๐’ a} {b} {af} {bf} {๐ŸŽ} {aa} p = [โˆƒ]-intro ๐ŸŽ โฆƒ injective(Either.Left) p โฆ„ concat-left-pattern {a = ๐’ a} {๐ŸŽ} {af} {bf} {๐’ n} {aa} p rewrite concat-is-left-on-0 {af = af}{bf = bf}{n = ๐’ n} = [โˆƒ]-intro (๐’(n)) โฆƒ injective(Either.Left) p โฆ„ concat-left-pattern {a = ๐’ a} {๐’ b} {af} {bf} {๐’ n} {aa} p with concat-left-pattern {a = a}{๐’ b}{af โˆ˜ ๐’}{bf}{n} ... | q with q p ... | [โˆƒ]-intro witness โฆƒ proof โฆ„ = [โˆƒ]-intro (๐’ witness) โฆƒ proof โฆ„ concat-right-pattern : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{n : ๐•Ÿ(a โ„•.+ b)}{bb} โ†’ (concat af bf n โ‰ก Either.Right(bb)) โ†’ โˆƒ(k โ†ฆ (bf(k) โ‰ก bb)) concat-right-pattern {a = ๐ŸŽ} {๐ŸŽ} {af} {bf} {} concat-right-pattern {a = ๐ŸŽ} {๐’ b} {af} {bf} {๐ŸŽ} {bb} p = [โˆƒ]-intro ๐ŸŽ โฆƒ injective(Either.Right) p โฆ„ concat-right-pattern {a = ๐ŸŽ} {๐’ b} {af} {bf} {๐’ n} {bb} p = [โˆƒ]-intro (๐’(n)) โฆƒ injective(Either.Right) p โฆ„ concat-right-pattern {a = ๐’ a} {๐ŸŽ} {af} {bf} {๐’ n} {bb} p = concat-right-pattern {a = a}{๐ŸŽ} {af โˆ˜ ๐’}{bf} {n} {bb} p concat-right-pattern {a = ๐’ a} {๐’ b} {af} {bf} {๐’ n} {bb} p = concat-right-pattern {a = a}{๐’ b}{af โˆ˜ ๐’}{bf}{n} p concat-left-or-right : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{n : ๐•Ÿ(a โ„•.+ b)} โ†’ โˆƒ(aa โ†ฆ concat af bf n โ‰ก Either.Left(af(aa))) โˆจ โˆƒ(bb โ†ฆ concat af bf n โ‰ก Either.Right(bf(bb))) concat-left-or-right {a = a} {b} {af} {bf} {n} with concat af bf n | inspect (concat af bf) n ... | [โˆจ]-introโ‚— aa | intro q with [โˆƒ]-intro r โฆƒ rp โฆ„ โ† concat-left-pattern{a = a}{b}{af}{bf}{n}{aa} q = [โˆจ]-introโ‚— ([โˆƒ]-intro r โฆƒ [โ‰ก]-with(Either.Left) (symmetry(_โ‰ก_) rp) โฆ„) ... | [โˆจ]-introแตฃ bb | intro q with [โˆƒ]-intro r โฆƒ rp โฆ„ โ† concat-right-pattern{a = a}{b}{af}{bf}{n}{bb} q = [โˆจ]-introแตฃ ([โˆƒ]-intro r โฆƒ [โ‰ก]-with(Either.Right) (symmetry(_โ‰ก_) rp) โฆ„) instance concat-injective : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B} โ†’ โฆƒ Injective(af) โฆ„ โ†’ โฆƒ Injective(bf) โฆ„ โ†’ Injective(concat af bf) Injective.proof (concat-injective {a = ๐ŸŽ} {๐’ b} {af} {bf}) {x} {y} p = injective(bf) (injective(Either.Right) p) Injective.proof (concat-injective {a = ๐’ a} {b} {af} {bf}) {๐ŸŽ} {๐ŸŽ} p = [โ‰ก]-intro Injective.proof (concat-injective {a = ๐’ a} {๐ŸŽ} {af} {bf}) {๐ŸŽ} {๐’ y} p rewrite concat-is-left-on-0 {af = af}{bf = bf}{n = ๐’ y} with () โ† injective(af) (injective(Either.Left) p) Injective.proof (concat-injective {a = ๐’ a} {๐ŸŽ} {af} {bf}) {๐’ x} {๐ŸŽ} p rewrite concat-is-left-on-0 {af = af}{bf = bf}{n = ๐’ x} with () โ† injective(af) (injective(Either.Left) p) Injective.proof (concat-injective {a = ๐’ a} {๐’ b} {af} {bf}) {๐ŸŽ} {๐’ y} p with concat-left-or-right{af = af โˆ˜ ๐’}{bf = bf}{n = y} ... | [โˆจ]-introโ‚— ([โˆƒ]-intro _ โฆƒ proof โฆ„) with () โ† injective(af) (injective(Either.Left) (p ๐Ÿ– proof)) ... | [โˆจ]-introแตฃ ([โˆƒ]-intro _ โฆƒ proof โฆ„) with () โ† p ๐Ÿ– proof Injective.proof (concat-injective {a = ๐’ a} {๐’ b} {af} {bf}) {๐’ x} {๐ŸŽ} p with concat-left-or-right{af = af โˆ˜ ๐’}{bf = bf}{n = x} ... | [โˆจ]-introโ‚— ([โˆƒ]-intro _ โฆƒ proof โฆ„) with () โ† injective(af) (injective(Either.Left) (symmetry(_โ‰ก_) p ๐Ÿ– proof)) ... | [โˆจ]-introแตฃ ([โˆƒ]-intro _ โฆƒ proof โฆ„) with () โ† symmetry(_โ‰ก_) p ๐Ÿ– proof {-# CATCHALL #-} Injective.proof (concat-injective {a = ๐’ a} {b} {af} {bf}) {๐’ x} {๐’ y} p = congruenceโ‚(๐’) (Injective.proof (concat-injective {a = a} {b} {af โˆ˜ ๐’} {bf} โฆƒ [โˆ˜]-injective {f = af}{g = ๐’} โฆ„) {x} {y} p) concat-when-left : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{n} โ†’ โˆƒ(aa โ†ฆ concat af bf n โ‰ก Either.Left(aa)) โ†” (๐•Ÿ-to-โ„•(n) < a) concat-when-left {a = a} {b} {af} {bf} {n} = [โ†”]-intro l r where l : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{n} โ†’ โˆƒ(aa โ†ฆ concat af bf n โ‰ก Either.Left(aa)) โ† (๐•Ÿ-to-โ„•(n) < a) l {a = .(๐’ _)} {b} {af} {bf} {๐ŸŽ} [โ‰ค]-with-[๐’] = [โˆƒ]-intro (af(๐ŸŽ)) โฆƒ reflexivity(_โ‰ก_) โฆ„ l {a = .(๐’ _)} {b} {af} {bf} {๐’ n} ([โ‰ค]-with-[๐’] {y = a} โฆƒ p โฆ„) = l {a = a}{b}{af โˆ˜ ๐’}{bf}{n} p r : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{n} โ†’ โˆƒ(aa โ†ฆ concat af bf n โ‰ก Either.Left(aa)) โ†’ (๐•Ÿ-to-โ„•(n) < a) r {a = ๐ŸŽ} {b} {af} {bf} {๐ŸŽ} ([โˆƒ]-intro aa โฆƒ โฆ„) r {a = ๐’ a} {b} {af} {bf} {๐ŸŽ} ([โˆƒ]-intro aa โฆƒ p โฆ„) = [<]-minimum r {a = ๐’ a} {b} {af} {bf} {๐’ n} ([โˆƒ]-intro aa โฆƒ p โฆ„) = [โ‰ค]-with-[๐’] โฆƒ r {a = a}{b}{af โˆ˜ ๐’}{bf}{n} ([โˆƒ]-intro aa โฆƒ p โฆ„) โฆ„ concat-when-right : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{n} โ†’ โˆƒ(bb โ†ฆ concat af bf n โ‰ก Either.Right(bb)) โ†” (a โ‰ค ๐•Ÿ-to-โ„•(n)) concat-when-right {a = a} {b} {af} {bf} {n} = [โ†”]-intro l r where l : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{n} โ†’ โˆƒ(bb โ†ฆ concat af bf n โ‰ก Either.Right(bb)) โ† (a โ‰ค ๐•Ÿ-to-โ„•(n)) l {a = ๐ŸŽ} {๐’ b} {af} {bf} {n} [โ‰ค]-minimum = [โˆƒ]-intro (bf(n)) โฆƒ reflexivity(_โ‰ก_) โฆ„ l {a = ๐’ a} {b} {af} {bf} {๐’ n} ([โ‰ค]-with-[๐’] โฆƒ p โฆ„) = l {a = a}{b}{af โˆ˜ ๐’}{bf}{n} p r : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{n} โ†’ โˆƒ(bb โ†ฆ concat af bf n โ‰ก Either.Right(bb)) โ†’ (a โ‰ค ๐•Ÿ-to-โ„•(n)) r {a = ๐ŸŽ} {b} {af} {bf} {_} ([โˆƒ]-intro bb โฆƒ p โฆ„) = [โ‰ค]-minimum r {a = ๐’ a} {b} {af} {bf} {๐ŸŽ} ([โˆƒ]-intro bb โฆƒ โฆ„) r {a = ๐’ a} {b} {af} {bf} {๐’ n} ([โˆƒ]-intro bb โฆƒ p โฆ„) = [โ‰ค]-with-[๐’] โฆƒ r {a = a}{b}{af โˆ˜ ๐’}{bf}{n} ([โˆƒ]-intro bb โฆƒ p โฆ„) โฆ„ ๐•Ÿ-shrink : โˆ€{A B} โ†’ (b : ๐•Ÿ(B)) โ†’ (๐•Ÿ-to-โ„•(b) < A) โ†’ ๐•Ÿ(A) ๐•Ÿ-shrink {๐’ A}{๐’ B} ๐ŸŽ [โ‰ค]-with-[๐’] = ๐ŸŽ ๐•Ÿ-shrink {๐’ A}{๐’ B} (๐’ b) ([โ‰ค]-with-[๐’] โฆƒ p โฆ„) = ๐’(๐•Ÿ-shrink {A}{B} b p) ๐•Ÿ-subtract : โˆ€{A B} โ†’ (b : ๐•Ÿ(B)) โ†’ (A < ๐•Ÿ-to-โ„•(b)) โ†’ ๐•Ÿ(๐’(A)) ๐•Ÿ-subtract {๐ŸŽ} {๐’ B} (๐’ b) [โ‰ค]-with-[๐’] = ๐ŸŽ ๐•Ÿ-subtract {๐’ A}{๐’ B} (๐’ b) ([โ‰ค]-with-[๐’] โฆƒ p โฆ„) = ๐’(๐•Ÿ-subtract {A}{B} b p) concat-when-lesser : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{n} โ†’ (na : ๐•Ÿ-to-โ„•(n) < a) โ†’ (concat af bf n โ‰ก Either.Left(af(๐•Ÿ-shrink n na))) concat-when-lesser {a = ๐’ a} {b} {af} {bf} {๐ŸŽ} [โ‰ค]-with-[๐’] = [โ‰ก]-intro concat-when-lesser {a = ๐’ a} {b} {af} {bf} {๐’ n} ([โ‰ค]-with-[๐’] โฆƒ p โฆ„) = concat-when-lesser {a = a} {b} {af โˆ˜ ๐’} {bf} {n} p {- open import Numeral.Natural.Relation.Order.Proofs concat-when-greater : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(๐’(b)) โ†’ B}{n} โ†’ (bn : ๐’(b) < ๐•Ÿ-to-โ„•(n)) โ†’ (concat af bf n โ‰ก Either.Right(bf(๐•Ÿ-subtract n ([โ‰ค]-predecessor bn)))) concat-when-greater {a = ๐ŸŽ} {๐’ b} {af} {bf} {๐’ n} [โ‰ค]-with-[๐’] = {!!} concat-when-greater {a = ๐’ a} {๐ŸŽ} {af} {bf} {๐’ n} ([โ‰ค]-with-[๐’] {y = y} โฆƒ p โฆ„) with n | ๐•Ÿ-to-โ„• n ... | ๐ŸŽ | ๐ŸŽ = {!concat-when-greater {a = a} {?} {af โˆ˜ ๐’} {bf} {๐ŸŽ}!} ... | ๐ŸŽ | ๐’ bb = {!!} ... | ๐’ aa | ๐ŸŽ = {!!} ... | ๐’ aa | ๐’ bb = {!!} concat-when-greater {a = ๐’ a} {๐’ b} {af} {bf} {๐’ n} ([โ‰ค]-with-[๐’] {y = _} โฆƒ p โฆ„) = {!concat-when-greater {a = a} {๐’ b} {af โˆ˜ ๐’} {bf} {n}!} open import Numeral.Natural.Relation.Order.Proofs bound-[โ‰ค]-of-refl : โˆ€{n}{x} โ†’ (bound-[โ‰ค] (reflexivity(_โ‰ค_) {n}) x โ‰ก x) bound-[โ‰ค]-of-refl {๐’ n} {๐ŸŽ} = [โ‰ก]-intro bound-[โ‰ค]-of-refl {๐’ n} {๐’ x} = [โ‰ก]-with(๐’) (bound-[โ‰ค]-of-refl {n}{x}) concat-surjective-left : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B}{x} โ†’ โฆƒ Surjective(af) โฆ„ โ†’ โˆƒ(n โ†ฆ concat af bf n โ‰ก Either.Left(x)) concat-surjective-left {a = ๐ŸŽ} {b} {af} {bf} {x} with () โ† [โˆƒ]-witness(surjective(af) {x}) concat-surjective-left {a = ๐’ a} {b} {af} {bf} {x} with [โˆƒ]-intro x โฆƒ q โฆ„ โ† [โ†”]-to-[โ†] (concat-when-left {a = ๐’ a}{b}{af}{bf}{{!!}}) {!!} = {!!} {-โˆƒ.witness (concat-surjective-left {a = a} {b} {af} {bf} {x}) = bound-[โ‰ค] ([โ‰ค]-of-[+]โ‚— {y = b}) ([โˆƒ]-witness(surjective(af) {x})) โˆƒ.proof (concat-surjective-left {a = ๐ŸŽ} {_} {af} {bf} {x}) with () โ† [โˆƒ]-witness(surjective(af) {x}) โˆƒ.proof (concat-surjective-left {a = ๐’ a} {๐ŸŽ} {af} {bf} {x}) rewrite bound-[โ‰ค]-of-refl {๐’ a}{[โˆƒ]-witness(surjective(af) {x})} with surjective(af) {x} ... | [โˆƒ]-intro ๐ŸŽ โฆƒ p โฆ„ = congruenceโ‚(Either.Left) p ... | [โˆƒ]-intro (๐’ c) โฆƒ p โฆ„ with [โˆƒ]-intro x โฆƒ q โฆ„ โ† [โ†”]-to-[โ†] (concat-when-left {a = ๐’ a}{๐ŸŽ}{af}{bf}{๐’ c}) {!!} = {!!} โˆƒ.proof (concat-surjective-left {a = ๐’ a} {๐’ b} {af} {bf} {x}) = {!!}-} -} interleave-join-equality : โˆ€{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B} โ†’ (interleave af bf โˆ˜ Interleaving.join โŠœ Either.map af bf) interleave-join-equality {a = a}{b = b} = intro(p{a = a}{b = b}) where p : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B} โ†’ (interleave af bf โˆ˜ Interleaving.join Names.โŠœ Either.map af bf) p {a = ๐ŸŽ} {b = ๐’ b} {af}{bf} {Either.Right n} = [โ‰ก]-intro p {a = ๐’ a}{b = ๐ŸŽ} {af}{bf} {Either.Left n} = [โ‰ก]-intro p {a = ๐’ a}{b = ๐’ b} {af}{bf} {Either.Left ๐ŸŽ} = [โ‰ก]-intro p {a = ๐’ a}{b = ๐’ b} {af}{bf} {Either.Right ๐ŸŽ} = [โ‰ก]-intro p {a = ๐’ a}{b = ๐’ b} {af}{bf} {Either.Left (๐’ n)} = p {a = a}{b = b} {af โˆ˜ ๐’}{bf โˆ˜ ๐’} {Either.Left n} p {a = ๐’ a}{b = ๐’ b} {af}{bf} {Either.Right (๐’ n)} = p {a = a}{b = b} {af โˆ˜ ๐’}{bf โˆ˜ ๐’} {Either.Right n} interleave-split-equality : โˆ€{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B} โ†’ (interleave af bf โŠœ Either.map af bf โˆ˜ Interleaving.split) interleave-split-equality {a = a}{b = b}{af = af}{bf = bf} = interleave af bf ๐Ÿ–[ _โŠœ_ ]-[] interleave af bf โˆ˜ id ๐Ÿ–[ _โŠœ_ ]-[ congruenceโ‚‚แตฃ(_โˆ˜_)(interleave af bf) (intro(inverseแตฃ(Interleaving.join{a}{b})(Interleaving.split{a}{b}))) ]-sym interleave af bf โˆ˜ Interleaving.join{a}{b} โˆ˜ Interleaving.split ๐Ÿ–[ _โŠœ_ ]-[ congruenceโ‚‚โ‚—(_โˆ˜_)(Interleaving.split) (interleave-join-equality{a = a}{b = b}{af = af}{bf = bf}) ] Either.map af bf โˆ˜ Interleaving.split ๐Ÿ–-end instance interleave-injective : โˆ€{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B} โ†’ โฆƒ Injective(af) โฆ„ โ†’ โฆƒ Injective(bf) โฆ„ โ†’ Injective(interleave af bf) interleave-injective {a = a}{b = b}{af = af}{bf = bf} = substituteโ‚โ‚—(Injective) (interleave-split-equality {af = af}{bf = bf}) ([โˆ˜]-injective {f = Either.map af bf}{g = Interleaving.split} โฆƒ inj-g = inverse-to-injective โฆƒ inver = [โˆง]-intro Interleaving.join-split-inverse Interleaving.split-join-inverse โฆ„ โฆ„) instance interleave-surjective : โˆ€{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B} โ†’ โฆƒ Surjective(af) โฆ„ โ†’ โฆƒ Surjective(bf) โฆ„ โ†’ Surjective(interleave af bf) interleave-surjective {a = a}{b = b}{af = af}{bf = bf} = substituteโ‚โ‚—(Surjective) (interleave-split-equality {af = af}{bf = bf}) ([โˆ˜]-surjective {f = Either.map af bf}{g = Interleaving.split} โฆƒ surj-g = inverse-to-surjective โฆƒ inver = [โˆง]-intro Interleaving.join-split-inverse Interleaving.split-join-inverse โฆ„ โฆ„) instance interleave-bijective : โˆ€{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B} โ†’ โฆƒ Bijective(af) โฆ„ โ†’ โฆƒ Bijective(bf) โฆ„ โ†’ Bijective(interleave af bf) interleave-bijective {a = a}{b = b}{af = af}{bf = bf} = substituteโ‚โ‚—(Bijective) (interleave-split-equality {af = af}{bf = bf}) ([โˆ˜]-bijective {f = Either.map af bf}{g = Interleaving.split} โฆƒ bij-g = inverse-to-bijective โฆƒ inver = [โˆง]-intro Interleaving.join-split-inverse Interleaving.split-join-inverse โฆ„ โฆ„) concat-split-equality : โˆ€{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B} โ†’ (concat af bf โŠœ Either.map af bf โˆ˜ Concatenation.split) concat-split-equality {a = a}{b = b} = intro(p{a = a}{b = b}) where p : โˆ€{a b}{af : ๐•Ÿ(a) โ†’ A}{bf : ๐•Ÿ(b) โ†’ B} โ†’ (concat af bf Names.โŠœ Either.map af bf โˆ˜ Concatenation.split) p {a = ๐ŸŽ} {b = ๐’ b} {af = af}{bf = bf} {n} = [โ‰ก]-intro p {a = ๐’ a} {b = ๐ŸŽ} {af = af}{bf = bf} {๐ŸŽ} = [โ‰ก]-intro p {a = ๐’(๐’ a)}{b = ๐ŸŽ} {af = af}{bf = bf} {๐’ n} = p{a = ๐’ a}{b = ๐ŸŽ}{af = af โˆ˜ ๐’}{bf = bf}{n} p {a = ๐’ a} {b = ๐’ b} {af = af}{bf = bf} {๐ŸŽ} = [โ‰ก]-intro p {a = ๐’ a} {b = ๐’ b} {af = af}{bf = bf} {๐’ n} with Concatenation.split {a}{๐’ b} n | p {a = a} {b = ๐’ b} {af = af โˆ˜ ๐’} {bf = bf} {n} ... | Either.Left _ | prev = prev ... | Either.Right _ | prev = prev -- TODO: It is possible to copy-paste the proofs of inj/surj/bijectivity with a few modifications from Interleaving and apply it to Concatenation -}
{ "alphanum_fraction": 0.545458603, "avg_line_length": 59.1160949868, "ext": "agda", "hexsha": "5f63700642e96422e84ef1ccc91a8926fcf86c58", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Finite/Sequence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Finite/Sequence.agda", "max_line_length": 315, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Finite/Sequence.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": 10753, "size": 22405 }
open import Agda.Primitive open import Data.Nat using (โ„•) data โˆ‘ {nโ‚ : Level} {nโ‚‚ : Level} (A : Set nโ‚) (P : A โ†’ Set nโ‚‚) : Set (nโ‚ โŠ” nโ‚‚) where sum : (a : A) โ†’ (pa : P a) โ†’ โˆ‘ A P data List {n : Level} (t : Set n) : Set n where _::_ : t โ†’ List t โ†’ List t [] : List t data Unit {n : Level} : Set n where ## : Unit heterohomo : List (โˆ‘ Set ฮป x โ†’ x) heterohomo = (sum โ„• 0) :: ((sum (List Unit) (## :: [])) :: ((sum Unit ##) :: []))
{ "alphanum_fraction": 0.509009009, "avg_line_length": 26.1176470588, "ext": "agda", "hexsha": "3b89cf673749db0105effb12bec508d4201f8fbb", "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": "ad7278cc2a5152fde242e9be5961ce907ab482a5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Mikotochan/csders", "max_forks_repo_path": "agda.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ad7278cc2a5152fde242e9be5961ce907ab482a5", "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": "Mikotochan/csders", "max_issues_repo_path": "agda.agda", "max_line_length": 84, "max_stars_count": null, "max_stars_repo_head_hexsha": "ad7278cc2a5152fde242e9be5961ce907ab482a5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Mikotochan/csders", "max_stars_repo_path": "agda.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 182, "size": 444 }
module AbsurdLam where data Nat : Set where zero : Nat suc : Nat -> Nat data Fin : Nat -> Set where fzero : forall {n} -> Fin (suc n) fsuc : forall {n} -> Fin n -> Fin (suc n) data False : Set where elimFalse : (A : Set) -> False -> A elimFalse A = \() data _==_ {A : Set}(x : A) : A -> Set where refl : x == x magic : forall {n} -> suc n == zero -> False magic = \() hidden : Nat -> {x : Fin zero} -> False hidden = \n {}
{ "alphanum_fraction": 0.546275395, "avg_line_length": 17.72, "ext": "agda", "hexsha": "929a6700aba010b175b48cec37955443fbe775f8", "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/AbsurdLam.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/AbsurdLam.agda", "max_line_length": 44, "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/AbsurdLam.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 156, "size": 443 }
module UnequalRelevance where postulate A : Set f : .A -> A g : (A -> A) -> A -> A -- this should fail because -- cannot use irrelevant function where relevant is needed h : A -> A h = g f -- error: function types are not equal because one is relevant and the other not
{ "alphanum_fraction": 0.6690647482, "avg_line_length": 25.2727272727, "ext": "agda", "hexsha": "889aa2ac638c0cbd9c371fdd99031cead9558260", "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": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/agda-kanso", "max_forks_repo_path": "test/fail/UnequalRelevance.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "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": "asr/agda-kanso", "max_issues_repo_path": "test/fail/UnequalRelevance.agda", "max_line_length": 89, "max_stars_count": null, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "test/fail/UnequalRelevance.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 79, "size": 278 }
{-# OPTIONS --rewriting #-} module Properties.TypeSaturation where open import Agda.Builtin.Equality using (_โ‰ก_; refl) open import FFI.Data.Either using (Either; Left; Right) open import Luau.Subtyping using (Tree; Language; ยฌLanguage; _<:_; _โ‰ฎ:_; witness; scalar; function; function-err; function-ok; function-okโ‚; function-okโ‚‚; scalar-function; _,_; never) open import Luau.Type using (Type; _โ‡’_; _โˆฉ_; _โˆช_; never; unknown) open import Luau.TypeNormalization using (_โˆฉโฟ_; _โˆชโฟ_) open import Luau.TypeSaturation using (_โ‹“_; _โ‹’_; _โˆฉแต˜_; _โˆฉโฑ_; โˆช-saturate; โˆฉ-saturate; saturate) open import Properties.Subtyping using (dec-language; language-comp; <:-impl-โЇ; <:-refl; <:-trans; <:-trans-โ‰ฎ:; <:-impl-ยฌโ‰ฎ: ; <:-never; <:-unknown; <:-function; <:-union; <:-โˆช-symm; <:-โˆช-left; <:-โˆช-right; <:-โˆช-lub; <:-โˆช-assocl; <:-โˆช-assocr; <:-intersect; <:-โˆฉ-symm; <:-โˆฉ-left; <:-โˆฉ-right; <:-โˆฉ-glb; โ‰ฎ:-function-left; โ‰ฎ:-function-right; <:-function-โˆฉ-โˆช; <:-function-โˆฉ-โˆฉ; <:-โˆฉ-assocl; <:-โˆฉ-assocr; โˆฉ-<:-โˆช; <:-โˆฉ-distl-โˆช; โˆฉ-distl-โˆช-<:; <:-โˆฉ-distr-โˆช; โˆฉ-distr-โˆช-<:) open import Properties.TypeNormalization using (Normal; FunType; _โ‡’_; _โˆฉ_; _โˆช_; never; unknown; normal-โˆชโฟ; normal-โˆฉโฟ; โˆชโฟ-<:-โˆช; โˆช-<:-โˆชโฟ; โˆฉโฟ-<:-โˆฉ; โˆฉ-<:-โˆฉโฟ) open import Properties.Contradiction using (CONTRADICTION) open import Properties.Functions using (_โˆ˜_) -- Saturation preserves normalization normal-โ‹’ : โˆ€ {F G} โ†’ FunType F โ†’ FunType G โ†’ FunType (F โ‹’ G) normal-โ‹’ (R โ‡’ S) (T โ‡’ U) = (normal-โˆฉโฟ R T) โ‡’ (normal-โˆฉโฟ S U) normal-โ‹’ (R โ‡’ S) (G โˆฉ H) = normal-โ‹’ (R โ‡’ S) G โˆฉ normal-โ‹’ (R โ‡’ S) H normal-โ‹’ (E โˆฉ F) G = normal-โ‹’ E G โˆฉ normal-โ‹’ F G normal-โ‹“ : โˆ€ {F G} โ†’ FunType F โ†’ FunType G โ†’ FunType (F โ‹“ G) normal-โ‹“ (R โ‡’ S) (T โ‡’ U) = (normal-โˆชโฟ R T) โ‡’ (normal-โˆชโฟ S U) normal-โ‹“ (R โ‡’ S) (G โˆฉ H) = normal-โ‹“ (R โ‡’ S) G โˆฉ normal-โ‹“ (R โ‡’ S) H normal-โ‹“ (E โˆฉ F) G = normal-โ‹“ E G โˆฉ normal-โ‹“ F G normal-โˆฉ-saturate : โˆ€ {F} โ†’ FunType F โ†’ FunType (โˆฉ-saturate F) normal-โˆฉ-saturate (S โ‡’ T) = S โ‡’ T normal-โˆฉ-saturate (F โˆฉ G) = (normal-โˆฉ-saturate F โˆฉ normal-โˆฉ-saturate G) โˆฉ normal-โ‹’ (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) normal-โˆช-saturate : โˆ€ {F} โ†’ FunType F โ†’ FunType (โˆช-saturate F) normal-โˆช-saturate (S โ‡’ T) = S โ‡’ T normal-โˆช-saturate (F โˆฉ G) = (normal-โˆช-saturate F โˆฉ normal-โˆช-saturate G) โˆฉ normal-โ‹“ (normal-โˆช-saturate F) (normal-โˆช-saturate G) normal-saturate : โˆ€ {F} โ†’ FunType F โ†’ FunType (saturate F) normal-saturate F = normal-โˆช-saturate (normal-โˆฉ-saturate F) -- Saturation resects subtyping โˆช-saturate-<: : โˆ€ {F} โ†’ FunType F โ†’ โˆช-saturate F <: F โˆช-saturate-<: (S โ‡’ T) = <:-refl โˆช-saturate-<: (F โˆฉ G) = <:-trans <:-โˆฉ-left (<:-intersect (โˆช-saturate-<: F) (โˆช-saturate-<: G)) โˆฉ-saturate-<: : โˆ€ {F} โ†’ FunType F โ†’ โˆฉ-saturate F <: F โˆฉ-saturate-<: (S โ‡’ T) = <:-refl โˆฉ-saturate-<: (F โˆฉ G) = <:-trans <:-โˆฉ-left (<:-intersect (โˆฉ-saturate-<: F) (โˆฉ-saturate-<: G)) saturate-<: : โˆ€ {F} โ†’ FunType F โ†’ saturate F <: F saturate-<: F = <:-trans (โˆช-saturate-<: (normal-โˆฉ-saturate F)) (โˆฉ-saturate-<: F) โˆฉ-<:-โ‹“ : โˆ€ {F G} โ†’ FunType F โ†’ FunType G โ†’ (F โˆฉ G) <: (F โ‹“ G) โˆฉ-<:-โ‹“ (R โ‡’ S) (T โ‡’ U) = <:-trans <:-function-โˆฉ-โˆช (<:-function (โˆชโฟ-<:-โˆช R T) (โˆช-<:-โˆชโฟ S U)) โˆฉ-<:-โ‹“ (R โ‡’ S) (G โˆฉ H) = <:-trans (<:-โˆฉ-glb (<:-intersect <:-refl <:-โˆฉ-left) (<:-intersect <:-refl <:-โˆฉ-right)) (<:-intersect (โˆฉ-<:-โ‹“ (R โ‡’ S) G) (โˆฉ-<:-โ‹“ (R โ‡’ S) H)) โˆฉ-<:-โ‹“ (E โˆฉ F) G = <:-trans (<:-โˆฉ-glb (<:-intersect <:-โˆฉ-left <:-refl) (<:-intersect <:-โˆฉ-right <:-refl)) (<:-intersect (โˆฉ-<:-โ‹“ E G) (โˆฉ-<:-โ‹“ F G)) โˆฉ-<:-โ‹’ : โˆ€ {F G} โ†’ FunType F โ†’ FunType G โ†’ (F โˆฉ G) <: (F โ‹’ G) โˆฉ-<:-โ‹’ (R โ‡’ S) (T โ‡’ U) = <:-trans <:-function-โˆฉ-โˆฉ (<:-function (โˆฉโฟ-<:-โˆฉ R T) (โˆฉ-<:-โˆฉโฟ S U)) โˆฉ-<:-โ‹’ (R โ‡’ S) (G โˆฉ H) = <:-trans (<:-โˆฉ-glb (<:-intersect <:-refl <:-โˆฉ-left) (<:-intersect <:-refl <:-โˆฉ-right)) (<:-intersect (โˆฉ-<:-โ‹’ (R โ‡’ S) G) (โˆฉ-<:-โ‹’ (R โ‡’ S) H)) โˆฉ-<:-โ‹’ (E โˆฉ F) G = <:-trans (<:-โˆฉ-glb (<:-intersect <:-โˆฉ-left <:-refl) (<:-intersect <:-โˆฉ-right <:-refl)) (<:-intersect (โˆฉ-<:-โ‹’ E G) (โˆฉ-<:-โ‹’ F G)) <:-โˆช-saturate : โˆ€ {F} โ†’ FunType F โ†’ F <: โˆช-saturate F <:-โˆช-saturate (S โ‡’ T) = <:-refl <:-โˆช-saturate (F โˆฉ G) = <:-โˆฉ-glb (<:-intersect (<:-โˆช-saturate F) (<:-โˆช-saturate G)) (<:-trans (<:-intersect (<:-โˆช-saturate F) (<:-โˆช-saturate G)) (โˆฉ-<:-โ‹“ (normal-โˆช-saturate F) (normal-โˆช-saturate G))) <:-โˆฉ-saturate : โˆ€ {F} โ†’ FunType F โ†’ F <: โˆฉ-saturate F <:-โˆฉ-saturate (S โ‡’ T) = <:-refl <:-โˆฉ-saturate (F โˆฉ G) = <:-โˆฉ-glb (<:-intersect (<:-โˆฉ-saturate F) (<:-โˆฉ-saturate G)) (<:-trans (<:-intersect (<:-โˆฉ-saturate F) (<:-โˆฉ-saturate G)) (โˆฉ-<:-โ‹’ (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G))) <:-saturate : โˆ€ {F} โ†’ FunType F โ†’ F <: saturate F <:-saturate F = <:-trans (<:-โˆฉ-saturate F) (<:-โˆช-saturate (normal-โˆฉ-saturate F)) -- Overloads F is the set of overloads of F data Overloads : Type โ†’ Type โ†’ Set where here : โˆ€ {S T} โ†’ Overloads (S โ‡’ T) (S โ‡’ T) left : โˆ€ {S T F G} โ†’ Overloads F (S โ‡’ T) โ†’ Overloads (F โˆฉ G) (S โ‡’ T) right : โˆ€ {S T F G} โ†’ Overloads G (S โ‡’ T) โ†’ Overloads (F โˆฉ G) (S โ‡’ T) normal-overload-src : โˆ€ {F S T} โ†’ FunType F โ†’ Overloads F (S โ‡’ T) โ†’ Normal S normal-overload-src (S โ‡’ T) here = S normal-overload-src (F โˆฉ G) (left o) = normal-overload-src F o normal-overload-src (F โˆฉ G) (right o) = normal-overload-src G o normal-overload-tgt : โˆ€ {F S T} โ†’ FunType F โ†’ Overloads F (S โ‡’ T) โ†’ Normal T normal-overload-tgt (S โ‡’ T) here = T normal-overload-tgt (F โˆฉ G) (left o) = normal-overload-tgt F o normal-overload-tgt (F โˆฉ G) (right o) = normal-overload-tgt G o -- An inductive presentation of the overloads of F โ‹“ G data โˆช-Lift (P Q : Type โ†’ Set) : Type โ†’ Set where union : โˆ€ {R S T U} โ†’ P (R โ‡’ S) โ†’ Q (T โ‡’ U) โ†’ -------------------- โˆช-Lift P Q ((R โˆช T) โ‡’ (S โˆช U)) -- An inductive presentation of the overloads of F โ‹’ G data โˆฉ-Lift (P Q : Type โ†’ Set) : Type โ†’ Set where intersect : โˆ€ {R S T U} โ†’ P (R โ‡’ S) โ†’ Q (T โ‡’ U) โ†’ -------------------- โˆฉ-Lift P Q ((R โˆฉ T) โ‡’ (S โˆฉ U)) -- An inductive presentation of the overloads of โˆช-saturate F data โˆช-Saturate (P : Type โ†’ Set) : Type โ†’ Set where base : โˆ€ {S T} โ†’ P (S โ‡’ T) โ†’ -------------------- โˆช-Saturate P (S โ‡’ T) union : โˆ€ {R S T U} โ†’ โˆช-Saturate P (R โ‡’ S) โ†’ โˆช-Saturate P (T โ‡’ U) โ†’ -------------------- โˆช-Saturate P ((R โˆช T) โ‡’ (S โˆช U)) -- An inductive presentation of the overloads of โˆฉ-saturate F data โˆฉ-Saturate (P : Type โ†’ Set) : Type โ†’ Set where base : โˆ€ {S T} โ†’ P (S โ‡’ T) โ†’ -------------------- โˆฉ-Saturate P (S โ‡’ T) intersect : โˆ€ {R S T U} โ†’ โˆฉ-Saturate P (R โ‡’ S) โ†’ โˆฉ-Saturate P (T โ‡’ U) โ†’ -------------------- โˆฉ-Saturate P ((R โˆฉ T) โ‡’ (S โˆฉ U)) -- The <:-up-closure of a set of function types data <:-Close (P : Type โ†’ Set) : Type โ†’ Set where defn : โˆ€ {R S T U} โ†’ P (S โ‡’ T) โ†’ R <: S โ†’ T <: U โ†’ ------------------ <:-Close P (R โ‡’ U) -- F โІแต’ G whenever every overload of F is an overload of G _โІแต’_ : Type โ†’ Type โ†’ Set F โІแต’ G = โˆ€ {S T} โ†’ Overloads F (S โ‡’ T) โ†’ Overloads G (S โ‡’ T) -- F <:แต’ G when every overload of G is a supertype of an overload of F _<:แต’_ : Type โ†’ Type โ†’ Set _<:แต’_ F G = โˆ€ {S T} โ†’ Overloads G (S โ‡’ T) โ†’ <:-Close (Overloads F) (S โ‡’ T) -- P โŠ‚: Q when any type in P is a subtype of some type in Q _โŠ‚:_ : (Type โ†’ Set) โ†’ (Type โ†’ Set) โ†’ Set P โŠ‚: Q = โˆ€ {S T} โ†’ P (S โ‡’ T) โ†’ <:-Close Q (S โ‡’ T) -- <:-Close is a monad just : โˆ€ {P S T} โ†’ P (S โ‡’ T) โ†’ <:-Close P (S โ‡’ T) just p = defn p <:-refl <:-refl infixl 5 _>>=_ _>>=หก_ _>>=สณ_ _>>=_ : โˆ€ {P Q S T} โ†’ <:-Close P (S โ‡’ T) โ†’ (P โŠ‚: Q) โ†’ <:-Close Q (S โ‡’ T) (defn p pโ‚ pโ‚‚) >>= PโŠ‚Q with PโŠ‚Q p (defn p pโ‚ pโ‚‚) >>= PโŠ‚Q | defn q qโ‚ qโ‚‚ = defn q (<:-trans pโ‚ qโ‚) (<:-trans qโ‚‚ pโ‚‚) _>>=หก_ : โˆ€ {P R S T} โ†’ <:-Close P (S โ‡’ T) โ†’ (R <: S) โ†’ <:-Close P (R โ‡’ T) (defn p pโ‚ pโ‚‚) >>=หก q = defn p (<:-trans q pโ‚) pโ‚‚ _>>=สณ_ : โˆ€ {P S T U} โ†’ <:-Close P (S โ‡’ T) โ†’ (T <: U) โ†’ <:-Close P (S โ‡’ U) (defn p pโ‚ pโ‚‚) >>=สณ q = defn p pโ‚ (<:-trans pโ‚‚ q) -- Properties of โŠ‚: โŠ‚:-refl : โˆ€ {P} โ†’ P โŠ‚: P โŠ‚:-refl p = just p _[โˆช]_ : โˆ€ {P Q R S T U} โ†’ <:-Close P (R โ‡’ S) โ†’ <:-Close Q (T โ‡’ U) โ†’ <:-Close (โˆช-Lift P Q) ((R โˆช T) โ‡’ (S โˆช U)) (defn p pโ‚ pโ‚‚) [โˆช] (defn q qโ‚ qโ‚‚) = defn (union p q) (<:-union pโ‚ qโ‚) (<:-union pโ‚‚ qโ‚‚) _[โˆฉ]_ : โˆ€ {P Q R S T U} โ†’ <:-Close P (R โ‡’ S) โ†’ <:-Close Q (T โ‡’ U) โ†’ <:-Close (โˆฉ-Lift P Q) ((R โˆฉ T) โ‡’ (S โˆฉ U)) (defn p pโ‚ pโ‚‚) [โˆฉ] (defn q qโ‚ qโ‚‚) = defn (intersect p q) (<:-intersect pโ‚ qโ‚) (<:-intersect pโ‚‚ qโ‚‚) โŠ‚:-โˆฉ-saturate-inj : โˆ€ {P} โ†’ P โŠ‚: โˆฉ-Saturate P โŠ‚:-โˆฉ-saturate-inj p = defn (base p) <:-refl <:-refl โŠ‚:-โˆช-saturate-inj : โˆ€ {P} โ†’ P โŠ‚: โˆช-Saturate P โŠ‚:-โˆช-saturate-inj p = just (base p) โŠ‚:-โˆฉ-lift-saturate : โˆ€ {P} โ†’ โˆฉ-Lift (โˆฉ-Saturate P) (โˆฉ-Saturate P) โŠ‚: โˆฉ-Saturate P โŠ‚:-โˆฉ-lift-saturate (intersect p q) = just (intersect p q) โŠ‚:-โˆช-lift-saturate : โˆ€ {P} โ†’ โˆช-Lift (โˆช-Saturate P) (โˆช-Saturate P) โŠ‚: โˆช-Saturate P โŠ‚:-โˆช-lift-saturate (union p q) = just (union p q) โŠ‚:-โˆฉ-lift : โˆ€ {P Q R S} โ†’ (P โŠ‚: Q) โ†’ (R โŠ‚: S) โ†’ (โˆฉ-Lift P R โŠ‚: โˆฉ-Lift Q S) โŠ‚:-โˆฉ-lift PโŠ‚Q RโŠ‚S (intersect n o) = PโŠ‚Q n [โˆฉ] RโŠ‚S o โŠ‚:-โˆช-lift : โˆ€ {P Q R S} โ†’ (P โŠ‚: Q) โ†’ (R โŠ‚: S) โ†’ (โˆช-Lift P R โŠ‚: โˆช-Lift Q S) โŠ‚:-โˆช-lift PโŠ‚Q RโŠ‚S (union n o) = PโŠ‚Q n [โˆช] RโŠ‚S o โŠ‚:-โˆฉ-saturate : โˆ€ {P Q} โ†’ (P โŠ‚: Q) โ†’ (โˆฉ-Saturate P โŠ‚: โˆฉ-Saturate Q) โŠ‚:-โˆฉ-saturate PโŠ‚Q (base p) = PโŠ‚Q p >>= โŠ‚:-โˆฉ-saturate-inj โŠ‚:-โˆฉ-saturate PโŠ‚Q (intersect p q) = (โŠ‚:-โˆฉ-saturate PโŠ‚Q p [โˆฉ] โŠ‚:-โˆฉ-saturate PโŠ‚Q q) >>= โŠ‚:-โˆฉ-lift-saturate โŠ‚:-โˆช-saturate : โˆ€ {P Q} โ†’ (P โŠ‚: Q) โ†’ (โˆช-Saturate P โŠ‚: โˆช-Saturate Q) โŠ‚:-โˆช-saturate PโŠ‚Q (base p) = PโŠ‚Q p >>= โŠ‚:-โˆช-saturate-inj โŠ‚:-โˆช-saturate PโŠ‚Q (union p q) = (โŠ‚:-โˆช-saturate PโŠ‚Q p [โˆช] โŠ‚:-โˆช-saturate PโŠ‚Q q) >>= โŠ‚:-โˆช-lift-saturate โŠ‚:-โˆฉ-saturate-indn : โˆ€ {P Q} โ†’ (P โŠ‚: Q) โ†’ (โˆฉ-Lift Q Q โŠ‚: Q) โ†’ (โˆฉ-Saturate P โŠ‚: Q) โŠ‚:-โˆฉ-saturate-indn PโŠ‚Q QQโŠ‚Q (base p) = PโŠ‚Q p โŠ‚:-โˆฉ-saturate-indn PโŠ‚Q QQโŠ‚Q (intersect p q) = (โŠ‚:-โˆฉ-saturate-indn PโŠ‚Q QQโŠ‚Q p [โˆฉ] โŠ‚:-โˆฉ-saturate-indn PโŠ‚Q QQโŠ‚Q q) >>= QQโŠ‚Q โŠ‚:-โˆช-saturate-indn : โˆ€ {P Q} โ†’ (P โŠ‚: Q) โ†’ (โˆช-Lift Q Q โŠ‚: Q) โ†’ (โˆช-Saturate P โŠ‚: Q) โŠ‚:-โˆช-saturate-indn PโŠ‚Q QQโŠ‚Q (base p) = PโŠ‚Q p โŠ‚:-โˆช-saturate-indn PโŠ‚Q QQโŠ‚Q (union p q) = (โŠ‚:-โˆช-saturate-indn PโŠ‚Q QQโŠ‚Q p [โˆช] โŠ‚:-โˆช-saturate-indn PโŠ‚Q QQโŠ‚Q q) >>= QQโŠ‚Q โˆช-saturate-resp-โˆฉ-saturation : โˆ€ {P} โ†’ (โˆฉ-Lift P P โŠ‚: P) โ†’ (โˆฉ-Lift (โˆช-Saturate P) (โˆช-Saturate P) โŠ‚: โˆช-Saturate P) โˆช-saturate-resp-โˆฉ-saturation โˆฉPโŠ‚P (intersect (base p) (base q)) = โˆฉPโŠ‚P (intersect p q) >>= โŠ‚:-โˆช-saturate-inj โˆช-saturate-resp-โˆฉ-saturation โˆฉPโŠ‚P (intersect p (union q qโ‚)) = (โˆช-saturate-resp-โˆฉ-saturation โˆฉPโŠ‚P (intersect p q) [โˆช] โˆช-saturate-resp-โˆฉ-saturation โˆฉPโŠ‚P (intersect p qโ‚)) >>= โŠ‚:-โˆช-lift-saturate >>=หก <:-โˆฉ-distl-โˆช >>=สณ โˆฉ-distl-โˆช-<: โˆช-saturate-resp-โˆฉ-saturation โˆฉPโŠ‚P (intersect (union p pโ‚) q) = (โˆช-saturate-resp-โˆฉ-saturation โˆฉPโŠ‚P (intersect p q) [โˆช] โˆช-saturate-resp-โˆฉ-saturation โˆฉPโŠ‚P (intersect pโ‚ q)) >>= โŠ‚:-โˆช-lift-saturate >>=หก <:-โˆฉ-distr-โˆช >>=สณ โˆฉ-distr-โˆช-<: ov-language : โˆ€ {F t} โ†’ FunType F โ†’ (โˆ€ {S T} โ†’ Overloads F (S โ‡’ T) โ†’ Language (S โ‡’ T) t) โ†’ Language F t ov-language (S โ‡’ T) p = p here ov-language (F โˆฉ G) p = (ov-language F (p โˆ˜ left) , ov-language G (p โˆ˜ right)) ov-<: : โˆ€ {F R S T U} โ†’ FunType F โ†’ Overloads F (R โ‡’ S) โ†’ ((R โ‡’ S) <: (T โ‡’ U)) โ†’ F <: (T โ‡’ U) ov-<: F here p = p ov-<: (F โˆฉ G) (left o) p = <:-trans <:-โˆฉ-left (ov-<: F o p) ov-<: (F โˆฉ G) (right o) p = <:-trans <:-โˆฉ-right (ov-<: G o p) <:แต’-impl-<: : โˆ€ {F G} โ†’ FunType F โ†’ FunType G โ†’ (F <:แต’ G) โ†’ (F <: G) <:แต’-impl-<: F (T โ‡’ U) F<G with F<G here <:แต’-impl-<: F (T โ‡’ U) F<G | defn o oโ‚ oโ‚‚ = ov-<: F o (<:-function oโ‚ oโ‚‚) <:แต’-impl-<: F (G โˆฉ H) F<G = <:-โˆฉ-glb (<:แต’-impl-<: F G (F<G โˆ˜ left)) (<:แต’-impl-<: F H (F<G โˆ˜ right)) โŠ‚:-overloads-left : โˆ€ {F G} โ†’ Overloads F โŠ‚: Overloads (F โˆฉ G) โŠ‚:-overloads-left p = just (left p) โŠ‚:-overloads-right : โˆ€ {F G} โ†’ Overloads G โŠ‚: Overloads (F โˆฉ G) โŠ‚:-overloads-right p = just (right p) โŠ‚:-overloads-โ‹’ : โˆ€ {F G} โ†’ FunType F โ†’ FunType G โ†’ โˆฉ-Lift (Overloads F) (Overloads G) โŠ‚: Overloads (F โ‹’ G) โŠ‚:-overloads-โ‹’ (R โ‡’ S) (T โ‡’ U) (intersect here here) = defn here (โˆฉ-<:-โˆฉโฟ R T) (โˆฉโฟ-<:-โˆฉ S U) โŠ‚:-overloads-โ‹’ (R โ‡’ S) (G โˆฉ H) (intersect here (left o)) = โŠ‚:-overloads-โ‹’ (R โ‡’ S) G (intersect here o) >>= โŠ‚:-overloads-left โŠ‚:-overloads-โ‹’ (R โ‡’ S) (G โˆฉ H) (intersect here (right o)) = โŠ‚:-overloads-โ‹’ (R โ‡’ S) H (intersect here o) >>= โŠ‚:-overloads-right โŠ‚:-overloads-โ‹’ (E โˆฉ F) G (intersect (left n) o) = โŠ‚:-overloads-โ‹’ E G (intersect n o) >>= โŠ‚:-overloads-left โŠ‚:-overloads-โ‹’ (E โˆฉ F) G (intersect (right n) o) = โŠ‚:-overloads-โ‹’ F G (intersect n o) >>= โŠ‚:-overloads-right โŠ‚:-โ‹’-overloads : โˆ€ {F G} โ†’ FunType F โ†’ FunType G โ†’ Overloads (F โ‹’ G) โŠ‚: โˆฉ-Lift (Overloads F) (Overloads G) โŠ‚:-โ‹’-overloads (R โ‡’ S) (T โ‡’ U) here = defn (intersect here here) (โˆฉโฟ-<:-โˆฉ R T) (โˆฉ-<:-โˆฉโฟ S U) โŠ‚:-โ‹’-overloads (R โ‡’ S) (G โˆฉ H) (left o) = โŠ‚:-โ‹’-overloads (R โ‡’ S) G o >>= โŠ‚:-โˆฉ-lift โŠ‚:-refl โŠ‚:-overloads-left โŠ‚:-โ‹’-overloads (R โ‡’ S) (G โˆฉ H) (right o) = โŠ‚:-โ‹’-overloads (R โ‡’ S) H o >>= โŠ‚:-โˆฉ-lift โŠ‚:-refl โŠ‚:-overloads-right โŠ‚:-โ‹’-overloads (E โˆฉ F) G (left o) = โŠ‚:-โ‹’-overloads E G o >>= โŠ‚:-โˆฉ-lift โŠ‚:-overloads-left โŠ‚:-refl โŠ‚:-โ‹’-overloads (E โˆฉ F) G (right o) = โŠ‚:-โ‹’-overloads F G o >>= โŠ‚:-โˆฉ-lift โŠ‚:-overloads-right โŠ‚:-refl โŠ‚:-overloads-โ‹“ : โˆ€ {F G} โ†’ FunType F โ†’ FunType G โ†’ โˆช-Lift (Overloads F) (Overloads G) โŠ‚: Overloads (F โ‹“ G) โŠ‚:-overloads-โ‹“ (R โ‡’ S) (T โ‡’ U) (union here here) = defn here (โˆช-<:-โˆชโฟ R T) (โˆชโฟ-<:-โˆช S U) โŠ‚:-overloads-โ‹“ (R โ‡’ S) (G โˆฉ H) (union here (left o)) = โŠ‚:-overloads-โ‹“ (R โ‡’ S) G (union here o) >>= โŠ‚:-overloads-left โŠ‚:-overloads-โ‹“ (R โ‡’ S) (G โˆฉ H) (union here (right o)) = โŠ‚:-overloads-โ‹“ (R โ‡’ S) H (union here o) >>= โŠ‚:-overloads-right โŠ‚:-overloads-โ‹“ (E โˆฉ F) G (union (left n) o) = โŠ‚:-overloads-โ‹“ E G (union n o) >>= โŠ‚:-overloads-left โŠ‚:-overloads-โ‹“ (E โˆฉ F) G (union (right n) o) = โŠ‚:-overloads-โ‹“ F G (union n o) >>= โŠ‚:-overloads-right โŠ‚:-โ‹“-overloads : โˆ€ {F G} โ†’ FunType F โ†’ FunType G โ†’ Overloads (F โ‹“ G) โŠ‚: โˆช-Lift (Overloads F) (Overloads G) โŠ‚:-โ‹“-overloads (R โ‡’ S) (T โ‡’ U) here = defn (union here here) (โˆชโฟ-<:-โˆช R T) (โˆช-<:-โˆชโฟ S U) โŠ‚:-โ‹“-overloads (R โ‡’ S) (G โˆฉ H) (left o) = โŠ‚:-โ‹“-overloads (R โ‡’ S) G o >>= โŠ‚:-โˆช-lift โŠ‚:-refl โŠ‚:-overloads-left โŠ‚:-โ‹“-overloads (R โ‡’ S) (G โˆฉ H) (right o) = โŠ‚:-โ‹“-overloads (R โ‡’ S) H o >>= โŠ‚:-โˆช-lift โŠ‚:-refl โŠ‚:-overloads-right โŠ‚:-โ‹“-overloads (E โˆฉ F) G (left o) = โŠ‚:-โ‹“-overloads E G o >>= โŠ‚:-โˆช-lift โŠ‚:-overloads-left โŠ‚:-refl โŠ‚:-โ‹“-overloads (E โˆฉ F) G (right o) = โŠ‚:-โ‹“-overloads F G o >>= โŠ‚:-โˆช-lift โŠ‚:-overloads-right โŠ‚:-refl โˆช-saturate-overloads : โˆ€ {F} โ†’ FunType F โ†’ Overloads (โˆช-saturate F) โŠ‚: โˆช-Saturate (Overloads F) โˆช-saturate-overloads (S โ‡’ T) here = just (base here) โˆช-saturate-overloads (F โˆฉ G) (left (left o)) = โˆช-saturate-overloads F o >>= โŠ‚:-โˆช-saturate โŠ‚:-overloads-left โˆช-saturate-overloads (F โˆฉ G) (left (right o)) = โˆช-saturate-overloads G o >>= โŠ‚:-โˆช-saturate โŠ‚:-overloads-right โˆช-saturate-overloads (F โˆฉ G) (right o) = โŠ‚:-โ‹“-overloads (normal-โˆช-saturate F) (normal-โˆช-saturate G) o >>= โŠ‚:-โˆช-lift (โˆช-saturate-overloads F) (โˆช-saturate-overloads G) >>= โŠ‚:-โˆช-lift (โŠ‚:-โˆช-saturate โŠ‚:-overloads-left) (โŠ‚:-โˆช-saturate โŠ‚:-overloads-right) >>= โŠ‚:-โˆช-lift-saturate overloads-โˆช-saturate : โˆ€ {F} โ†’ FunType F โ†’ โˆช-Saturate (Overloads F) โŠ‚: Overloads (โˆช-saturate F) overloads-โˆช-saturate F = โŠ‚:-โˆช-saturate-indn (inj F) (step F) where inj : โˆ€ {F} โ†’ FunType F โ†’ Overloads F โŠ‚: Overloads (โˆช-saturate F) inj (S โ‡’ T) here = just here inj (F โˆฉ G) (left p) = inj F p >>= โŠ‚:-overloads-left >>= โŠ‚:-overloads-left inj (F โˆฉ G) (right p) = inj G p >>= โŠ‚:-overloads-right >>= โŠ‚:-overloads-left step : โˆ€ {F} โ†’ FunType F โ†’ โˆช-Lift (Overloads (โˆช-saturate F)) (Overloads (โˆช-saturate F)) โŠ‚: Overloads (โˆช-saturate F) step (S โ‡’ T) (union here here) = defn here (<:-โˆช-lub <:-refl <:-refl) <:-โˆช-left step (F โˆฉ G) (union (left (left p)) (left (left q))) = step F (union p q) >>= โŠ‚:-overloads-left >>= โŠ‚:-overloads-left step (F โˆฉ G) (union (left (left p)) (left (right q))) = โŠ‚:-overloads-โ‹“ (normal-โˆช-saturate F) (normal-โˆช-saturate G) (union p q) >>= โŠ‚:-overloads-right step (F โˆฉ G) (union (left (right p)) (left (left q))) = โŠ‚:-overloads-โ‹“ (normal-โˆช-saturate F) (normal-โˆช-saturate G) (union q p) >>= โŠ‚:-overloads-right >>=หก <:-โˆช-symm >>=สณ <:-โˆช-symm step (F โˆฉ G) (union (left (right p)) (left (right q))) = step G (union p q) >>= โŠ‚:-overloads-right >>= โŠ‚:-overloads-left step (F โˆฉ G) (union p (right q)) with โŠ‚:-โ‹“-overloads (normal-โˆช-saturate F) (normal-โˆช-saturate G) q step (F โˆฉ G) (union (left (left p)) (right q)) | defn (union qโ‚ qโ‚‚) qโ‚ƒ qโ‚„ = (step F (union p qโ‚) [โˆช] just qโ‚‚) >>= โŠ‚:-overloads-โ‹“ (normal-โˆช-saturate F) (normal-โˆช-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-union <:-refl qโ‚ƒ) <:-โˆช-assocl >>=สณ <:-trans <:-โˆช-assocr (<:-union <:-refl qโ‚„) step (F โˆฉ G) (union (left (right p)) (right q)) | defn (union qโ‚ qโ‚‚) qโ‚ƒ qโ‚„ = (just qโ‚ [โˆช] step G (union p qโ‚‚)) >>= โŠ‚:-overloads-โ‹“ (normal-โˆช-saturate F) (normal-โˆช-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-union <:-refl qโ‚ƒ) (<:-โˆช-lub (<:-trans <:-โˆช-left <:-โˆช-right) (<:-โˆช-lub <:-โˆช-left (<:-trans <:-โˆช-right <:-โˆช-right))) >>=สณ <:-trans (<:-โˆช-lub (<:-trans <:-โˆช-left <:-โˆช-right) (<:-โˆช-lub <:-โˆช-left (<:-trans <:-โˆช-right <:-โˆช-right))) (<:-union <:-refl qโ‚„) step (F โˆฉ G) (union (right p) (right q)) | defn (union qโ‚ qโ‚‚) qโ‚ƒ qโ‚„ with โŠ‚:-โ‹“-overloads (normal-โˆช-saturate F) (normal-โˆช-saturate G) p step (F โˆฉ G) (union (right p) (right q)) | defn (union qโ‚ qโ‚‚) qโ‚ƒ qโ‚„ | defn (union pโ‚ pโ‚‚) pโ‚ƒ pโ‚„ = (step F (union pโ‚ qโ‚) [โˆช] step G (union pโ‚‚ qโ‚‚)) >>= โŠ‚:-overloads-โ‹“ (normal-โˆช-saturate F) (normal-โˆช-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-union pโ‚ƒ qโ‚ƒ) (<:-โˆช-lub (<:-union <:-โˆช-left <:-โˆช-left) (<:-union <:-โˆช-right <:-โˆช-right)) >>=สณ <:-trans (<:-โˆช-lub (<:-union <:-โˆช-left <:-โˆช-left) (<:-union <:-โˆช-right <:-โˆช-right)) (<:-union pโ‚„ qโ‚„) step (F โˆฉ G) (union (right p) q) with โŠ‚:-โ‹“-overloads (normal-โˆช-saturate F) (normal-โˆช-saturate G) p step (F โˆฉ G) (union (right p) (left (left q))) | defn (union pโ‚ pโ‚‚) pโ‚ƒ pโ‚„ = (step F (union pโ‚ q) [โˆช] just pโ‚‚) >>= โŠ‚:-overloads-โ‹“ (normal-โˆช-saturate F) (normal-โˆช-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-union pโ‚ƒ <:-refl) (<:-โˆช-lub (<:-union <:-โˆช-left <:-refl) (<:-trans <:-โˆช-right <:-โˆช-left)) >>=สณ <:-trans (<:-โˆช-lub (<:-union <:-โˆช-left <:-refl) (<:-trans <:-โˆช-right <:-โˆช-left)) (<:-union pโ‚„ <:-refl) step (F โˆฉ G) (union (right p) (left (right q))) | defn (union pโ‚ pโ‚‚) pโ‚ƒ pโ‚„ = (just pโ‚ [โˆช] step G (union pโ‚‚ q)) >>= โŠ‚:-overloads-โ‹“ (normal-โˆช-saturate F) (normal-โˆช-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-union pโ‚ƒ <:-refl) <:-โˆช-assocr >>=สณ <:-trans <:-โˆช-assocl (<:-union pโ‚„ <:-refl) step (F โˆฉ G) (union (right p) (right q)) | defn (union pโ‚ pโ‚‚) pโ‚ƒ pโ‚„ with โŠ‚:-โ‹“-overloads (normal-โˆช-saturate F) (normal-โˆช-saturate G) q step (F โˆฉ G) (union (right p) (right q)) | defn (union pโ‚ pโ‚‚) pโ‚ƒ pโ‚„ | defn (union qโ‚ qโ‚‚) qโ‚ƒ qโ‚„ = (step F (union pโ‚ qโ‚) [โˆช] step G (union pโ‚‚ qโ‚‚)) >>= โŠ‚:-overloads-โ‹“ (normal-โˆช-saturate F) (normal-โˆช-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-union pโ‚ƒ qโ‚ƒ) (<:-โˆช-lub (<:-union <:-โˆช-left <:-โˆช-left) (<:-union <:-โˆช-right <:-โˆช-right)) >>=สณ <:-trans (<:-โˆช-lub (<:-union <:-โˆช-left <:-โˆช-left) (<:-union <:-โˆช-right <:-โˆช-right)) (<:-union pโ‚„ qโ‚„) โˆช-saturated : โˆ€ {F} โ†’ FunType F โ†’ โˆช-Lift (Overloads (โˆช-saturate F)) (Overloads (โˆช-saturate F)) โŠ‚: Overloads (โˆช-saturate F) โˆช-saturated F o = โŠ‚:-โˆช-lift (โˆช-saturate-overloads F) (โˆช-saturate-overloads F) o >>= โŠ‚:-โˆช-lift-saturate >>= overloads-โˆช-saturate F โˆฉ-saturate-overloads : โˆ€ {F} โ†’ FunType F โ†’ Overloads (โˆฉ-saturate F) โŠ‚: โˆฉ-Saturate (Overloads F) โˆฉ-saturate-overloads (S โ‡’ T) here = just (base here) โˆฉ-saturate-overloads (F โˆฉ G) (left (left o)) = โˆฉ-saturate-overloads F o >>= โŠ‚:-โˆฉ-saturate โŠ‚:-overloads-left โˆฉ-saturate-overloads (F โˆฉ G) (left (right o)) = โˆฉ-saturate-overloads G o >>= โŠ‚:-โˆฉ-saturate โŠ‚:-overloads-right โˆฉ-saturate-overloads (F โˆฉ G) (right o) = โŠ‚:-โ‹’-overloads (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) o >>= โŠ‚:-โˆฉ-lift (โˆฉ-saturate-overloads F) (โˆฉ-saturate-overloads G) >>= โŠ‚:-โˆฉ-lift (โŠ‚:-โˆฉ-saturate โŠ‚:-overloads-left) (โŠ‚:-โˆฉ-saturate โŠ‚:-overloads-right) >>= โŠ‚:-โˆฉ-lift-saturate overloads-โˆฉ-saturate : โˆ€ {F} โ†’ FunType F โ†’ โˆฉ-Saturate (Overloads F) โŠ‚: Overloads (โˆฉ-saturate F) overloads-โˆฉ-saturate F = โŠ‚:-โˆฉ-saturate-indn (inj F) (step F) where inj : โˆ€ {F} โ†’ FunType F โ†’ Overloads F โŠ‚: Overloads (โˆฉ-saturate F) inj (S โ‡’ T) here = just here inj (F โˆฉ G) (left p) = inj F p >>= โŠ‚:-overloads-left >>= โŠ‚:-overloads-left inj (F โˆฉ G) (right p) = inj G p >>= โŠ‚:-overloads-right >>= โŠ‚:-overloads-left step : โˆ€ {F} โ†’ FunType F โ†’ โˆฉ-Lift (Overloads (โˆฉ-saturate F)) (Overloads (โˆฉ-saturate F)) โŠ‚: Overloads (โˆฉ-saturate F) step (S โ‡’ T) (intersect here here) = defn here <:-โˆฉ-left (<:-โˆฉ-glb <:-refl <:-refl) step (F โˆฉ G) (intersect (left (left p)) (left (left q))) = step F (intersect p q) >>= โŠ‚:-overloads-left >>= โŠ‚:-overloads-left step (F โˆฉ G) (intersect (left (left p)) (left (right q))) = โŠ‚:-overloads-โ‹’ (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) (intersect p q) >>= โŠ‚:-overloads-right step (F โˆฉ G) (intersect (left (right p)) (left (left q))) = โŠ‚:-overloads-โ‹’ (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) (intersect q p) >>= โŠ‚:-overloads-right >>=หก <:-โˆฉ-symm >>=สณ <:-โˆฉ-symm step (F โˆฉ G) (intersect (left (right p)) (left (right q))) = step G (intersect p q) >>= โŠ‚:-overloads-right >>= โŠ‚:-overloads-left step (F โˆฉ G) (intersect (right p) q) with โŠ‚:-โ‹’-overloads (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) p step (F โˆฉ G) (intersect (right p) (left (left q))) | defn (intersect pโ‚ pโ‚‚) pโ‚ƒ pโ‚„ = (step F (intersect pโ‚ q) [โˆฉ] just pโ‚‚) >>= โŠ‚:-overloads-โ‹’ (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-intersect pโ‚ƒ <:-refl) (<:-โˆฉ-glb (<:-intersect <:-โˆฉ-left <:-refl) (<:-trans <:-โˆฉ-left <:-โˆฉ-right)) >>=สณ <:-trans (<:-โˆฉ-glb (<:-intersect <:-โˆฉ-left <:-refl) (<:-trans <:-โˆฉ-left <:-โˆฉ-right)) (<:-intersect pโ‚„ <:-refl) step (F โˆฉ G) (intersect (right p) (left (right q))) | defn (intersect pโ‚ pโ‚‚) pโ‚ƒ pโ‚„ = (just pโ‚ [โˆฉ] step G (intersect pโ‚‚ q)) >>= โŠ‚:-overloads-โ‹’ (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-intersect pโ‚ƒ <:-refl) <:-โˆฉ-assocr >>=สณ <:-trans <:-โˆฉ-assocl (<:-intersect pโ‚„ <:-refl) step (F โˆฉ G) (intersect (right p) (right q)) | defn (intersect pโ‚ pโ‚‚) pโ‚ƒ pโ‚„ with โŠ‚:-โ‹’-overloads (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) q step (F โˆฉ G) (intersect (right p) (right q)) | defn (intersect pโ‚ pโ‚‚) pโ‚ƒ pโ‚„ | defn (intersect qโ‚ qโ‚‚) qโ‚ƒ qโ‚„ = (step F (intersect pโ‚ qโ‚) [โˆฉ] step G (intersect pโ‚‚ qโ‚‚)) >>= โŠ‚:-overloads-โ‹’ (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-intersect pโ‚ƒ qโ‚ƒ) (<:-โˆฉ-glb (<:-intersect <:-โˆฉ-left <:-โˆฉ-left) (<:-intersect <:-โˆฉ-right <:-โˆฉ-right)) >>=สณ <:-trans (<:-โˆฉ-glb (<:-intersect <:-โˆฉ-left <:-โˆฉ-left) (<:-intersect <:-โˆฉ-right <:-โˆฉ-right)) (<:-intersect pโ‚„ qโ‚„) step (F โˆฉ G) (intersect p (right q)) with โŠ‚:-โ‹’-overloads (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) q step (F โˆฉ G) (intersect (left (left p)) (right q)) | defn (intersect qโ‚ qโ‚‚) qโ‚ƒ qโ‚„ = (step F (intersect p qโ‚) [โˆฉ] just qโ‚‚) >>= โŠ‚:-overloads-โ‹’ (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-intersect <:-refl qโ‚ƒ) <:-โˆฉ-assocl >>=สณ <:-trans <:-โˆฉ-assocr (<:-intersect <:-refl qโ‚„) step (F โˆฉ G) (intersect (left (right p)) (right q)) | defn (intersect qโ‚ qโ‚‚) qโ‚ƒ qโ‚„ = (just qโ‚ [โˆฉ] step G (intersect p qโ‚‚) ) >>= โŠ‚:-overloads-โ‹’ (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-intersect <:-refl qโ‚ƒ) (<:-โˆฉ-glb (<:-trans <:-โˆฉ-right <:-โˆฉ-left) (<:-โˆฉ-glb <:-โˆฉ-left (<:-trans <:-โˆฉ-right <:-โˆฉ-right))) >>=สณ <:-โˆฉ-glb (<:-trans <:-โˆฉ-right <:-โˆฉ-left) (<:-trans (<:-โˆฉ-glb <:-โˆฉ-left (<:-trans <:-โˆฉ-right <:-โˆฉ-right)) qโ‚„) step (F โˆฉ G) (intersect (right p) (right q)) | defn (intersect qโ‚ qโ‚‚) qโ‚ƒ qโ‚„ with โŠ‚:-โ‹’-overloads (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) p step (F โˆฉ G) (intersect (right p) (right q)) | defn (intersect qโ‚ qโ‚‚) qโ‚ƒ qโ‚„ | defn (intersect pโ‚ pโ‚‚) pโ‚ƒ pโ‚„ = (step F (intersect pโ‚ qโ‚) [โˆฉ] step G (intersect pโ‚‚ qโ‚‚)) >>= โŠ‚:-overloads-โ‹’ (normal-โˆฉ-saturate F) (normal-โˆฉ-saturate G) >>= โŠ‚:-overloads-right >>=หก <:-trans (<:-intersect pโ‚ƒ qโ‚ƒ) (<:-โˆฉ-glb (<:-intersect <:-โˆฉ-left <:-โˆฉ-left) (<:-intersect <:-โˆฉ-right <:-โˆฉ-right)) >>=สณ <:-trans (<:-โˆฉ-glb (<:-intersect <:-โˆฉ-left <:-โˆฉ-left) (<:-intersect <:-โˆฉ-right <:-โˆฉ-right)) (<:-intersect pโ‚„ qโ‚„) saturate-overloads : โˆ€ {F} โ†’ FunType F โ†’ Overloads (saturate F) โŠ‚: โˆช-Saturate (โˆฉ-Saturate (Overloads F)) saturate-overloads F o = โˆช-saturate-overloads (normal-โˆฉ-saturate F) o >>= (โŠ‚:-โˆช-saturate (โˆฉ-saturate-overloads F)) overloads-saturate : โˆ€ {F} โ†’ FunType F โ†’ โˆช-Saturate (โˆฉ-Saturate (Overloads F)) โŠ‚: Overloads (saturate F) overloads-saturate F o = โŠ‚:-โˆช-saturate (overloads-โˆฉ-saturate F) o >>= overloads-โˆช-saturate (normal-โˆฉ-saturate F) -- Saturated F whenever -- * if F has overloads (R โ‡’ S) and (T โ‡’ U) then F has an overload which is a subtype of ((R โˆฉ T) โ‡’ (S โˆฉ U)) -- * ditto union data Saturated (F : Type) : Set where defn : (โˆ€ {R S T U} โ†’ Overloads F (R โ‡’ S) โ†’ Overloads F (T โ‡’ U) โ†’ <:-Close (Overloads F) ((R โˆฉ T) โ‡’ (S โˆฉ U))) โ†’ (โˆ€ {R S T U} โ†’ Overloads F (R โ‡’ S) โ†’ Overloads F (T โ‡’ U) โ†’ <:-Close (Overloads F) ((R โˆช T) โ‡’ (S โˆช U))) โ†’ ----------- Saturated F -- saturated F is saturated! saturated : โˆ€ {F} โ†’ FunType F โ†’ Saturated (saturate F) saturated F = defn (ฮป n o โ†’ (saturate-overloads F n [โˆฉ] saturate-overloads F o) >>= โˆช-saturate-resp-โˆฉ-saturation โŠ‚:-โˆฉ-lift-saturate >>= overloads-saturate F) (ฮป n o โ†’ โˆช-saturated (normal-โˆฉ-saturate F) (union n o))
{ "alphanum_fraction": 0.534125099, "avg_line_length": 58.202764977, "ext": "agda", "hexsha": "13f7d171ffe571ab31261d45297a5b85c08369d1", "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": "39fbd2146a379fb0878369b48764cd7e8772c0fb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "sthagen/Roblox-luau", "max_forks_repo_path": "prototyping/Properties/TypeSaturation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "39fbd2146a379fb0878369b48764cd7e8772c0fb", "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": "sthagen/Roblox-luau", "max_issues_repo_path": "prototyping/Properties/TypeSaturation.agda", "max_line_length": 459, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f1b46f4b967f11fabe666da1de0e71b225368260", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Libertus-Lab/luau", "max_stars_repo_path": "prototyping/Properties/TypeSaturation.agda", "max_stars_repo_stars_event_max_datetime": "2021-11-06T08:03:00.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-06T08:03:00.000Z", "num_tokens": 12167, "size": 25260 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Patterns used in the reflection machinery ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Reflection.Pattern where open import Data.List.Base hiding (_++_) open import Data.List.Properties open import Data.Product open import Data.String as String using (String; braces; parens; _++_; _<+>_) import Reflection.Literal as Literal import Reflection.Name as Name open import Relation.Nullary open import Relation.Nullary.Decidable as Dec open import Relation.Nullary.Product using (_ร—-dec_) open import Relation.Binary open import Relation.Binary.PropositionalEquality open import Reflection.Argument open import Reflection.Argument.Visibility using (Visibility); open Visibility open import Reflection.Argument.Relevance using (Relevance); open Relevance open import Reflection.Argument.Information using (ArgInfo); open ArgInfo ------------------------------------------------------------------------ -- Re-exporting the builtin type and constructors open import Agda.Builtin.Reflection public using (Pattern) open Pattern public ------------------------------------------------------------------------ -- Decidable equality con-injectiveโ‚ : โˆ€ {c cโ€ฒ args argsโ€ฒ} โ†’ con c args โ‰ก con cโ€ฒ argsโ€ฒ โ†’ c โ‰ก cโ€ฒ con-injectiveโ‚ refl = refl con-injectiveโ‚‚ : โˆ€ {c cโ€ฒ args argsโ€ฒ} โ†’ con c args โ‰ก con cโ€ฒ argsโ€ฒ โ†’ args โ‰ก argsโ€ฒ con-injectiveโ‚‚ refl = refl con-injective : โˆ€ {c cโ€ฒ args argsโ€ฒ} โ†’ con c args โ‰ก con cโ€ฒ argsโ€ฒ โ†’ c โ‰ก cโ€ฒ ร— args โ‰ก argsโ€ฒ con-injective = < con-injectiveโ‚ , con-injectiveโ‚‚ > var-injective : โˆ€ {x y} โ†’ var x โ‰ก var y โ†’ x โ‰ก y var-injective refl = refl lit-injective : โˆ€ {x y} โ†’ Pattern.lit x โ‰ก lit y โ†’ x โ‰ก y lit-injective refl = refl proj-injective : โˆ€ {x y} โ†’ proj x โ‰ก proj y โ†’ x โ‰ก y proj-injective refl = refl _โ‰Ÿs_ : Decidable (_โ‰ก_ {A = Args Pattern}) _โ‰Ÿ_ : Decidable (_โ‰ก_ {A = Pattern}) con c ps โ‰Ÿ con cโ€ฒ psโ€ฒ = Dec.mapโ€ฒ (uncurry (congโ‚‚ con)) con-injective (c Name.โ‰Ÿ cโ€ฒ ร—-dec ps โ‰Ÿs psโ€ฒ) var s โ‰Ÿ var sโ€ฒ = Dec.mapโ€ฒ (cong var) var-injective (s String.โ‰Ÿ sโ€ฒ) lit l โ‰Ÿ lit lโ€ฒ = Dec.mapโ€ฒ (cong lit) lit-injective (l Literal.โ‰Ÿ lโ€ฒ) proj a โ‰Ÿ proj aโ€ฒ = Dec.mapโ€ฒ (cong proj) proj-injective (a Name.โ‰Ÿ aโ€ฒ) con x xโ‚ โ‰Ÿ dot = no (ฮป ()) con x xโ‚ โ‰Ÿ var xโ‚‚ = no (ฮป ()) con x xโ‚ โ‰Ÿ lit xโ‚‚ = no (ฮป ()) con x xโ‚ โ‰Ÿ proj xโ‚‚ = no (ฮป ()) con x xโ‚ โ‰Ÿ absurd = no (ฮป ()) dot โ‰Ÿ con x xโ‚ = no (ฮป ()) dot โ‰Ÿ dot = yes refl dot โ‰Ÿ var x = no (ฮป ()) dot โ‰Ÿ lit x = no (ฮป ()) dot โ‰Ÿ proj x = no (ฮป ()) dot โ‰Ÿ absurd = no (ฮป ()) var s โ‰Ÿ con x xโ‚ = no (ฮป ()) var s โ‰Ÿ dot = no (ฮป ()) var s โ‰Ÿ lit x = no (ฮป ()) var s โ‰Ÿ proj x = no (ฮป ()) var s โ‰Ÿ absurd = no (ฮป ()) lit x โ‰Ÿ con xโ‚ xโ‚‚ = no (ฮป ()) lit x โ‰Ÿ dot = no (ฮป ()) lit x โ‰Ÿ var _ = no (ฮป ()) lit x โ‰Ÿ proj xโ‚ = no (ฮป ()) lit x โ‰Ÿ absurd = no (ฮป ()) proj x โ‰Ÿ con xโ‚ xโ‚‚ = no (ฮป ()) proj x โ‰Ÿ dot = no (ฮป ()) proj x โ‰Ÿ var _ = no (ฮป ()) proj x โ‰Ÿ lit xโ‚ = no (ฮป ()) proj x โ‰Ÿ absurd = no (ฮป ()) absurd โ‰Ÿ con x xโ‚ = no (ฮป ()) absurd โ‰Ÿ dot = no (ฮป ()) absurd โ‰Ÿ var _ = no (ฮป ()) absurd โ‰Ÿ lit x = no (ฮป ()) absurd โ‰Ÿ proj x = no (ฮป ()) absurd โ‰Ÿ absurd = yes refl [] โ‰Ÿs [] = yes refl (arg i p โˆท xs) โ‰Ÿs (arg j q โˆท ys) = โˆท-dec (unArg-dec (p โ‰Ÿ q)) (xs โ‰Ÿs ys) [] โ‰Ÿs (_ โˆท _) = no ฮป() (_ โˆท _) โ‰Ÿs [] = no ฮป()
{ "alphanum_fraction": 0.5600839077, "avg_line_length": 33.0396039604, "ext": "agda", "hexsha": "1ddc31778804f4e778e6acad4d2a02f3fbfb603f", "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/Reflection/Pattern.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/Reflection/Pattern.agda", "max_line_length": 98, "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/Reflection/Pattern.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": 1039, "size": 3337 }
module sum-thms where open import eq open import sum open import list open import product open import empty open import negation injโ‚-inj : โˆ€{โ„“ โ„“'}{A : Set โ„“}{B : Set โ„“'}{x : A}{x'} โ†’ injโ‚{โ„“}{โ„“'}{A}{B} x โ‰ก injโ‚ x' โ†’ x โ‰ก x' injโ‚-inj refl = refl โŠŽ-assoc-isoโ‚ : โˆ€{โ„“}{U V W : Set โ„“}{x : U โŠŽ V โŠŽ W} โ†’ โŠŽ-assoc-inv (โŠŽ-assoc x) โ‰ก x โŠŽ-assoc-isoโ‚ {x = injโ‚ x} = refl โŠŽ-assoc-isoโ‚ {x = injโ‚‚ (injโ‚ x)} = refl โŠŽ-assoc-isoโ‚ {x = injโ‚‚ (injโ‚‚ y)} = refl โŠŽ-assoc-isoโ‚‚ : โˆ€{โ„“}{U V W : Set โ„“}{x : (U โŠŽ V) โŠŽ W} โ†’ โŠŽ-assoc (โŠŽ-assoc-inv x) โ‰ก x โŠŽ-assoc-isoโ‚‚ {x = injโ‚ (injโ‚ x)} = refl โŠŽ-assoc-isoโ‚‚ {x = injโ‚ (injโ‚‚ y)} = refl โŠŽ-assoc-isoโ‚‚ {x = injโ‚‚ y} = refl โŠŽ-left-ident-isoโ‚ : โˆ€{โ„“}{X : Set โ„“}{x} โ†’ โŠŽ-left-ident-inv {_}{X} (โŠŽ-left-ident x) โ‰ก x โŠŽ-left-ident-isoโ‚ {x = injโ‚ x} = โŠฅ-elim x โŠŽ-left-ident-isoโ‚ {x = injโ‚‚ y} = refl โŠŽ-left-ident-isoโ‚‚ : โˆ€{โ„“}{X : Set โ„“}{x} โ†’ โŠŽ-left-ident {_}{X} (โŠŽ-left-ident-inv x) โ‰ก x โŠŽ-left-ident-isoโ‚‚ = refl โŠŽ-right-ident-isoโ‚ : โˆ€{โ„“}{X : Set โ„“}{x} โ†’ โŠŽ-right-ident-inv {_}{X} (โŠŽ-right-ident x) โ‰ก x โŠŽ-right-ident-isoโ‚ {x = injโ‚ x} = refl โŠŽ-right-ident-isoโ‚ {x = injโ‚‚ y} = โŠฅ-elim y โŠŽ-right-ident-isoโ‚‚ : โˆ€{โ„“}{X : Set โ„“}{x} โ†’ โŠŽ-right-ident {_}{X} (โŠŽ-right-ident-inv x) โ‰ก x โŠŽ-right-ident-isoโ‚‚ = refl ยฌโŠŽโ†’ร— : โˆ€{โ„“}{A B : Set โ„“} โ†’ ยฌ (_โŠŽ_ {โ„“} A B) โ†’ ยฌ A ร— ยฌ B ยฌโŠŽโ†’ร— {โ„“}{A}{B} p = (ฮป x โ†’ p (injโ‚ x)) , ฮป x โ†’ p (injโ‚‚ x)
{ "alphanum_fraction": 0.5417933131, "avg_line_length": 33.7435897436, "ext": "agda", "hexsha": "b26bc9e4b29b19012c1b67bf9b31d2fd433f03ec", "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": "sum-thms.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": "sum-thms.agda", "max_line_length": 93, "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": "sum-thms.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 719, "size": 1316 }
module Imports.Unsolved where X : Set X = ?
{ "alphanum_fraction": 0.6595744681, "avg_line_length": 6.7142857143, "ext": "agda", "hexsha": "beb0226c3b2d87b943d3c191671c8c80771e822e", "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/Imports/Unsolved.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/Imports/Unsolved.agda", "max_line_length": 29, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Imports/Unsolved.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": 15, "size": 47 }
open import Agda.Primitive postulate F : (a : Level) โ†’ Set a โ†’ Set a P : (a : Level) (A : Set a) โ†’ F a A โ†’ Set a p : (a : Level) (A : Set a) (x : F a A) โ†’ P a A x Q : (a : Level) (A : Set a) โ†’ A โ†’ Set a variable a : Level A : Set a postulate q : (x : F _ A) โ†’ Q a _ (p a A x) q' : {a : Level} {A : Set a} (x : F a A) โ†’ Q a (P a A x) (p a A x) q' {a} {A} = q {a} {A}
{ "alphanum_fraction": 0.4545454545, "avg_line_length": 20.2631578947, "ext": "agda", "hexsha": "146240fac0a8bec2b7d990182aaec3d8599ae5f5", "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/Issue3655.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/Issue3655.agda", "max_line_length": 66, "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/Issue3655.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": 183, "size": 385 }
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use -- Data.Vec.Relation.Unary.All directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Vec.All where open import Data.Vec.Relation.Unary.All public
{ "alphanum_fraction": 0.4393530997, "avg_line_length": 28.5384615385, "ext": "agda", "hexsha": "c04627bda24005e079a4dfd599ceef824f7ddcbf", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/All.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/All.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/Data/Vec/All.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 60, "size": 371 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category open import Categories.Functor open import Categories.Adjoint -- Right Adjoint Preserves Limits. module Categories.Adjoint.RAPL {o oโ€ฒ โ„“ โ„“โ€ฒ e eโ€ฒ} {C : Category o โ„“ e} {D : Category oโ€ฒ โ„“โ€ฒ eโ€ฒ} {L : Functor C D} {R : Functor D C} (LโŠฃR : L โŠฃ R) where open import Categories.Functor.Properties import Categories.Morphism.Reasoning as MR import Categories.Diagram.Limit as Lim import Categories.Category.Construction.Cones as Con private module C = Category C module D = Category D module L = Functor L module R = Functor R open Adjoint LโŠฃR module _ {oโ€ณ โ„“โ€ณ eโ€ณ} {J : Category oโ€ณ โ„“โ€ณ eโ€ณ} (F : Functor J D) where private module F = Functor F module LF = Lim F module CF = Con F RF = R โˆ˜F F module LRF = Lim RF module CRF = Con RF rapl : LF.Limit โ†’ LRF.Limit rapl lim = record { terminal = record { โŠค = โŠค ; ! = ! ; !-unique = !-unique } } where module lim = LF.Limit lim open lim โŠค : CRF.Cone โŠค = record { N = R.Fโ‚€ apex ; apex = record { ฯˆ = ฮป X โ†’ R.Fโ‚ (proj X) ; commute = ฮป f โ†’ [ R ]-resp-โˆ˜ (limit-commute f) } } Kโ€ฒ : CRF.Cone โ†’ CF.Cone Kโ€ฒ K = record { N = L.Fโ‚€ K.N ; apex = record { ฯˆ = ฮป X โ†’ counit.ฮท (F.Fโ‚€ X) D.โˆ˜ L.Fโ‚ (K.ฯˆ X) ; commute = ฮป {X Y} f โ†’ begin F.Fโ‚ f D.โˆ˜ counit.ฮท (F.Fโ‚€ X) D.โˆ˜ L.Fโ‚ (K.ฯˆ X) โ‰ˆห˜โŸจ pushหก (counit.commute (F.Fโ‚ f)) โŸฉ (counit.ฮท (F.Fโ‚€ Y) D.โˆ˜ L.Fโ‚ (R.Fโ‚ (F.Fโ‚ f))) D.โˆ˜ L.Fโ‚ (K.ฯˆ X) โ‰ˆโŸจ pullสณ ([ L ]-resp-โˆ˜ (K.commute f)) โŸฉ counit.ฮท (F.Fโ‚€ Y) D.โˆ˜ L.Fโ‚ (K.ฯˆ Y) โˆŽ } } where module K = CRF.Cone K open D.HomReasoning open MR D module Kโ€ฒ K = CF.Cone (Kโ€ฒ K) ! : โˆ€ {K : CRF.Cone} โ†’ CRF.Cones [ K , โŠค ] ! {K} = record { arr = R.Fโ‚ (rep (Kโ€ฒ K)) C.โˆ˜ unit.ฮท K.N ; commute = commuteโ€ฒ } where module K = CRF.Cone K commuteโ€ฒ : โˆ€ {X} โ†’ R.Fโ‚ (proj X) C.โˆ˜ R.Fโ‚ (rep (Kโ€ฒ K)) C.โˆ˜ unit.ฮท K.N C.โ‰ˆ K.ฯˆ X commuteโ€ฒ {X} = begin R.Fโ‚ (proj X) C.โˆ˜ R.Fโ‚ (rep (Kโ€ฒ K)) C.โˆ˜ unit.ฮท K.N โ‰ˆโŸจ pullหก ([ R ]-resp-โˆ˜ commute) โŸฉ R.Fโ‚ (Kโ€ฒ.ฯˆ K X) C.โˆ˜ unit.ฮท K.N โ‰ˆโŸจ LRadjunctโ‰ˆid โŸฉ K.ฯˆ X โˆŽ where open C.HomReasoning open MR C module ! {K} = CRF.Coneโ‡’ (! {K}) !-unique : โˆ€ {K : CRF.Cone} (f : CRF.Cones [ K , โŠค ]) โ†’ CRF.Cones [ ! โ‰ˆ f ] !-unique {K} f = let open C.HomReasoning open MR C in begin R.Fโ‚ (rep (Kโ€ฒ K)) C.โˆ˜ unit.ฮท K.N โ‰ˆโŸจ R.F-resp-โ‰ˆ (terminal.!-unique fโ€ฒ) โŸฉโˆ˜โŸจrefl โŸฉ Ladjunct (Radjunct f.arr) โ‰ˆโŸจ LRadjunctโ‰ˆid โŸฉ f.arr โˆŽ where module K = CRF.Cone K module f = CRF.Coneโ‡’ f fโ€ฒ : CF.Cones [ Kโ€ฒ K , limit ] fโ€ฒ = record { arr = Radjunct f.arr ; commute = ฮป {X} โ†’ begin proj X D.โˆ˜ Radjunct f.arr โ‰ˆห˜โŸจ pushหก (counit.commute (proj X)) โŸฉ (counit.ฮท (F.Fโ‚€ X) D.โˆ˜ L.Fโ‚ (R.Fโ‚ (proj X))) D.โˆ˜ L.Fโ‚ f.arr โ‰ˆห˜โŸจ pushสณ L.homomorphism โŸฉ Radjunct (R.Fโ‚ (proj X) C.โˆ˜ f.arr) โ‰ˆโŸจ Radjunct-resp-โ‰ˆ f.commute โŸฉ Radjunct (K.ฯˆ X) โˆŽ } where open D.HomReasoning open MR D
{ "alphanum_fraction": 0.400544285, "avg_line_length": 34.547008547, "ext": "agda", "hexsha": "b701bf681849447fa3e4e1aad73faef160263503", "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/Adjoint/RAPL.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/Adjoint/RAPL.agda", "max_line_length": 119, "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/Adjoint/RAPL.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1326, "size": 4042 }
module Convertibility where open import Syntax public -- ฮฒ-ฮท-equivalence. infix 4 _โ‰กแตแต‘_ data _โ‰กแตแต‘_ : โˆ€ {A ฮ“} โ†’ ฮ“ โŠข A โ†’ ฮ“ โŠข A โ†’ Set where reflโ‰กแตแต‘ : โˆ€ {A ฮ“} {d : ฮ“ โŠข A} โ†’ d โ‰กแตแต‘ d transโ‰กแตแต‘ : โˆ€ {A ฮ“} {d dโ€ฒ dโ€ณ : ฮ“ โŠข A} โ†’ d โ‰กแตแต‘ dโ€ฒ โ†’ dโ€ฒ โ‰กแตแต‘ dโ€ณ โ†’ d โ‰กแตแต‘ dโ€ณ symโ‰กแตแต‘ : โˆ€ {A ฮ“} {d dโ€ฒ : ฮ“ โŠข A} โ†’ d โ‰กแตแต‘ dโ€ฒ โ†’ dโ€ฒ โ‰กแตแต‘ d -- Congruences. congโ‰กแตแต‘lam : โˆ€ {A B ฮ“} {d dโ€ฒ : ฮ“ , A โŠข B} โ†’ d โ‰กแตแต‘ dโ€ฒ โ†’ lam d โ‰กแตแต‘ lam dโ€ฒ congโ‰กแตแต‘app : โˆ€ {A B ฮ“} {d dโ€ฒ : ฮ“ โŠข A โ‡’ B} {e eโ€ฒ : ฮ“ โŠข A} โ†’ d โ‰กแตแต‘ dโ€ฒ โ†’ e โ‰กแตแต‘ eโ€ฒ โ†’ app d e โ‰กแตแต‘ app dโ€ฒ eโ€ฒ congโ‰กแตแต‘pair : โˆ€ {A B ฮ“} {d dโ€ฒ : ฮ“ โŠข A} {e eโ€ฒ : ฮ“ โŠข B} โ†’ d โ‰กแตแต‘ dโ€ฒ โ†’ e โ‰กแตแต‘ eโ€ฒ โ†’ pair d e โ‰กแตแต‘ pair dโ€ฒ eโ€ฒ congโ‰กแตแต‘fst : โˆ€ {A B ฮ“} {d dโ€ฒ : ฮ“ โŠข A โฉ• B} โ†’ d โ‰กแตแต‘ dโ€ฒ โ†’ fst d โ‰กแตแต‘ fst dโ€ฒ congโ‰กแตแต‘snd : โˆ€ {A B ฮ“} {d dโ€ฒ : ฮ“ โŠข A โฉ• B} โ†’ d โ‰กแตแต‘ dโ€ฒ โ†’ snd d โ‰กแตแต‘ snd dโ€ฒ -- Reductions, or ฮฒ-conversions. reduceโ‡’ : โˆ€ {A B ฮ“} โ†’ (d : ฮ“ , A โŠข B) (e : ฮ“ โŠข A) โ†’ app (lam d) e โ‰กแตแต‘ [ top โ‰” e ] d reduceโฉ•โ‚ : โˆ€ {A B ฮ“} โ†’ (d : ฮ“ โŠข A) (e : ฮ“ โŠข B) โ†’ fst (pair d e) โ‰กแตแต‘ d reduceโฉ•โ‚‚ : โˆ€ {A B ฮ“} โ†’ (d : ฮ“ โŠข A) (e : ฮ“ โŠข B) โ†’ snd (pair d e) โ‰กแตแต‘ e -- Expansions, or ฮท-conversions. expandโ‡’ : โˆ€ {A B ฮ“} โ†’ (d : ฮ“ โŠข A โ‡’ B) โ†’ d โ‰กแตแต‘ lam (app (monoโŠข weakโІ d) vโ‚€) expandโฉ• : โˆ€ {A B ฮ“} โ†’ (d : ฮ“ โŠข A โฉ• B) โ†’ d โ‰กแตแต‘ pair (fst d) (snd d) expandโซช : โˆ€ {ฮ“} โ†’ (d : ฮ“ โŠข โซช) โ†’ d โ‰กแตแต‘ unit โ‰กโ†’โ‰กแตแต‘ : โˆ€ {A ฮ“} {d dโ€ฒ : ฮ“ โŠข A} โ†’ d โ‰ก dโ€ฒ โ†’ d โ‰กแตแต‘ dโ€ฒ โ‰กโ†’โ‰กแตแต‘ refl = reflโ‰กแตแต‘ -- Syntax for equational reasoning with ฮฒ-ฮท-equivalence. module โ‰กแตแต‘-Reasoning where infix 1 beginโ‰กแตแต‘_ beginโ‰กแตแต‘_ : โˆ€ {A ฮ“} {d dโ€ฒ : ฮ“ โŠข A} โ†’ d โ‰กแตแต‘ dโ€ฒ โ†’ d โ‰กแตแต‘ dโ€ฒ beginโ‰กแตแต‘_ p = p infixr 2 _โ‰กโ†’โ‰กแตแต‘โŸจโŸฉ_ _โ‰กโ†’โ‰กแตแต‘โŸจโŸฉ_ : โˆ€ {A ฮ“} (d {dโ€ฒ} : ฮ“ โŠข A) โ†’ d โ‰ก dโ€ฒ โ†’ d โ‰กแตแต‘ dโ€ฒ d โ‰กโ†’โ‰กแตแต‘โŸจโŸฉ p = โ‰กโ†’โ‰กแตแต‘ p infixr 2 _โ‰กแตแต‘โŸจโŸฉ_ _โ‰กแตแต‘โŸจโŸฉ_ : โˆ€ {A ฮ“} (d {dโ€ฒ} : ฮ“ โŠข A) โ†’ d โ‰กแตแต‘ dโ€ฒ โ†’ d โ‰กแตแต‘ dโ€ฒ d โ‰กแตแต‘โŸจโŸฉ p = p infixr 2 _โ‰กแตแต‘โŸจ_โŸฉ_ _โ‰กแตแต‘โŸจ_โŸฉ_ : โˆ€ {A ฮ“} (d {dโ€ฒ dโ€ณ} : ฮ“ โŠข A) โ†’ d โ‰กแตแต‘ dโ€ฒ โ†’ dโ€ฒ โ‰กแตแต‘ dโ€ณ โ†’ d โ‰กแตแต‘ dโ€ณ d โ‰กแตแต‘โŸจ p โŸฉ q = transโ‰กแตแต‘ p q infix 3 _โˆŽโ‰กแตแต‘ _โˆŽโ‰กแตแต‘ : โˆ€ {A ฮ“} (d : ฮ“ โŠข A) โ†’ d โ‰กแตแต‘ d _โˆŽโ‰กแตแต‘ _ = reflโ‰กแตแต‘ open โ‰กแตแต‘-Reasoning public
{ "alphanum_fraction": 0.4051764706, "avg_line_length": 24.4252873563, "ext": "agda", "hexsha": "44ca6afa7623ae08fc156252b746f39933afc215", "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": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/nbe-correctness", "max_forks_repo_path": "src/Convertibility.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5", "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/nbe-correctness", "max_issues_repo_path": "src/Convertibility.agda", "max_line_length": 74, "max_stars_count": 3, "max_stars_repo_head_hexsha": "54e9a83a8db4e33a33bf5dae5b2d651ad38aa3d5", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/nbe-correctness", "max_stars_repo_path": "src/Convertibility.agda", "max_stars_repo_stars_event_max_datetime": "2017-03-23T18:51:34.000Z", "max_stars_repo_stars_event_min_datetime": "2017-03-23T06:25:23.000Z", "num_tokens": 1473, "size": 2125 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties related to propositional list membership, that rely on -- the K rule ------------------------------------------------------------------------ {-# OPTIONS --with-K --safe #-} module Data.List.Membership.Propositional.Properties.WithK where open import Data.List.Base open import Data.List.Relation.Unary.Unique.Propositional open import Data.List.Membership.Propositional import Data.List.Membership.Setoid.Properties as Membershipโ‚› open import Relation.Unary using (Irrelevant) open import Relation.Binary.PropositionalEquality as P using (_โ‰ก_) open import Relation.Binary.PropositionalEquality.WithK ------------------------------------------------------------------------ -- Irrelevance uniqueโ‡’irrelevant : โˆ€ {a} {A : Set a} {xs : List A} โ†’ Unique xs โ†’ Irrelevant (_โˆˆ xs) uniqueโ‡’irrelevant = Membershipโ‚›.uniqueโ‡’irrelevant (P.setoid _) โ‰ก-irrelevant
{ "alphanum_fraction": 0.5935613682, "avg_line_length": 38.2307692308, "ext": "agda", "hexsha": "5909ec3e723ad7c5287c22ffe2ff9bda01100461", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Data/List/Membership/Propositional/Properties/WithK.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Data/List/Membership/Propositional/Properties/WithK.agda", "max_line_length": 75, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Data/List/Membership/Propositional/Properties/WithK.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 199, "size": 994 }
{-# OPTIONS --without-K --rewriting #-} module Bool where open import Basics open import lib.Basics open import lib.types.Bool public _โ‰คb_ : Bool โ†’ Bool โ†’ PropTโ‚€ true โ‰คb true = True true โ‰คb false = False false โ‰คb true = True false โ‰คb false = True โ‰คb-refl : (b : Bool) โ†’ (b โ‰คb b) holds โ‰คb-refl true = unit โ‰คb-refl false = unit โ‰คb-trans : {a b c : Bool} โ†’ (a โ‰คb b) holds โ†’ (b โ‰คb c) holds โ†’ (a โ‰คb c) holds โ‰คb-trans {a} {b} {c} = โ‰คb-trans' a b c where โ‰คb-trans' : (a b c : Bool) โ†’ (a โ‰คb b) holds โ†’ (b โ‰คb c) holds โ†’ (a โ‰คb c) holds โ‰คb-trans' true true true = ฮป _ _ โ†’ unit โ‰คb-trans' true true false = ฮป _ z โ†’ z โ‰คb-trans' true false true = ฮป _ _ โ†’ unit โ‰คb-trans' true false false = ฮป z _ โ†’ z โ‰คb-trans' false true true = ฮป _ _ โ†’ unit โ‰คb-trans' false true false = ฮป _ _ โ†’ unit โ‰คb-trans' false false true = ฮป _ _ โ†’ unit โ‰คb-trans' false false false = ฮป _ _ โ†’ unit Bool-to-PropTโ‚€ : Bool โ†’ PropTโ‚€ Bool-to-PropTโ‚€ true = True Bool-to-PropTโ‚€ false = False Dec-Prop-to-Bool : {i : ULevel} (P : PropT i) โ†’ Dec (P holds) โ†’ Bool Dec-Prop-to-Bool _ (inl _) = true Dec-Prop-to-Bool _ (inr _) = false Dec-Prop-to-Bool-true-id : {i : ULevel} (P : PropT i) (d : Dec (P holds)) โ†’ P holds โ†’ (Dec-Prop-to-Bool P d) == true Dec-Prop-to-Bool-true-id P (inl _) p = refl Dec-Prop-to-Bool-true-id P (inr d) p = quodlibet (d p) Dec-Prop-to-Bool-false-id : {i : ULevel} (P : PropT i) (d : Dec (P holds)) โ†’ ยฌ (P holds) โ†’ (Dec-Prop-to-Bool P d) == false Dec-Prop-to-Bool-false-id P (inl x) np = quodlibet (np x) Dec-Prop-to-Bool-false-id P (inr _) np = refl _holds-b : Bool โ†’ Typeโ‚€ b holds-b = (Bool-to-PropTโ‚€ b) holds
{ "alphanum_fraction": 0.5598411798, "avg_line_length": 34.568627451, "ext": "agda", "hexsha": "5f01fc864b8a1fcbf43875934c6c53bde28d95c0", "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": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "glangmead/formalization", "max_forks_repo_path": "cohesion/david_jaz_261/Bool.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "glangmead/formalization", "max_issues_repo_path": "cohesion/david_jaz_261/Bool.agda", "max_line_length": 83, "max_stars_count": 6, "max_stars_repo_head_hexsha": "497e720a1ddaa2ec713c060f999f4b3ee2fe5e8a", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "glangmead/formalization", "max_stars_repo_path": "cohesion/david_jaz_261/Bool.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-13T05:51:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-10-06T17:39:22.000Z", "num_tokens": 655, "size": 1763 }
{-# OPTIONS --without-K #-} module sets.int.properties where open import equality open import function.core import sets.nat as N open N using (โ„•; suc) open import sets.int.definition open import sets.int.utils import sets.int.core as Z private module _ where open N add-right-unit : โˆ€ n n' โ†’ (n + 0) [-] (n' + 0) โ‰ก n [-] n' add-right-unit n n' = apโ‚‚ _[-]_ (+-right-unit n) (+-right-unit n') add-left-inverse : โˆ€ n n' โ†’ (n' + n) [-] (n + n') โ‰ก 0 [-] 0 add-left-inverse n n' = sym $ eq-โ„ค 0 0 (n' + n) ยท apโ‚‚ _[-]_ (+-right-unit (n' + n)) (+-right-unit (n' + n) ยท +-commutativity n' n) module _ where open Z +-left-unit : โˆ€ n โ†’ zero + n โ‰ก n +-left-unit = elim-prop-โ„ค (ฮป n โ†’ hโ„ค (zero + n) n) (ฮป n n' โ†’ refl) +-right-unit : โˆ€ n โ†’ n + zero โ‰ก n +-right-unit = elim-prop-โ„ค (ฮป n โ†’ hโ„ค (n + zero) n) add-right-unit +-left-inverse : โˆ€ n โ†’ negate n + n โ‰ก zero +-left-inverse = elim-prop-โ„ค (ฮป n โ†’ hโ„ค (negate n + n) zero) add-left-inverse +-right-inverse : โˆ€ n โ†’ n + negate n โ‰ก zero +-right-inverse = elim-prop-โ„ค (ฮป n โ†’ hโ„ค (n + negate n) zero) (ฮป n n' โ†’ add-left-inverse n' n) inc-dec : โˆ€ n โ†’ inc (dec n) โ‰ก n inc-dec = elim-prop-โ„ค (ฮป n โ†’ hโ„ค (inc (dec n)) n) (ฮป n n' โ†’ sym (eq-โ„ค n n' 1)) dec-inc : โˆ€ n โ†’ dec (inc n) โ‰ก n dec-inc = elim-prop-โ„ค (ฮป n โ†’ hโ„ค (dec (inc n)) n) (ฮป n n' โ†’ sym (eq-โ„ค n n' 1)) +-associativity : โˆ€ n m p โ†’ n + m + p โ‰ก n + (m + p) +-associativity = elimโ‚ƒ-prop-โ„ค (ฮป n m p โ†’ hโ„ค (n + m + p) (n + (m + p))) (ฮป n n' m m' p p' โ†’ apโ‚‚ _[-]_ (N.+-associativity n m p) (N.+-associativity n' m' p'))
{ "alphanum_fraction": 0.469376392, "avg_line_length": 30.9655172414, "ext": "agda", "hexsha": "8ab09c6e70ae74fdb8e5c8c7a6faee64303ccc1f", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/sets/int/properties.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/sets/int/properties.agda", "max_line_length": 70, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/sets/int/properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 647, "size": 1796 }
{-# OPTIONS --safe #-} module Issue2487.B where import Issue2487.A
{ "alphanum_fraction": 0.7058823529, "avg_line_length": 13.6, "ext": "agda", "hexsha": "0dad358e65940419816582c921116983ab3e618e", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue2487/B.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue2487/B.agda", "max_line_length": 24, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue2487/B.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 18, "size": 68 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Rings.Definition open import Rings.Orders.Partial.Definition open import Rings.Orders.Total.Definition open import Setoids.Setoids open import Setoids.Orders.Partial.Definition open import Setoids.Orders.Total.Definition open import Functions.Definition open import Fields.Fields open import Fields.Orders.Total.Definition open import Numbers.Naturals.Semiring open import Numbers.Naturals.Order open import Sets.EquivalenceRelations open import LogicalFormulae open import Groups.Definition open import Agda.Primitive using (Level; lzero; lsuc; _โŠ”_) module Fields.Orders.Total.Lemmas {m n : _} {A : Set m} {S : Setoid {m} {n} A} {_+_ : A โ†’ A โ†’ A} {_*_ : A โ†’ A โ†’ A} {R : Ring S _+_ _*_} {F : Field R} {p : _} {_<_ : Rel {_} {p} A} {pOrder : SetoidPartialOrder S _<_} {oR : PartiallyOrderedRing R pOrder} (oF : TotallyOrderedField F oR) where open Ring R open Group additiveGroup open Setoid S open Equivalence eq open Field F open TotallyOrderedField oF open TotallyOrderedRing oRing open PartiallyOrderedRing oR open SetoidTotalOrder total open SetoidPartialOrder pOrder open import Rings.InitialRing R open import Rings.Orders.Total.Lemmas oRing open import Rings.Orders.Partial.Lemmas oR open import Rings.Lemmas R open import Groups.Lemmas additiveGroup charNotN : (n : โ„•) โ†’ fromN (succ n) โˆผ 0R โ†’ False charNotN n pr = irreflexive (<WellDefined reflexive pr t) where t : 0R < fromN (succ n) t = fromNPreservesOrder (0<1 (Field.nontrivial F)) (succIsPositive n) charNot2 : Setoid._โˆผ_ S ((Ring.1R R) + (Ring.1R R)) (Ring.0R R) โ†’ False charNot2 pr = charNotN 1 (transitive (transitive +Associative identRight) pr)
{ "alphanum_fraction": 0.759149941, "avg_line_length": 36.8260869565, "ext": "agda", "hexsha": "1d04ed093bcafae099408ffeb6c0dee3a873086e", "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": "Fields/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": "Fields/Orders/Total/Lemmas.agda", "max_line_length": 290, "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": "Fields/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": 510, "size": 1694 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Package where open import Light.Level using (Setฯ‰) record Meta : Setฯ‰ where field Dependencies : Setฯ‰ field Library : Dependencies โ†’ Setฯ‰ record Package (meta : Meta) : Setฯ‰ where instance constructor package open Meta meta field โฆƒ dependencies โฆ„ : Dependencies field โฆƒ library โฆ„ : Library dependencies open Package โฆƒ ... โฆ„ public
{ "alphanum_fraction": 0.6939655172, "avg_line_length": 27.2941176471, "ext": "agda", "hexsha": "b34946cfd2a2c59c1380ec1e8416f483681102e3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "Light/Package.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "Light/Package.agda", "max_line_length": 79, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "Light/Package.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 113, "size": 464 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.SuspSectionDecomp open import homotopy.CofiberComp open import homotopy.SmashIsCofiber module homotopy.SuspProduct where module SuspProduct {i} {j} (X : Ptd i) (Y : Ptd j) where private iโ‚ : X โŠ™โ†’ X โŠ™ร— Y iโ‚ = ((ฮป x โ†’ (x , pt Y)) , idp) iโ‚‚ : Y โŠ™โ†’ X โŠ™ร— Y iโ‚‚ = ((ฮป y โ†’ (pt X , y)) , idp) jโ‚‚ : deโŠ™ (โŠ™Cofiber iโ‚) โ†’ deโŠ™ Y jโ‚‚ = CofiberRec.f (pt Y) snd (ฮป x โ†’ idp) โŠ™eq : โŠ™Susp (X โŠ™ร— Y) โŠ™โ‰ƒ โŠ™Susp X โŠ™โˆจ (โŠ™Susp Y โŠ™โˆจ โŠ™Susp (X โŠ™โˆง Y)) โŠ™eq = โŠ™โˆจ-emap (โŠ™ide (โŠ™Susp X)) (โŠ™โˆจ-emap (โŠ™ide (โŠ™Susp Y)) (โŠ™Susp-emap (Smash-โŠ™equiv-Cof X Y โŠ™โปยน โŠ™โˆ˜e CofiberComp.โŠ™eq iโ‚ iโ‚‚))) โŠ™โˆ˜e โŠ™โˆจ-emap (โŠ™ide (โŠ™Susp X)) (โ‰ƒ-to-โŠ™โ‰ƒ (SuspSectionDecomp.eq (โŠ™cfcod' iโ‚ โŠ™โˆ˜ iโ‚‚) jโ‚‚ (ฮป y โ†’ idp)) (! $ ap winl $ merid (pt Y))) โŠ™โˆ˜e โ‰ƒ-to-โŠ™โ‰ƒ (SuspSectionDecomp.eq iโ‚ fst (ฮป x โ†’ idp)) (! $ ap winl $ merid (pt X))
{ "alphanum_fraction": 0.5112059765, "avg_line_length": 29.28125, "ext": "agda", "hexsha": "d83a98e580c4cf7ffff494486080dcaf1149ee2c", "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/homotopy/SuspProduct.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/homotopy/SuspProduct.agda", "max_line_length": 75, "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/homotopy/SuspProduct.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 457, "size": 937 }
module Structure.Operator.Monoid.Invertible.Proofs where import Data.Tuple as Tuple import Lvl open import Logic.Propositional open import Logic.Predicate open import Structure.Operator open import Structure.Operator.Monoid open import Structure.Operator.Monoid.Invertible open import Structure.Operator.Properties hiding (InverseOperatorโ‚— ; InverseOperatorแตฃ) open import Structure.Relator.Properties open import Structure.Setoid open import Syntax.Transitivity open import Type private variable โ„“ โ„“โ‚— โ„“โ‚‘ : Lvl.Level private variable T : Type{โ„“} private variable _โ–ซ_ : T โ†’ T โ†’ T private variable _โจž_ : T โ†’ T โ†’ Type{โ„“โ‚—} module _ โฆƒ equiv : Equiv{โ„“โ‚‘}(T) โฆ„ โฆƒ monoid : Monoid{T = T}(_โ–ซ_) โฆ„ โฆƒ invRel : InverseRelationแตฃ(_โ–ซ_){โ„“โ‚—}(_โจž_) โฆ„ where open Monoid(monoid) using (id) instance inverseRelationแตฃ-reflexivity : Reflexivity(_โจž_) Reflexivity.proof inverseRelationแตฃ-reflexivity = [โ†”]-to-[โ†] (InverseRelationแตฃ.proof invRel) ([โˆƒ]-intro id โฆƒ identityแตฃ(_โ–ซ_)(id) โฆ„) instance inverseRelationแตฃ-transitivity : Transitivity(_โจž_) Transitivity.proof inverseRelationแตฃ-transitivity xy yz with [โˆƒ]-intro a โฆƒ pa โฆ„ โ† [โ†”]-to-[โ†’] (InverseRelationแตฃ.proof invRel) xy with [โˆƒ]-intro b โฆƒ pb โฆ„ โ† [โ†”]-to-[โ†’] (InverseRelationแตฃ.proof invRel) yz = [โ†”]-to-[โ†] (InverseRelationแตฃ.proof invRel) ([โˆƒ]-intro (a โ–ซ b) โฆƒ symmetry(_โ‰ก_) (associativity(_โ–ซ_)) ๐Ÿ– congruenceโ‚‚โ‚—(_โ–ซ_)(b) pa ๐Ÿ– pb โฆ„) inverseRelationแตฃ-with-opแตฃ : โˆ€{a x y} โ†’ (x โจž y) โ†’ ((a โ–ซ x) โจž (a โ–ซ y)) inverseRelationแตฃ-with-opแตฃ {a}{x}{y} xy with [โˆƒ]-intro z โฆƒ xzy โฆ„ โ† [โ†”]-to-[โ†’] (InverseRelationแตฃ.proof invRel) xy = [โ†”]-to-[โ†] (InverseRelationแตฃ.proof invRel) ([โˆƒ]-intro z โฆƒ associativity(_โ–ซ_) ๐Ÿ– congruenceโ‚‚แตฃ(_โ–ซ_)(a) xzy โฆ„) inverseRelationแตฃ-without-opแตฃ : โฆƒ cancโ‚— : Cancellationโ‚—(_โ–ซ_) โฆ„ โ†’ โˆ€{a x y} โ†’ ((a โ–ซ x) โจž (a โ–ซ y)) โ†’ (x โจž y) inverseRelationแตฃ-without-opแตฃ {a}{x}{y} xy with [โˆƒ]-intro z โฆƒ xzy โฆ„ โ† [โ†”]-to-[โ†’] (InverseRelationแตฃ.proof invRel) xy = [โ†”]-to-[โ†] (InverseRelationแตฃ.proof invRel) ([โˆƒ]-intro z โฆƒ cancellationโ‚—(_โ–ซ_) (symmetry(_โ‰ก_) (associativity(_โ–ซ_)) ๐Ÿ– xzy) โฆ„) inverseRelationแตฃ-of-idโ‚— : โˆ€{x} โ†’ (id โจž x) inverseRelationแตฃ-of-idโ‚— {x} = [โ†”]-to-[โ†] (InverseRelationแตฃ.proof invRel) ([โˆƒ]-intro x โฆƒ identityโ‚—(_โ–ซ_)(id) โฆ„) module _ {_โ‹„_ : (x : T) โ†’ (y : T) โ†’ . โฆƒ inv : (y โจž x) โฆ„ โ†’ T} โฆƒ invOper : InverseOperatorแตฃ(_โ–ซ_)(_โ‹„_) โฆ„ where {-op-cancellationแตฃ : โˆ€{a x y} โ†’ (a โจž x) โ†’ (a โจž y) โ†’ (a โ–ซ x โ‰ก a โ–ซ y) โ†’ (x โ‰ก y) op-cancellationแตฃ {a}{x}{y} ax ay axay with [โˆƒ]-intro r โฆƒ pr โฆ„ โ† [โ†”]-to-[โ†’] (InverseRelationแตฃ.proof invRel) ax with [โˆƒ]-intro s โฆƒ ps โฆ„ โ† [โ†”]-to-[โ†’] (InverseRelationแตฃ.proof invRel) ay = x ๐Ÿ–[ _โ‰ก_ ]-[ {!!} ] y ๐Ÿ–-end-} inverseRelationแตฃ-to-invertibleแตฃ : โˆ€{x} โ†’ โฆƒ x โจž id โฆ„ โ†’ InvertibleElementแตฃ(_โ–ซ_) โฆƒ Monoid.identity-existenceแตฃ(monoid) โฆ„ (x) inverseRelationแตฃ-to-invertibleแตฃ {x} โฆƒ xid โฆ„ = [โˆƒ]-intro (id โ‹„ x) โฆƒ intro p โฆ„ where p = (x โ–ซ (id โ‹„ x)) ๐Ÿ–[ _โ‰ก_ ]-[ congruenceโ‚‚แตฃ(_โ–ซ_)(x) (InverseOperatorแตฃ.proof invOper {id}{x}) ] (x โ–ซ [โˆƒ]-witness([โ†”]-to-[โ†’] (InverseRelationแตฃ.proof invRel) xid)) ๐Ÿ–[ _โ‰ก_ ]-[ [โˆƒ]-proof([โ†”]-to-[โ†’] (InverseRelationแตฃ.proof invRel) xid) ] id ๐Ÿ–-end {- TODO: Should this not be possible without cancellation? inverseOperator-self : โˆ€{x} โ†’ let instance _ = reflexivity(_โจž_) in (x โ‹„ x โ‰ก id) inverseOperator-self {x} = let instance _ = reflexivity(_โจž_) {x} in (x โ‹„ x) ๐Ÿ–[ _โ‰ก_ ]-[ InverseOperatorแตฃ.proof invOper {x}{x} ] [โˆƒ]-witness([โ†”]-to-[โ†’] (InverseRelationแตฃ.proof invRel) (reflexivity(_โจž_) {x})) ๐Ÿ–[ _โ‰ก_ ]-[] โˆƒ.witness(Tuple.right(InverseRelationแตฃ.proof invRel) (reflexivity(_โจž_))) ๐Ÿ–[ _โ‰ก_ ]-[ {!!} ] id ๐Ÿ–-end -}
{ "alphanum_fraction": 0.5738375064, "avg_line_length": 54.3611111111, "ext": "agda", "hexsha": "3d7f7d61026b6666e15eb94fa57f7a988a00d2b9", "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/Monoid/Invertible/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Operator/Monoid/Invertible/Proofs.agda", "max_line_length": 148, "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/Monoid/Invertible/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1609, "size": 3914 }
module PiQ.SAT where open import Data.Unit open import Data.Sum open import Data.Product open import Data.Nat open import Data.Nat.Properties open import Data.List as L open import Data.Maybe open import Relation.Binary.PropositionalEquality open import PiQ.Syntax open import PiQ.Eval open import PiQ.Examples -- Given reversible F : ๐”น^n โ†” ๐”น^n, generate a circuit to find xฬ… such that F(xฬ…) = (๐”ฝ,โ€ฆ) -- via running (LOOP F)(๐”ฝ,๐”ฝฬ…). -- (idโ†” โŠ— F)((LOOP F)(๐”ฝ,๐”ฝฬ…)) = (๐”ฝ,๐”ฝ,โ€ฆ) LOOP : โˆ€ {n} โ†’ ๐”น^ n โ†” ๐”น^ n โ†’ ๐”น ร—แตค ๐”น^ n โ†” ๐”น ร—แตค ๐”น^ n LOOP {0} F = idโ†” LOOP {1} F = idโ†” โŠ— F LOOP {suc (suc n)} F = traceโ‚Š ((dist โŠ• idโ†”) โจพ [A+B]+C=[A+C]+B โจพ (factor โŠ• idโ†”) โจพ ((RESET โจพ (idโ†” โŠ— F) โจพ COPY โจพ (idโ†” โŠ— ! F)) โŠ• idโ†”) โจพ (dist โŠ• idโ†”) โจพ [A+B]+C=[A+C]+B โจพ (factor โŠ• (idโ†” โŠ— INCR))) MERGE : (n m : โ„•) โ†’ ๐”น^ n ร—แตค ๐”น^ m โ†” ๐”น^ (n + m) MERGE 0 m = uniteโ‹†l MERGE 1 0 = uniteโ‹†r MERGE 1 (suc m) = idโ†” MERGE (suc (suc n)) m = assocrโ‹† โจพ (idโ†” โŠ— MERGE (suc n) m) SPLIT : (n m : โ„•) โ†’ ๐”น^ (n + m) โ†” ๐”น^ n ร—แตค ๐”น^ m SPLIT n m = ! MERGE n m ~_ : โˆ€ {n} โ†’ ๐”น^ (1 + n) โ†” ๐”น^ (1 + n) โ†’ ๐”น^ (1 + n) โ†” ๐”น^ (1 + n) ~_ {zero} F = F ~_ {suc n} F = F โจพ NOT โŠ— idโ†” -- Given a function G : ๐”น^n โ†’ ๐”น there exists a reversible Gสณ : ๐”น^(1+n) โ†” ๐”น^(1+n) such that Gสณ(๐”ฝ,xโฟ) = (F(xโฟ),โ€ฆ) -- SAT(Gสณ) = tt iff โˆƒ xโฟ . G(xโฟ) = ๐•‹ SAT : โˆ€ {n} โ†’ ๐”น^ (1 + n) โ†” ๐”น^ (1 + n) โ†’ ๐Ÿ™ โ†” ๐Ÿ™ SAT {n} Gสณ = traceโ‹† (๐”ฝ^ (3 + n)) (idโ†” โŠ— ((idโ†” โŠ— (LOOP (~ Gสณ) โจพ (idโ†” โŠ— SPLIT 1 n))) โจพ (idโ†” โŠ— (assoclโ‹† โจพ (COPY โŠ— idโ†”) โจพ assocrโ‹†)) โจพ assoclโ‹† โจพ (swapโ‹† โŠ— idโ†”) โจพ assocrโ‹† โจพ (idโ†” โŠ— ((idโ†” โŠ— MERGE 1 n) โจพ LOOPโปยน (~ Gสณ))))) where LOOPโปยน : โˆ€ {n} โ†’ ๐”น^ n โ†” ๐”น^ n โ†’ ๐”น ร—แตค ๐”น^ n โ†” ๐”น ร—แตค ๐”น^ n LOOPโปยน F = ! (LOOP F) module SAT_test where -- Examples -- AND(๐”ฝ,a,b) = AND(aโˆงb,a,b) AND : ๐”น^ 3 โ†” ๐”น^ 3 AND = FST2LAST โจพ (dist โจพ (idโ†” โŠ• (idโ†” โŠ— (dist โจพ (idโ†” โŠ• (idโ†” โŠ— swapโ‚Š)) โจพ factor))) โจพ factor) โจพ FST2LASTโปยน NAND : ๐”น^ 3 โ†” ๐”น^ 3 NAND = AND โจพ (NOT โŠ— idโ†”) -- OR(๐”ฝ,a,b) = OR(aโˆจb,a,b) OR : ๐”น^ 3 โ†” ๐”น^ 3 OR = FST2LAST โจพ (dist โจพ ((idโ†” โŠ— (dist โจพ (idโ†” โŠ• (idโ†” โŠ— swapโ‚Š)) โจพ factor)) โŠ• (idโ†” โŠ— (idโ†” โŠ— swapโ‚Š))) โจพ factor) โจพ FST2LASTโปยน NOR : ๐”น^ 3 โ†” ๐”น^ 3 NOR = OR โจพ (NOT โŠ— idโ†”) -- XOR(a,b) = XOR(a xor b,b) XOR : ๐”น^ 2 โ†” ๐”น^ 2 XOR = distl โจพ (idโ†” โŠ• (swapโ‚Š โŠ— idโ†”)) โจพ factorl tests : List โŸฆ ๐”น^ 3 โŸง tests = (๐”ฝ , ๐”ฝ , ๐”ฝ) โˆท (๐”ฝ , ๐”ฝ , ๐•‹) โˆท (๐”ฝ , ๐•‹ , ๐”ฝ) โˆท (๐”ฝ , ๐•‹ , ๐•‹) โˆท (๐•‹ , ๐”ฝ , ๐”ฝ) โˆท (๐•‹ , ๐”ฝ , ๐•‹) โˆท (๐•‹ , ๐•‹ , ๐”ฝ) โˆท (๐•‹ , ๐•‹ , ๐•‹) โˆท [] -- Exโ‚(๐”ฝ,a,b) = ((aโˆงb) xor (aโˆงb),_,_) -- ยฌโˆƒa,b . Exโ‚(๐”ฝ,a,b) = (๐•‹,โ€ฆ) Exโ‚ : ๐”น^ 3 โ†” ๐”น^ 3 Exโ‚ = traceโ‹† (๐”ฝ^ 1) (swapโ‹† โจพ (idโ†” โŠ— AND) โจพ assoclโ‹† โจพ (swapโ‹† โŠ— idโ†”) โจพ assocrโ‹† โจพ (idโ†” โŠ— AND) โจพ assoclโ‹† โจพ (XOR โŠ— idโ†”) โจพ assocrโ‹† โจพ (idโ†” โŠ— ! AND) โจพ assoclโ‹† โจพ (swapโ‹† โŠ— idโ†”) โจพ assocrโ‹† โจพ swapโ‹† ) testsโ‚ = L.map (eval' Exโ‚) tests -- Exโ‚‚(๐”ฝ,a,b) = ((aโˆงb) xor (aโˆจb),_,_) -- โˆƒa,b . Exโ‚‚(๐”ฝ,a,b) = (๐•‹,โ€ฆ) Exโ‚‚ : ๐”น^ 3 โ†” ๐”น^ 3 Exโ‚‚ = traceโ‹† (๐”ฝ^ 1) (swapโ‹† โจพ (idโ†” โŠ— AND) โจพ assoclโ‹† โจพ (swapโ‹† โŠ— idโ†”) โจพ assocrโ‹† โจพ (idโ†” โŠ— OR) โจพ assoclโ‹† โจพ (XOR โŠ— idโ†”) โจพ assocrโ‹† โจพ (idโ†” โŠ— ! OR) โจพ assoclโ‹† โจพ (swapโ‹† โŠ— idโ†”) โจพ assocrโ‹† โจพ swapโ‹† ) testsโ‚‚ = L.map (eval' Exโ‚‚) tests -- Exโ‚ƒ(๐”ฝ,a,b) = (((aโˆงb) โˆง (a xor b)),_,_) -- ยฌโˆƒa,b . Exโ‚ƒ(๐”ฝ,a,b) = (๐•‹,โ€ฆ) Exโ‚ƒ : ๐”น^ 3 โ†” ๐”น^ 3 Exโ‚ƒ = traceโ‹† (๐”ฝ^ 1) (swapโ‹† โจพ assoclโ‹† โจพ (swapโ‹† โŠ— idโ†”) โจพ assocrโ‹† โจพ idโ†” โŠ— F โจพ (idโ†” โŠ— assoclโ‹†) โจพ assoclโ‹† โจพ (AND โŠ— idโ†”) โจพ assocrโ‹† โจพ (idโ†” โŠ— assocrโ‹†) โจพ idโ†” โŠ— ! F โจพ assoclโ‹† โจพ (swapโ‹† โŠ— idโ†”) โจพ assocrโ‹† โจพ swapโ‹†) where F : ๐”น^ 3 โ†” ๐”น^ 3 F = AND โจพ (idโ†” โŠ— XOR) testsโ‚ƒ = L.map (eval' Exโ‚ƒ) tests -- Exโ‚„(๐”ฝ,a,b) = (((aโˆจb) โˆง (a xor b)),_,_) -- โˆƒa,b . Exโ‚„(๐”ฝ,a,b) = (๐•‹,โ€ฆ) Exโ‚„ : ๐”น^ 3 โ†” ๐”น^ 3 Exโ‚„ = traceโ‹† (๐”ฝ^ 1) (swapโ‹† โจพ assoclโ‹† โจพ (swapโ‹† โŠ— idโ†”) โจพ assocrโ‹† โจพ idโ†” โŠ— F โจพ (idโ†” โŠ— assoclโ‹†) โจพ assoclโ‹† โจพ (AND โŠ— idโ†”) โจพ assocrโ‹† โจพ (idโ†” โŠ— assocrโ‹†) โจพ idโ†” โŠ— ! F โจพ assoclโ‹† โจพ (swapโ‹† โŠ— idโ†”) โจพ assocrโ‹† โจพ swapโ‹†) where F : ๐”น^ 3 โ†” ๐”น^ 3 F = OR โจพ (idโ†” โŠ— XOR) testsโ‚„ = L.map (eval' Exโ‚„) tests SAT-tests : List (๐Ÿ™ โ†” ๐Ÿ™) SAT-tests = (SAT AND) โˆท (SAT OR) โˆท (SAT XOR) โˆท (SAT Exโ‚) โˆท (SAT Exโ‚‚) โˆท (SAT Exโ‚ƒ) โˆท (SAT Exโ‚„) โˆท [] results : List (Maybe (ฮฃ[ t โˆˆ ๐•Œ ] โŸฆ t โŸง) ร— โ„•) results = L.map (ฮป c โ†’ eval' c tt) SAT-tests -- (just (๐Ÿ™ , tt) , 3923) โˆท -- (just (๐Ÿ™ , tt) , 2035) โˆท -- (just (๐Ÿ™ , tt) , 1347) โˆท -- (nothing , 10386) โˆท -- (just (๐Ÿ™ , tt) , 4307) โˆท -- (nothing , 11442) โˆท -- (just (๐Ÿ™ , tt) , 4827) โˆท []
{ "alphanum_fraction": 0.3792006363, "avg_line_length": 35.1678321678, "ext": "agda", "hexsha": "4f686a8bd439e6d7a192b27a181f0ccacf11b739", "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": "PiQ/SAT.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": "PiQ/SAT.agda", "max_line_length": 124, "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": "PiQ/SAT.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": 2759, "size": 5029 }
-- Andreas, 2019-03-25, issue #3640, reported by gallais {-# OPTIONS --sized-types #-} -- {-# OPTIONS -v tc.polarity:40 #-} module _ where open import Agda.Builtin.Size module M (_ : Set) where data U : Size โ†’ Set where node : โˆ€ {i} โ†’ U (โ†‘ i) module L (A B : Set) where open M A -- WAS: crash because of number of parameters in size-index checki -- of L.U was wrongly calculated. -- Should succeed.
{ "alphanum_fraction": 0.643373494, "avg_line_length": 18.8636363636, "ext": "agda", "hexsha": "2062ea9432d568e12b3e55ba10995a1d3e529eee", "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/Issue3640.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/Issue3640.agda", "max_line_length": 66, "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/Issue3640.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": 124, "size": 415 }
open import FRP.JS.Delay using ( Delay ) module FRP.JS.Time.Core where record Time : Set where constructor epoch field toDelay : Delay {-# COMPILED_JS Time function(x,v) { return v.epoch(x); } #-} {-# COMPILED_JS epoch function(d) { return d; } #-}
{ "alphanum_fraction": 0.68359375, "avg_line_length": 23.2727272727, "ext": "agda", "hexsha": "a6583887ea6e1a5ee36239c9847f5fa563fd6e45", "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/Time/Core.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/Time/Core.agda", "max_line_length": 61, "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/Time/Core.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": 70, "size": 256 }
module Shallow where open import Level using (_โŠ”_) renaming (suc to lsuc) open import Function open import Data.Unit open import Data.Empty open import Data.Product open import Data.Sum open import Data.Nat hiding (_โŠ”_) open import Data.Fin open import Relation.Binary.PropositionalEquality as PE hiding ([_]; subst) ฮ  : โˆ€ {a b} (A : Set a) (B : A โ†’ Set b) โ†’ Set (a โŠ” b) ฮ  A B = (a : A) โ†’ B a Fam : โˆ€ {a} โ†’ Set a โ†’ Set (lsuc a) Fam {a} I = I โ†’ Set a data ฮฃ' {A B : Set} (f : A โ†’ B) (P : Fam A) : B โ†’ Set where ins : (a : A) โ†’ P a โ†’ ฮฃ' f P (f a) ฮ ' : {I J : Set} (u : I โ†’ J) (P : Fam I) โ†’ Fam J ฮ ' {I} u P j = ฮ  (โˆƒ ฮป i โ†’ u i โ‰ก j) (ฮป { (i , _) โ†’ P i}) _* : {I J : Set} โ†’ (I โ†’ J) โ†’ Fam J โ†’ Fam I (u *) A i = A (u i) Finโบ : โ„• โ†’ Set Finโบ = Fin โˆ˜ suc Vecโบ : โˆ€ {a} โ†’ Set a โ†’ โ„• โ†’ Set a Vecโบ A n = Finโบ n โ†’ A [_] : โˆ€ {a} {A : Set a} โ†’ A โ†’ Vecโบ A 0 [ x ] _ = x _โˆท_ : โˆ€ {a} {A : Set a} {n : โ„•} โ†’ A โ†’ Vecโบ A n โ†’ Vecโบ A (suc n) (x โˆท v) zero = x (x โˆท v) (suc k) = v k module Simple where module _ where mutual data U : Set where zero : U one : U sigma : (A : U) โ†’ (Elem A โ†’ U) โ†’ U pi : (A : U) โ†’ (Elem A โ†’ U) โ†’ U Elem : U โ†’ Set Elem zero = โŠฅ Elem one = โŠค Elem (sigma A B) = ฮฃ (Elem A) (ฮป x โ†’ Elem (B x)) Elem (pi A B) = ฮ  (Elem A) (ฮป x โ†’ Elem (B x)) module Recursive where module _ where โˆ : {n : โ„•} {I : Set} โ†’ (Finโบ n โ†’ Fam I) โ†’ Fam I โˆ {zero} f = f zero โˆ {suc n} f i = f zero i โŠŽ โˆ (ฮป k โ†’ f (suc k)) i โˆ : {n : โ„•} {I : Set} โ†’ (Finโบ n โ†’ Fam I) โ†’ Fam I โˆ {zero} f = f zero โˆ {suc n} f i = f zero i ร— โˆ (ฮป k โ†’ f (suc k)) i data FP : Set where ฮผ : FP ฮฝ : FP mutual data U : Set where fp : {n : โ„•} (A : U) (o : Vecโบ U n) โ†’ FP โ†’ Functor [ A ] o โ†’ Subst o A โ†’ U -- | Substitutions Subst : {n : โ„•} โ†’ Vecโบ U n โ†’ U โ†’ Set Subst {n} o A = (k : Finโบ n) โ†’ Elem (o k) โ†’ Elem A data Functor : {m n : โ„•} โ†’ Vecโบ U m โ†’ Vecโบ U n โ†’ Set where K : {m : โ„•} (v : Vecโบ U m) (A : U) โ†’ Functor v [ A ] ฯ€ : {m : โ„•} (v : Vecโบ U m) (i : Finโบ m) โ†’ Functor v [ v i ] fpF : {m n : โ„•} {v : Vecโบ U m} {o : Vecโบ U n} {A : U} โ†’ FP โ†’ Functor (A โˆท v) o โ†’ Subst o A โ†’ Functor v [ A ] Elem : U โ†’ Set Elem (fp A o ฮผ F u) = {!!} -- LFP F u {!!} where G : Fam (Elem A) โ†’ Fam (Elem A) G = IndFun F u Elem (fp A o ฮฝ F u) = {!!} IdxFam : {m : โ„•} โ†’ Vecโบ U m โ†’ Setโ‚ IdxFam {m} v = (k : Finโบ m) โ†’ Fam (Elem (v k)) โŸฆ_โŸง : {m n : โ„•} {i : Vecโบ U m} {o : Vecโบ U n} โ†’ Functor i o โ†’ (IdxFam i โ†’ IdxFam o) โŸฆ K v A โŸง x k i = Elem A โŸฆ ฯ€ v k โŸง x zero i = x k i โŸฆ ฯ€ v k โŸง x (suc ()) i โŸฆ fpF ฮผ F u โŸง x = {!!} โŸฆ fpF ฮฝ F u โŸง x = {!!} IndFun : {n : โ„•} {A : U} {o : Vecโบ U n} โ†’ (F : Functor [ A ] o) โ†’ -- (F : Fam (Elem A) โ†’ IdxFam o) โ†’ (u : Subst o A) โ†’ (Fam (Elem A) โ†’ Fam (Elem A)) IndFun {n} {A} F u X = โˆ f where f : Finโบ n โ†’ Fam (Elem A) f k = ฮฃ' (u k) (โŸฆ F โŸง (ฮป _ โ†’ X) k) CoindFun : {n : โ„•} {A : U} {o : Vecโบ U n} โ†’ (F : Functor [ A ] o) โ†’ -- (F : Fam (Elem A) โ†’ IdxFam o) โ†’ (u : Subst o A) โ†’ (Fam (Elem A) โ†’ Fam (Elem A)) CoindFun {n} {A} F u X = โˆ f where f : Finโบ n โ†’ Fam (Elem A) f k = ฮ ' (u k) (โŸฆ F โŸง (ฮป _ โ†’ X) k) data LFP {n : โ„•} {A : U} {o : Vecโบ U n} (F : Functor [ A ] o) (u : Subst o A) : Elem A โ†’ Set where -- ฮฑ : (a : Elem A) โ†’ IndFun F u (LFP F u) a โ†’ LFP F u a {- data U : Set where fp : {n : โ„•} (C : Cat) (o : Vec Cat n) โ†’ FP โ†’ Functor [ C ] o โ†’ Subst o C โ†’ U -- | Index of a fibre Cat : Set Cat = ฮฃ U Elem Mor : Cat โ†’ Set Mor C = ? -- (A , x) = -- ฮฃ U (ฮป B โ†’ {!Elem B โ†’ x!}) -- | Substitutions Subst : {n : โ„•} โ†’ Vec Cat n โ†’ Cat โ†’ Set Subst {n} o C = Vec {!!} n data Functor : {m n : โ„•} โ†’ Vec Cat m โ†’ Vec Cat n โ†’ Set where K : {m : โ„•} (v : Vec Cat m) โ†’ {A : U} โ†’ (x : Elem A) โ†’ Functor v [ , x ] ฯ€ : {m : โ„•} (v : Vec Cat m) โ†’ (i : Fin m) โ†’ Functor v [ lookup i v ] fpF : {m n : โ„•} {v : Vec Cat m} {o : Vec Cat n} {C : Cat} โ†’ FP โ†’ Functor (C โˆท v) o โ†’ Subst o C โ†’ Functor v [ C ] Elem : U โ†’ Set Elem x = {!!} -} module DepPoly where module _ where record DPoly (J I : Set) : Setโ‚ where constructor dpoly field -- J <- Shapes -> Pos -> I Pos : Set Shapes : Set s : Shapes โ†’ J f : Shapes โ†’ Pos t : Pos โ†’ I open DPoly โŸฆ_โŸง : {J I : Set} โ†’ DPoly J I โ†’ Fam J โ†’ Fam I โŸฆ dpoly A B s f t โŸง X = ฮฃ' t (ฮ ' f ((s *) X)) data W {I : Set} (P : DPoly I I) : I โ†’ Set where ฮฑ : (i : I) โ†’ โŸฆ P โŸง (W P) i โ†’ W P i record M {I : Set} (P : DPoly I I) (i : I) : Set where coinductive field ฮพ : โŸฆ P โŸง (M P) i data FP : Set where ฮผ : FP ฮฝ : FP mutual data U : Set where fp : {n : โ„•} (A : U) (o : Vecโบ U n) โ†’ FP โ†’ Functor [ A ] o โ†’ Subst o A โ†’ U -- | Substitutions Subst : {n : โ„•} โ†’ Vecโบ U n โ†’ U โ†’ Set Subst {n} o A = (k : Finโบ n) โ†’ Elem (o k) โ†’ Elem A data Functor : {m n : โ„•} โ†’ Vecโบ U m โ†’ Vecโบ U n โ†’ Set where K : {m : โ„•} (v : Vecโบ U m) {I A : U} โ†’ (Elem A โ†’ Elem I) โ†’ Functor v [ I ] ฯ€ : {m : โ„•} (v : Vecโบ U m) (i : Finโบ m) โ†’ Functor v [ v i ] fpF : {m n : โ„•} {v : Vecโบ U m} {o : Vecโบ U n} {A : U} โ†’ FP โ†’ Functor (A โˆท v) o โ†’ Subst o A โ†’ Functor v [ A ] Elem : U โ†’ Set Elem (fp A o ฮผ F u) = ฮฃ (Elem A) (W (Poly F u)) Elem (fp A o ฮฝ F u) = {!!} Poly : {n : โ„•} {I : U} {o : Vecโบ U n} (F : Functor [ I ] o) โ†’ (u : Subst o I) โ†’ DPoly (Elem I) (Elem I) Poly (K ._ {J} {A} B) u = dpoly (Elem A) โŠฅ (ฮป ()) (ฮป ()) (u zero โˆ˜ B) Poly {I = I} (ฯ€ ._ i) u = dpoly (Elem I) (Elem I) id id id Poly (fpF ฮผ F v) u = {!!} Poly (fpF ฮฝ F v) u = {!!}
{ "alphanum_fraction": 0.3990092681, "avg_line_length": 29.6587677725, "ext": "agda", "hexsha": "68d967d90023a894a377230744ec6ba8085954e1", "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/Shallow.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/Shallow.agda", "max_line_length": 82, "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/Shallow.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2560, "size": 6258 }
-- ฮฃ type (also used as existential) and -- cartesian product (also used as conjunction). {-# OPTIONS --without-K --safe #-} module Tools.Product where open import Agda.Primitive infixr 4 _,_ infixr 2 _ร—_ -- Dependent pair type (aka dependent sum, ฮฃ type). record ฮฃ {โ„“ โ„“โ€ฒ : Level} (A : Set โ„“) (B : A โ†’ Set โ„“โ€ฒ) : Set (โ„“ โŠ” โ„“โ€ฒ) where constructor _,_ field projโ‚ : A projโ‚‚ : B projโ‚ open ฮฃ public record ฮฃฯ‰โ‚€ {โ„“} (A : Set โ„“) (B : A โ†’ Setฯ‰) : Setฯ‰ where constructor _,_ field projโ‚ : A projโ‚‚ : B projโ‚ open ฮฃฯ‰โ‚€ public record ฮฃฯ‰โ‚‚ {โ„“} (A : Setฯ‰) (B : A โ†’ Set โ„“) : Setฯ‰ where constructor _,_ field projโ‚ : A projโ‚‚ : B projโ‚ open ฮฃฯ‰โ‚‚ public record ฮฃฯ‰โ‚ƒ (A : Setฯ‰) (B : A โ†’ Setฯ‰) : Setฯ‰ where constructor _,_ field projโ‚ : A projโ‚‚ : B projโ‚ open ฮฃฯ‰โ‚ƒ public record ฮฃฯ‰โ‚„ (A : Setฯ‰โ‚) (B : A โ†’ Setฯ‰) : Setฯ‰โ‚ where constructor _,_ field projโ‚ : A projโ‚‚ : B projโ‚ open ฮฃฯ‰โ‚„ public -- Existential quantification. โˆƒ : {โ„“ โ„“โ€ฒ : Level} โ†’ {A : Set โ„“} โ†’ (A โ†’ Set โ„“โ€ฒ) โ†’ Set (โ„“ โŠ” โ„“โ€ฒ) โˆƒ = ฮฃ _ โˆƒโ‚‚ : {โ„“ โ„“โ€ฒ โ„“โ€ณ : Level} โ†’ {A : Set โ„“} {B : A โ†’ Set โ„“โ€ฒ} (C : (x : A) โ†’ B x โ†’ Set โ„“โ€ณ) โ†’ Set (โ„“ โŠ” โ„“โ€ฒ โŠ” โ„“โ€ณ) โˆƒโ‚‚ C = โˆƒ ฮป a โ†’ โˆƒ ฮป b โ†’ C a b โˆƒฯ‰โ‚ƒ : {A : Setฯ‰} โ†’ (A โ†’ Setฯ‰) โ†’ Setฯ‰ โˆƒฯ‰โ‚ƒ = ฮฃฯ‰โ‚ƒ _ โˆƒฯ‰โ‚ƒยฒ : {A : Setฯ‰} {B : A โ†’ Setฯ‰} (C : (x : A) โ†’ B x โ†’ Setฯ‰) โ†’ Setฯ‰ โˆƒฯ‰โ‚ƒยฒ C = โˆƒฯ‰โ‚ƒ ฮป a โ†’ โˆƒฯ‰โ‚ƒ ฮป b โ†’ C a b โˆƒฯ‰โ‚„ : {A : Setฯ‰โ‚} โ†’ (A โ†’ Setฯ‰) โ†’ Setฯ‰โ‚ โˆƒฯ‰โ‚„ = ฮฃฯ‰โ‚„ _ -- Cartesian product. _ร—_ : {โ„“ โ„“โ€ฒ : Level} โ†’ (A : Set โ„“) โ†’ (B : Set โ„“โ€ฒ) โ†’ Set (โ„“ โŠ” โ„“โ€ฒ) A ร— B = ฮฃ A (ฮป x โ†’ B) _ร—ฯ‰โ‚‚_ : {โ„“ : Level} โ†’ (A : Setฯ‰) โ†’ (B : Set โ„“) โ†’ Setฯ‰ A ร—ฯ‰โ‚‚ B = ฮฃฯ‰โ‚‚ A (ฮป x โ†’ B) _ร—ฯ‰โ‚ƒ_ : (A : Setฯ‰) โ†’ (B : Setฯ‰) โ†’ Setฯ‰ A ร—ฯ‰โ‚ƒ B = ฮฃฯ‰โ‚ƒ A (ฮป x โ†’ B)
{ "alphanum_fraction": 0.5291616039, "avg_line_length": 19.5952380952, "ext": "agda", "hexsha": "7a4461e06f9c0d669b490ba93ed400badd77df53", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Tools/Product.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "loic-p/logrel-mltt", "max_issues_repo_path": "Tools/Product.agda", "max_line_length": 73, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Tools/Product.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 791, "size": 1646 }
-- Andreas, 2012-11-22 issue #729, abstract aliases -- Andreas, 2016-07-19 issue #2102, better fix of #418 helps! module Issue729 where abstract B = Set Bโ‚ = B Bโ‚‚ = Set abstract foo : Setโ‚ foo = x where x = B mutual abstract D = C C = B abstract mutual F = E E = D -- other stuff private A = Set Y = let X = Set in Set
{ "alphanum_fraction": 0.5950413223, "avg_line_length": 11.34375, "ext": "agda", "hexsha": "cf53adae8fd8a81efeed65c9673b64cec464ea5d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/Issue729.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/Issue729.agda", "max_line_length": 61, "max_stars_count": 3, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/Issue729.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": 133, "size": 363 }
{-# OPTIONS --without-K --safe #-} open import Categories.Category module Categories.Category.Site {o โ„“ e} (C : Category o โ„“ e) where open import Level open import Data.Product using (ฮฃ; _,_; โˆƒโ‚‚) open Category C private variable X Y Z : Obj record Coverage {i} j {I : Obj โ†’ Set i} (coveringโ‚€ : โˆ€ {X} โ†’ I X โ†’ Obj) (coveringโ‚ : โˆ€ {X} (i : I X) โ†’ coveringโ‚€ i โ‡’ X) : Set (i โŠ” suc j โŠ” o โŠ” โ„“ โŠ” e) where field J : โˆ€ (g : Y โ‡’ Z) โ†’ Set j universalโ‚€ : โˆ€ {g : Y โ‡’ Z} โ†’ J g โ†’ Obj universalโ‚ : โˆ€ {g : Y โ‡’ Z} (j : J g) โ†’ universalโ‚€ j โ‡’ Y commute : โˆ€ {g : Y โ‡’ Z} (j : J g) โ†’ โˆƒโ‚‚ (ฮป i k โ†’ g โˆ˜ universalโ‚ j โ‰ˆ coveringโ‚ i โˆ˜ k) record Site i j : Set (suc i โŠ” suc j โŠ” o โŠ” โ„“ โŠ” e) where field I : Obj โ†’ Set i coveringโ‚€ : โˆ€ {X} โ†’ I X โ†’ Obj coveringโ‚ : โˆ€ {X} (i : I X) โ†’ coveringโ‚€ i โ‡’ X coverage : Coverage j coveringโ‚€ coveringโ‚ module coverage = Coverage coverage open coverage public
{ "alphanum_fraction": 0.5351239669, "avg_line_length": 28.4705882353, "ext": "agda", "hexsha": "51198a829f2d873672022d174c509fe2809da5e1", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Site.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Site.agda", "max_line_length": 99, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Site.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 342, "size": 968 }
module JVM.Model.Properties where open import Data.List open import Data.List.Properties open import Data.List.Relation.Binary.Permutation.Propositional open import Data.List.Relation.Binary.Permutation.Propositional.Properties open import Data.Product hiding (map) open import Relation.Unary using (Pred) open import Relation.Binary.PropositionalEquality open import Relation.Ternary.Core open import Relation.Ternary.Structures open import Relation.Ternary.Structures.Syntax open import Relation.Ternary.Construct.Bag.Properties open import Function module _ {p t} {T : Set t} {P : Pred _ p} where open import JVM.Model (List T) open import Data.List.Relation.Unary.All -- If you know the split and what is bubbling up from the left and right parts, -- then you know what bubbles up from the composite. source : โˆ€ {ฮฆโ‚ : Intf} โ†’ ฮฆโ‚ โˆ™ ฮฆโ‚‚ โ‰ฃ ฮฆ โ†’ All P (up ฮฆโ‚) โ†’ All P (up ฮฆโ‚‚) โ†’ All P (up ฮฆ) source (ex {uโ‚} {uโ‚‚} (sub xโ‚ xโ‚‚) (sub xโ‚ƒ xโ‚„) xโ‚… xโ‚†) puโ‚ puโ‚‚ = joinAll (ฮป ()) xโ‚… puโ‚' puโ‚‚' where puโ‚‚' = projโ‚ (splitAll (ฮป where dup p โ†’ p , p) xโ‚‚ puโ‚‚) puโ‚' = projโ‚ (splitAll (ฮป where dup p โ†’ p , p) xโ‚„ puโ‚) -- If you know the split and what is bubbling up from the left and flowing down the composite, -- then you know what flows down the right part. sinkแตฃ : โˆ€ {ฮฆโ‚ : Intf} โ†’ ฮฆโ‚ โˆ™ ฮฆโ‚‚ โ‰ฃ ฮฆ โ†’ All P (up ฮฆโ‚) โ†’ All P (down ฮฆ) โ†’ All P (down ฮฆโ‚‚) sinkแตฃ (ex (sub xโ‚ xโ‚‚) (sub xโ‚ƒ xโ‚„) xโ‚… xโ‚†) puโ‚ puโ‚‚ = joinAll (ฮป ()) xโ‚ƒ pdโ‚' peโ‚ where pdโ‚' = projโ‚ (splitAll (ฮป where dup p โ†’ p , p) xโ‚† puโ‚‚) peโ‚ = projโ‚‚ (splitAll (ฮป where dup p โ†’ p , p) xโ‚„ puโ‚) -- The same, but different. sinkโ‚— : โˆ€ {ฮฆโ‚ ฮฆโ‚‚ ฮฆ : Intf} โ†’ ฮฆโ‚ โˆ™ ฮฆโ‚‚ โ‰ฃ ฮฆ โ†’ All P (up ฮฆโ‚‚) โ†’ All P (down ฮฆ) โ†’ All P (down ฮฆโ‚) sinkโ‚— ฯƒ ups downs = sinkแตฃ (โˆ™-comm ฯƒ) ups downs -- {- Mapping along any injection yields a model morphism -} -- module _ {a b} {A : Set a} {B : Set b} (๐‘š : A โ†ฃ B) where -- open Injection ๐‘š -- private -- โŸฆ_โŸง = ฮป a โ†’ f a -- j = map โŸฆ_โŸง -- open import JVM.Model A as L -- open import JVM.Model B as R -- import Relation.Ternary.Construct.Duplicate.Properties as D -- import Relation.Ternary.Construct.Empty.Properties as E -- module OMM = MonoidMorphism (bagMap (D.f-morphism ๐‘š)) -- module DMM = MonoidMorphism (bagMap (E.โŠฅ-morphism โŸฆ_โŸง)) -- import Relation.Ternary.Construct.Bag.Overlapping as O -- import Relation.Ternary.Construct.Bag.Disjoint as D -- private -- sub-lemmaโบ : โˆ€ {xs ys u d} โ†’ xs L.- ys โ‰ฃ (u L.โ‡… d) โ†’ j xs R.- j ys โ‰ฃ (j u R.โ‡… j d) -- sub-lemmaโบ (sub x xโ‚) = R.sub (DMM.j-โˆ™ x) (OMM.j-โˆ™ xโ‚) -- sub-lemmaโป : โˆ€ {xs ys u d} โ†’ j xs R.- j ys โ‰ฃ (u R.โ‡… d) โ†’ -- โˆƒโ‚‚ ฮป u' d' โ†’ xs L.- ys โ‰ฃ (u' L.โ‡… d') ร— u โ‰ก j u' ร— d โ‰ก j d' -- sub-lemmaโป (sub x y) -- with _ , x' , refl , refl โ† D.map-inv _ โŸฆ_โŸง x -- | _ , y' , refl , eq โ† O.map-inv _ โŸฆ_โŸง y -- with refl โ† map-injective ๐‘š eq -- = -, -, (L.sub x' y' , refl , refl) -- โŸฆโŸง-morphism : SemigroupMorphism L.intf-isSemigroup R.intf-isSemigroup -- SemigroupMorphism.j โŸฆโŸง-morphism (e โ‡… d) = (j e) R.โ‡… (j d) -- SemigroupMorphism.jcong โŸฆโŸง-morphism (ฯโ‚ , ฯโ‚‚) = mapโบ โŸฆ_โŸง ฯโ‚ , mapโบ โŸฆ_โŸง ฯโ‚‚ -- SemigroupMorphism.j-โˆ™ โŸฆโŸง-morphism (ex x xโ‚ ฯƒโ‚ ฯƒโ‚‚) = -- R.ex (sub-lemmaโบ x) (sub-lemmaโบ xโ‚) (DMM.j-โˆ™ ฯƒโ‚) (OMM.j-โˆ™ ฯƒโ‚‚) -- SemigroupMorphism.j-โˆ™โป โŸฆโŸง-morphism (ex x xโ‚ ฯƒโ‚ ฯƒโ‚‚) with sub-lemmaโป x -- ... | _ , _ , y , refl , refl with sub-lemmaโป xโ‚ -- ... | _ , _ , yโ‚ , refl , refl with _ , ฯ„โ‚ , refl โ† DMM.j-โˆ™โป ฯƒโ‚ | _ , ฯ„โ‚‚ , refl โ† OMM.j-โˆ™โป ฯƒโ‚‚ -- = -, L.ex y yโ‚ ฯ„โ‚ ฯ„โ‚‚ , refl
{ "alphanum_fraction": 0.6044607566, "avg_line_length": 42.6746987952, "ext": "agda", "hexsha": "1d7ff4d259c0e12cbd3d69934945a553b1724a95", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:37:15.000Z", "max_forks_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ajrouvoet/jvm.agda", "max_forks_repo_path": "src/JVM/Model/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "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": "ajrouvoet/jvm.agda", "max_issues_repo_path": "src/JVM/Model/Properties.agda", "max_line_length": 98, "max_stars_count": 6, "max_stars_repo_head_hexsha": "c84bc6b834295ac140ff30bfc8e55228efbf6d2a", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ajrouvoet/jvm.agda", "max_stars_repo_path": "src/JVM/Model/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-28T21:49:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T14:07:17.000Z", "num_tokens": 1404, "size": 3542 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Functors ------------------------------------------------------------------------ -- Note that currently the functor laws are not included here. {-# OPTIONS --without-K --safe #-} module Category.Functor where open import Function open import Level open import Relation.Binary.PropositionalEquality record RawFunctor {โ„“} (F : Set โ„“ โ†’ Set โ„“) : Set (suc โ„“) where infixl 4 _<$>_ _<$_ infixl 1 _<&>_ field _<$>_ : โˆ€ {A B} โ†’ (A โ†’ B) โ†’ F A โ†’ F B _<$_ : โˆ€ {A B} โ†’ A โ†’ F B โ†’ F A x <$ y = const x <$> y _<&>_ : โˆ€ {A B} โ†’ F A โ†’ (A โ†’ B) โ†’ F B _<&>_ = flip _<$>_ -- A functor morphism from Fโ‚ to Fโ‚‚ is an operation op such that -- op (Fโ‚ f x) โ‰ก Fโ‚‚ f (op x) record Morphism {โ„“} {Fโ‚ Fโ‚‚ : Set โ„“ โ†’ Set โ„“} (funโ‚ : RawFunctor Fโ‚) (funโ‚‚ : RawFunctor Fโ‚‚) : Set (suc โ„“) where open RawFunctor field op : โˆ€{X} โ†’ Fโ‚ X โ†’ Fโ‚‚ X op-<$> : โˆ€{X Y} (f : X โ†’ Y) (x : Fโ‚ X) โ†’ op (funโ‚ ._<$>_ f x) โ‰ก funโ‚‚ ._<$>_ f (op x)
{ "alphanum_fraction": 0.463099631, "avg_line_length": 25.8095238095, "ext": "agda", "hexsha": "fd7f607f7a52df9fc9e51ee6a2c647aa92996428", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Category/Functor.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Category/Functor.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/Category/Functor.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 362, "size": 1084 }
module Naturals where data Nat : Set where zero : Nat suc : Nat -> Nat infixl 60 _+_ infixl 80 _*_ _+_ : Nat -> Nat -> Nat zero + m = m suc n + m = suc (n + m) _*_ : Nat -> Nat -> Nat zero * m = zero suc n * m = m + n * m {-# BUILTIN NATURAL Nat #-} {-# BUILTIN ZERO zero #-} {-# BUILTIN SUC suc #-} {-# BUILTIN NATPLUS _+_ #-} {-# BUILTIN NATTIMES _*_ #-}
{ "alphanum_fraction": 0.5272727273, "avg_line_length": 16.0416666667, "ext": "agda", "hexsha": "8f4174eb590c0e79741d3b7a20625a278e88d9e5", "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": "examples/AIM6/HelloAgda/Naturals.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": "examples/AIM6/HelloAgda/Naturals.agda", "max_line_length": 29, "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/AIM6/HelloAgda/Naturals.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": 142, "size": 385 }
-- Two fun examples of generic programming using univalence {-# OPTIONS --cubical --safe #-} module Cubical.Experiments.Generic where open import Agda.Builtin.String open import Agda.Builtin.List open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv open import Cubical.Foundations.Univalence open import Cubical.Data.Nat open import Cubical.Data.Int open import Cubical.Data.Prod ---------------------------------------------------------------------------- -- -- Dan Licata's example from slide 47 of: -- http://dlicata.web.wesleyan.edu/pubs/l13jobtalk/l13jobtalk.pdf There : Typeโ‚€ โ†’ Typeโ‚€ There X = List (โ„• ร— String ร— (X ร— โ„•)) Database : Typeโ‚€ Database = There (โ„• ร— โ„•) us : Database us = (4 , "John" , (30 , 5) , 1956) โˆท (8 , "Hugo" , (29 , 12) , 1978) โˆท (15 , "James" , (1 , 7) , 1968) โˆท (16 , "Sayid" , (2 , 10) , 1967) โˆท (23 , "Jack" , (3 , 12) , 1969) โˆท (42 , "Sun" , (20 , 3) , 1980) โˆท [] convert : Database โ†’ Database convert d = transport (ฮป i โ†’ There (swapEq โ„• โ„• i)) d -- Swap the dates of the American database to get the European format eu : Database eu = convert us -- A sanity check _ : us โ‰ก convert eu _ = refl ---------------------------------------------------------------------------- -- -- Example inspired by: -- -- Scrap Your Boilerplate: A Practical Design Pattern for Generic Programming -- Ralf Lรคmmel & Simon Peyton Jones, TLDI'03 Address : Typeโ‚€ Address = String Name : Typeโ‚€ Name = String data Person : Typeโ‚€ where P : Name โ†’ Address โ†’ Person data Salary (A : Typeโ‚€) : Typeโ‚€ where S : A โ†’ Salary A data Employee (A : Typeโ‚€) : Typeโ‚€ where E : Person โ†’ Salary A โ†’ Employee A Manager : Typeโ‚€ โ†’ Typeโ‚€ Manager A = Employee A -- First test of "mutual" mutual data Dept (A : Typeโ‚€) : Typeโ‚€ where D : Name โ†’ Manager A โ†’ List (SubUnit A) โ†’ Dept A data SubUnit (A : Typeโ‚€) : Typeโ‚€ where PU : Employee A โ†’ SubUnit A DU : Dept A โ†’ SubUnit A data Company (A : Typeโ‚€) : Typeโ‚€ where C : List (Dept A) โ†’ Company A -- A small example anders : Employee Int anders = E (P "Anders" "Pittsburgh") (S (pos 2500)) andrea : Employee Int andrea = E (P "Andrea" "Copenhagen") (S (pos 2000)) andreas : Employee Int andreas = E (P "Andreas" "Gothenburg") (S (pos 3000)) -- For now we have a small company genCom : Company Int genCom = C ( D "Research" andreas (PU anders โˆท PU andrea โˆท []) โˆท []) -- Increase the salary for everyone by 1 incSalary : Company Int โ†’ Company Int incSalary c = transport (ฮป i โ†’ Company (sucPathInt i)) c genCom1 : Company Int genCom1 = incSalary genCom -- Increase the salary more incSalaryโ„• : โ„• โ†’ Company Int โ†’ Company Int incSalaryโ„• n c = transport (ฮป i โ†’ Company (addEq n i)) c genCom2 : Company Int genCom2 = incSalaryโ„• 2 genCom genCom10 : Company Int genCom10 = incSalaryโ„• 10 genCom
{ "alphanum_fraction": 0.6354883081, "avg_line_length": 23.4516129032, "ext": "agda", "hexsha": "7996f92c64ceb66f27d2b771fc1701f02b3ed861", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/Experiments/Generic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cj-xu/cubical", "max_issues_repo_path": "Cubical/Experiments/Generic.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/Experiments/Generic.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 905, "size": 2908 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types import LibraBFT.Impl.OBM.ConfigHardCoded as ConfigHardCoded open import LibraBFT.Impl.OBM.Logging.Logging import LibraBFT.Impl.Storage.DiemDB.DiemDB as DiemDB import LibraBFT.Impl.Types.OnChainConfig.ValidatorSet as ValidatorSet open import LibraBFT.ImplShared.Consensus.Types open import Optics.All open import Util.ByteString as BS import Util.Encode as S open import Util.Hash open import Util.Prelude ------------------------------------------------------------------------------ open import Data.String using (String) module LibraBFT.Impl.Consensus.StateComputerByteString where -- LBFT-OBM-DIFF: In Rust, the following might throw BlockNotFound -- in execution_correctness_client.execute_block (not needed/implemented). -- In OBM we call this error ErrECCBlockNotFound so it is easy to see it is -- defined, caught, but never thrown. compute : StateComputerComputeType compute _self block _parentBlockId = StateComputeResultโˆ™new (Versionโˆ™new (block ^โˆ™ bEpoch {-โˆ™ eEpoch-}) (block ^โˆ™ bRound {-โˆ™ rRound-})) <$> maybeEC where getES : ByteString โ†’ Either (List String) EpochState maybeEC : Either (List String) (Maybe EpochState) maybeEC = case block ^โˆ™ bBlockData โˆ™ bdBlockType of ฮป where (Proposal {-Payload [-}a{-])-} _author) โ†’ if BSโˆ™isPrefixOf ConfigHardCoded.ePOCHCHANGE a then just <$> getES a else pure nothing NilBlock โ†’ pure nothing Genesis โ†’ pure nothing getES bs = do let bs' = BSโˆ™drop (BSโˆ™length ConfigHardCoded.ePOCHCHANGE) bs case S.decode bs' of ฮป where (Left e) โ†’ Left ("StateComputerByteString" โˆท "compute" โˆท "decode" โˆท {-T.pack-} e โˆท []) (Right vv) โ†’ Right (EpochStateโˆ™new (block ^โˆ™ bEpoch + 1) vv) -- LBFT-OBM-DIFF : gets block instead of vector of hashes -- TODO-2: consider converting to EitherD before proving anything about this commit : StateComputerCommitType commit self db (ExecutedBlockโˆ™new _b (StateComputeResultโˆ™new version _)) liws = case (DiemDB.saveTransactions.E db (just liws)) of ฮป where (Left e) โ†’ Left (errText e) (Right db') โ†’ pure ( (self & scObmVersion โˆ™~ version) , db' , (maybeS (liws ^โˆ™ liwsLedgerInfo โˆ™ liNextEpochState) nothing $ ฮป (EpochStateโˆ™new e vv) โ†’ just (ReconfigEventEpochChangeโˆ™new (OnChainConfigPayloadโˆ™new e (ValidatorSet.obmFromVV vv)))) ) -- LBFT-OBM-DIFF : completely different syncTo : StateComputerSyncToType syncTo liws = maybeS (liws ^โˆ™ liwsNextEpochState) (Left ("StateComputerByteString" โˆท "syncTo" โˆท "Nothing" โˆท [])) $ ฮป (EpochStateโˆ™new e vv) โ†’ Right (ReconfigEventEpochChangeโˆ™new (OnChainConfigPayloadโˆ™new e (ValidatorSet.obmFromVV vv)))
{ "alphanum_fraction": 0.6632555165, "avg_line_length": 44.6714285714, "ext": "agda", "hexsha": "e8944758aac218a46c69578f7468773258cd5b2d", "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/Consensus/StateComputerByteString.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/Consensus/StateComputerByteString.agda", "max_line_length": 111, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/Consensus/StateComputerByteString.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 858, "size": 3127 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Data.Vec.OperationsNat where open import Cubical.Foundations.Prelude open import Cubical.Data.Empty as โŠฅ open import Cubical.Data.Nat renaming (_+_ to _+n_; _ยท_ to _ยทn_) open import Cubical.Data.Nat.Order open import Cubical.Data.Vec.Base open import Cubical.Data.Vec.Properties open import Cubical.Data.Sigma open import Cubical.Data.Sum open import Cubical.Relation.Nullary private variable โ„“ : Level ----------------------------------------------------------------------------- -- Generating Vector genฮดโ„•-Vec : {A : Type โ„“} โ†’ (m k : โ„•) โ†’ (a b : A) โ†’ Vec A m genฮดโ„•-Vec zero k a b = [] genฮดโ„•-Vec (suc m) k a b with (discreteโ„• k m) ... | yes p = a โˆท replicate b ... | no ยฌp = b โˆท (genฮดโ„•-Vec m k a b) -- some results are easier / false without general a and b ฮดโ„•-Vec : (m : โ„•) โ†’ (k : โ„•) โ†’ Vec โ„• m ฮดโ„•-Vec m k = genฮดโ„•-Vec m k 1 0 ฮดโ„•-Vec-nโ‰คkโ†’โ‰ก : (m k : โ„•) โ†’ (m โ‰ค k) โ†’ ฮดโ„•-Vec m k โ‰ก replicate 0 ฮดโ„•-Vec-nโ‰คkโ†’โ‰ก zero k r = refl ฮดโ„•-Vec-nโ‰คkโ†’โ‰ก (suc m) k r with (discreteโ„• k m) ... | yes p = โŠฅ.rec (<โ†’โ‰ข r (sym p)) ... | no ยฌp = cong (ฮป X โ†’ 0 โˆท X) (ฮดโ„•-Vec-nโ‰คkโ†’โ‰ก m k (โ‰ค-trans โ‰ค-sucโ„• r)) ฮดโ„•-Vec-k<nโ†’โ‰ข : (m k : โ„•) โ†’ (k < m) โ†’ (ฮดโ„•-Vec m k โ‰ก replicate 0 โ†’ โŠฅ) ฮดโ„•-Vec-k<nโ†’โ‰ข zero k r = โŠฅ.rec (ยฌ-<-zero r) ฮดโ„•-Vec-k<nโ†’โ‰ข (suc m) k r q with (discreteโ„• k m) | (โ‰ค-split r) ... | yes p | z = compute-eqโ„• 1 0 (fst (VecPath.encode _ _ q)) ... | no ยฌp | inl x = ฮดโ„•-Vec-k<nโ†’โ‰ข m k (pred-โ‰ค-pred x) (snd (VecPath.encode _ _ q)) ... | no ยฌp | inr x = ยฌp (injSuc x) ----------------------------------------------------------------------------- -- Point wise add _+n-vec_ : {m : โ„•} โ†’ Vec โ„• m โ†’ Vec โ„• m โ†’ Vec โ„• m _+n-vec_ {.zero} [] [] = [] _+n-vec_ {.(suc _)} (k โˆท v) (l โˆท v') = (k +n l) โˆท (v +n-vec v') +n-vec-lid : {m : โ„•} โ†’ (v : Vec โ„• m) โ†’ replicate 0 +n-vec v โ‰ก v +n-vec-lid {.zero} [] = refl +n-vec-lid {.(suc _)} (k โˆท v) = cong (_โˆท_ k) (+n-vec-lid v) +n-vec-rid : {m : โ„•} โ†’ (v : Vec โ„• m) โ†’ v +n-vec replicate 0 โ‰ก v +n-vec-rid {.zero} [] = refl +n-vec-rid {.(suc _)} (k โˆท v) = congโ‚‚ _โˆท_ (+-zero k) (+n-vec-rid v) +n-vec-assoc : {m : โ„•} โ†’ (v v' v'' : Vec โ„• m) โ†’ v +n-vec (v' +n-vec v'') โ‰ก (v +n-vec v') +n-vec v'' +n-vec-assoc [] [] [] = refl +n-vec-assoc (k โˆท v) (l โˆท v') (p โˆท v'') = congโ‚‚ _โˆท_ (+-assoc k l p) (+n-vec-assoc v v' v'') +n-vec-comm : {m : โ„•} โ†’ (v v' : Vec โ„• m) โ†’ v +n-vec v' โ‰ก v' +n-vec v +n-vec-comm {.zero} [] [] = refl +n-vec-comm {.(suc _)} (k โˆท v) (l โˆท v') = congโ‚‚ _โˆท_ (+-comm k l) (+n-vec-comm v v') ----------------------------------------------------------------------------- -- Equlity on Vec โ„• +n-vecSplitReplicate0 : {m : โ„•} โ†’ (v v' : Vec โ„• m) โ†’ (v +n-vec v') โ‰ก replicate 0 โ†’ (v โ‰ก replicate 0) ร— (v' โ‰ก replicate 0) +n-vecSplitReplicate0 [] [] p = refl , refl +n-vecSplitReplicate0 (k โˆท v) (l โˆท v') p with VecPath.encode ((k +n l) โˆท (v +n-vec v')) (replicate 0) p ... | pkl , pvv' = (congโ‚‚ _โˆท_ (fst (m+nโ‰ก0โ†’mโ‰ก0ร—nโ‰ก0 pkl)) (fst (+n-vecSplitReplicate0 v v' pvv'))) , (congโ‚‚ _โˆท_ (snd (m+nโ‰ก0โ†’mโ‰ก0ร—nโ‰ก0 pkl)) (snd (+n-vecSplitReplicate0 v v' pvv'))) pred-vec-โ‰ข0 : {m : โ„•} โ†’ (v : Vec โ„• m) โ†’ (v โ‰ก replicate 0 โ†’ โŠฅ) โ†’ ฮฃ[ k โˆˆ โ„• ] (ฮฃ[ v' โˆˆ Vec โ„• m ] ( ฮฃ[ r โˆˆ (k < m) ] v โ‰ก v' +n-vec (ฮดโ„•-Vec m k))) pred-vec-โ‰ข0 {zero} [] ยฌq = โŠฅ.rec (ยฌq refl) pred-vec-โ‰ข0 {(suc m)} (l โˆท v) ยฌq with (discreteโ„• l 0) -- case l โ‰ก 0 pred-vec-โ‰ข0 {(suc m)} (l โˆท v) ยฌq | yes p with pred-vec-โ‰ข0 v (ฮป r โ†’ ยฌq (congโ‚‚ _โˆท_ p r)) ... | k , v' , infkm , eqvv' = k , ((0 โˆท v') , ((โ‰ค-trans infkm โ‰ค-sucโ„•) , helper)) where helper : _ helper with (discreteโ„• k m) ... | yes pp = โŠฅ.rec (<โ†’โ‰ข (fst infkm , +-suc _ _ โˆ™ cong suc (snd infkm)) (cong suc pp)) ... | no ยฌpp = congโ‚‚ _โˆท_ p eqvv' -- case l โ‰ข 0 pred-vec-โ‰ข0 {(suc m)} (l โˆท v) ยฌq | no ยฌp = m , ((predโ„• l โˆท v) , (โ‰ค-refl , helper)) where helper : _ helper with (discreteโ„• m m) ... | yes pp = congโ‚‚ _โˆท_ (sym (+-suc _ _ โˆ™ +-zero _ โˆ™ sym (suc-predโ„• l ยฌp))) (sym (+n-vec-rid v)) ... | no ยฌpp = โŠฅ.rec (ยฌpp refl) -- split + concat vec results sep-vec : (k l : โ„•) โ†’ Vec โ„• (k +n l) โ†’ (Vec โ„• k) ร— (Vec โ„• l ) sep-vec zero l v = [] , v sep-vec (suc k) l (x โˆท v) = (x โˆท fst (sep-vec k l v)) , (snd (sep-vec k l v)) sep-vec-fst : (k l : โ„•) โ†’ (v : Vec โ„• k) โ†’ (v' : Vec โ„• l) โ†’ fst (sep-vec k l (v ++ v')) โ‰ก v sep-vec-fst zero l [] v' = refl sep-vec-fst (suc k) l (x โˆท v) v' = cong (ฮป X โ†’ x โˆท X) (sep-vec-fst k l v v') sep-vec-snd : (k l : โ„•) โ†’ (v : Vec โ„• k) โ†’ (v' : Vec โ„• l) โ†’ snd (sep-vec k l (v ++ v')) โ‰ก v' sep-vec-snd zero l [] v' = refl sep-vec-snd (suc k) l (x โˆท v) v' = sep-vec-snd k l v v' sep-vec-id : (k l : โ„•) โ†’ (v : Vec โ„• (k +n l)) โ†’ fst (sep-vec k l v) ++ snd (sep-vec k l v) โ‰ก v sep-vec-id zero l v = refl sep-vec-id (suc k) l (x โˆท v) = cong (ฮป X โ†’ x โˆท X) (sep-vec-id k l v) rep-concat : (k l : โ„•) โ†’ {B : Type โ„“} โ†’ (b : B) โ†’ replicate {_} {k} {B} b ++ replicate {_} {l} {B} b โ‰ก replicate {_} {k +n l} {B} b rep-concat zero l b = refl rep-concat (suc k) l b = cong (ฮป X โ†’ b โˆท X) (rep-concat k l b) +n-vec-concat : (k l : โ„•) โ†’ (v w : Vec โ„• k) โ†’ (v' w' : Vec โ„• l) โ†’ (v +n-vec w) ++ (v' +n-vec w') โ‰ก (v ++ v') +n-vec (w ++ w') +n-vec-concat zero l [] [] v' w' = refl +n-vec-concat (suc k) l (x โˆท v) (y โˆท w) v' w' = cong (ฮป X โ†’ x +n y โˆท X) (+n-vec-concat k l v w v' w')
{ "alphanum_fraction": 0.4859795377, "avg_line_length": 40.9147286822, "ext": "agda", "hexsha": "9c1d6940b2f8fa9ccd4fca7d7fe55d828b66ea26", "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/Data/Vec/OperationsNat.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/Data/Vec/OperationsNat.agda", "max_line_length": 103, "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/Data/Vec/OperationsNat.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": 2366, "size": 5278 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cohomology.Theory module cohomology.Coproduct {i} (CT : CohomologyTheory i) (n : โ„ค) (X Y : Ptd i) where open CohomologyTheory CT open import cohomology.Sigma CT private P : Bool โ†’ Ptd i P true = X P false = Y C-โŠ” : C n (X โŠ™โŠ” Y) โ‰ƒแดณ C n (X โŠ™โˆจ Y) ร—แดณ C2 n C-โŠ” = (ร—แดณ-emap (C-emap n (โ‰ƒ-to-โŠ™โ‰ƒ ( BigWedge-Bool-equiv-Wedge P โˆ˜e BigWedge-emap-l P lower-equiv) idp)) (idiso _)) โปยนแดณ โˆ˜eแดณ C-ฮฃ n (โŠ™Lift {j = i} โŠ™Bool) (P โˆ˜ lower) โˆ˜eแดณ C-emap n (โ‰ƒ-to-โŠ™โ‰ƒ ( ฮฃBool-equiv-โŠ” (deโŠ™ โˆ˜ P) โˆ˜e ฮฃ-emap-l (deโŠ™ โˆ˜ P) lower-equiv) idp)
{ "alphanum_fraction": 0.5412844037, "avg_line_length": 26.16, "ext": "agda", "hexsha": "99d873053dd558f83093f751fe090b9a4ace19e6", "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/cohomology/Coproduct.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/cohomology/Coproduct.agda", "max_line_length": 65, "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/cohomology/Coproduct.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": 306, "size": 654 }
open import Agda.Builtin.Unit open import Agda.Builtin.Bool open import Agda.Builtin.Sigma data โŠฅ : Set where type : Bool โ†’ Set type true = โŠค type false = โŠฅ record Bad : Set where constructor b field .f : ฮฃ Bool type test : Bad โ†’ Bool test (b (x , y)) = x
{ "alphanum_fraction": 0.6654275093, "avg_line_length": 14.1578947368, "ext": "agda", "hexsha": "b44d58b101f4997901e8e53a51a374e9e571ccf1", "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/Issue3056.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/Issue3056.agda", "max_line_length": 30, "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/Issue3056.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": 90, "size": 269 }
module Negative3 where data Mu (F : Set -> Set) : Set where inn : F (Mu F) -> Mu F
{ "alphanum_fraction": 0.5666666667, "avg_line_length": 12.8571428571, "ext": "agda", "hexsha": "117337f24827294f582c8be9cf555968abf3ad9f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/Negative3.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/Negative3.agda", "max_line_length": 36, "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/Negative3.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": 30, "size": 90 }
module Ethambda.Position import Eth.Prelude -- using (bool) import Prelude.Bool -- using (bool) import Data.List -- using (intercalate) import Prelude.Monad -- using ((>=>)) import Control.Monad.Identity import Control.Monad.Writer -- using -- (MonadWriter, WriterT, Writer, execWriterT, execWriter, tell) import Control.Monad.Reader -- using -- (MonadReader, ReaderT, Reader, runReaderT, runReader, ask, local) import Ethambda.Common -- using ((<.>), (<.)) import Ethambda.System -- using (Type(Var, Fun)) -- * The 'PosNeg' type. record PosNeg a where constructor PN negatives : List a positives : List a stuff : Show a => String -> List a -> String stuff ttl l = case l of [] => neutral _ => ttl <> ": " <> unwords (intercalate (pure ",") (map (pure . show) l)) Show a => Show (PosNeg a) where show (PN neg pos) = "PN" <.> "neg" <.> "pos" Semigroup (PosNeg a) where (PN p n) <+> (PN p' n') = PN (p <> p') (n <> n') Monoid (PosNeg a) where neutral = PN neutral neutral pos : a -> PosNeg a pos a = PN neutral (pure a) neg : a -> PosNeg a neg a = PN (pure a) neutral -- * Core algorithm. AppM : Type -> (Type -> Type) -> Type AppM a m = ( MonadWriter (PosNeg a) m , MonadReader Bool m ) App : Type -> Type -> Type App a x = WriterT (PosNeg a) (Reader Bool) x -- implementation Functor (ReaderT ?a ?m) where -- execApp : App a x -> PosNeg a execApp : WriterT (PosNeg a) (ReaderT Bool Identity) x -> PosNeg a execApp = (`runReader` True) . execWriterT -- tellPos : AppM a m => a -> m () tellPos : MonadWriter (PosNeg a) m => a -> m () -- tellPos = tell . pos tellPos = tell . pos -- tellNeg : AppM a m => a -> m () -- tellNeg = tell . neg tellNeg : MonadWriter (PosNeg a) m => a -> m () tellNeg = tell . neg -- tellIt : AppM a m => a -> m () -- tellIt a = ask >>= bool (tellNeg a) (tellPos a) tellIt : MonadWriter (PosNeg a) m => MonadReader Bool m => a -> m () tellIt a = ask >>= bool (tellNeg a) (tellPos a) -- positionM : AppM a m => Type a -> m () positionM : MonadWriter (PosNeg a) n => MonadReader Bool m => Tp a -> m () positionM tp = case tp of Var a => tellIt a Fun t u => do positionM u local not $ positionM t -- export -- position : Type a -> PosNeg a -- position = execApp . positionM
{ "alphanum_fraction": 0.6134969325, "avg_line_length": 23.5257731959, "ext": "agda", "hexsha": "9a3ddd0f6137e23a701d09a72dcba5a45dca3ce2", "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": "18e1f9271a3ce76319cdfbcffe027c2088a418aa", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "fredefox/ethambda-agda", "max_forks_repo_path": "src/Ethambda/Position.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "18e1f9271a3ce76319cdfbcffe027c2088a418aa", "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": "fredefox/ethambda-agda", "max_issues_repo_path": "src/Ethambda/Position.agda", "max_line_length": 77, "max_stars_count": null, "max_stars_repo_head_hexsha": "18e1f9271a3ce76319cdfbcffe027c2088a418aa", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "fredefox/ethambda-agda", "max_stars_repo_path": "src/Ethambda/Position.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 732, "size": 2282 }
{-# OPTIONS --erased-cubical --safe #-} module Pitch where open import Cubical.Core.Everything using (_โ‰ก_; Level; Type; ฮฃ; _,_; fst; snd; _โ‰ƒ_; ~_) open import Cubical.Foundations.Prelude using (refl; sym; _โˆ™_; cong; transport; subst; funExt; transp) --open import Cubical.Foundations.Function using (_โˆ˜_) open import Cubical.Foundations.Univalence using (ua) open import Cubical.Foundations.Isomorphism using (iso; Iso; isoToPath; section; retract; isoToEquiv) open import Data.Bool using (Bool; false; true) open import Data.Integer using (โ„ค; +_; -[1+_]) open import Data.Fin using (Fin; toโ„•; #_; _โ‰Ÿ_; fromโ„•<) renaming (zero to fz; suc to fs) open import Data.List using (List; []; _โˆท_; foldr; map) open import Data.Maybe using (Maybe; just; nothing) renaming (map to mmap) open import Data.Nat using (โ„•; zero; suc; _+_; _*_; _โˆธ_; _โ‰กแต‡_; _>_) open import Data.Nat.DivMod using (_mod_; _div_) open import Data.Product using (_ร—_; _,_; projโ‚) open import Data.String using (String; intersperse) renaming (_++_ to _++s_) open import Data.Vec using (Vec; []; _โˆท_; lookup; replicate; _[_]%=_; toList) renaming (map to vmap) open import Relation.Nullary using (yes; no) open import BitVec using (BitVec; insert; empty; show) open import Util using (nโˆธk<n; _+N_; opposite; _โˆ˜_) -- Position of a pitch on an absolute scale -- 0 is C(-1) on the international scale (where C4 is middle C) -- or C0 on the Midi scale (where C5 is middle C) -- Pitch is intentially set to match Midi pitch. -- However it is fine to let 0 represent some other note and -- translate appropriately at the end. Pitch : Type Pitch = โ„• -- Number of notes in the chromatic scale. s12 : โ„• s12 = 12 -- Number of notes in the diatonic scale. s7 : โ„• s7 = 7 -- Pitch Class: position of a pitch within an octave, in the range [0..s12-1]. -- Pitch class 0 corresponds to C (assuming pitch 0 is Midi C0), which is standard. PC : Type PC = Fin s12 showPC : PC โ†’ String showPC fz = "0" showPC (fs fz) = "1" showPC (fs (fs fz)) = "2" showPC (fs (fs (fs fz))) = "3" showPC (fs (fs (fs (fs fz)))) = "4" showPC (fs (fs (fs (fs (fs fz))))) = "5" showPC (fs (fs (fs (fs (fs (fs fz)))))) = "6" showPC (fs (fs (fs (fs (fs (fs (fs fz))))))) = "7" showPC (fs (fs (fs (fs (fs (fs (fs (fs fz)))))))) = "8" showPC (fs (fs (fs (fs (fs (fs (fs (fs (fs fz))))))))) = "9" showPC (fs (fs (fs (fs (fs (fs (fs (fs (fs (fs fz)))))))))) = "a" showPC (fs (fs (fs (fs (fs (fs (fs (fs (fs (fs (fs fz))))))))))) = "b" showPCs : List PC โ†’ String showPCs pcs = intersperse " " (map showPC pcs) toPC : Pitch โ†’ PC toPC = _mod s12 Scale : โ„• โ†’ Type Scale = Vec PC -- Which octave one is in. Octave : Type Octave = โ„• PitchOctave : Type PitchOctave = PC ร— Octave relativeToAbsolute : PitchOctave โ†’ Pitch relativeToAbsolute (n , o) = (o * s12 + (toโ„• n)) absoluteToRelative : Pitch โ†’ PitchOctave absoluteToRelative n = (toPC n , n div s12) pitchToClass : Pitch โ†’ PC pitchToClass = projโ‚ โˆ˜ absoluteToRelative majorScale harmonicMinorScale : Scale s7 majorScale = # 0 โˆท # 2 โˆท # 4 โˆท # 5 โˆท # 7 โˆท # 9 โˆท # 11 โˆท [] harmonicMinorScale = # 0 โˆท # 2 โˆท # 3 โˆท # 5 โˆท # 7 โˆท # 8 โˆท # 11 โˆท [] wholeTone0Scale wholeTone1Scale : Scale 6 wholeTone0Scale = # 0 โˆท # 2 โˆท # 4 โˆท # 6 โˆท # 8 โˆท # 10 โˆท [] wholeTone1Scale = # 1 โˆท # 3 โˆท # 5 โˆท # 7 โˆท # 9 โˆท # 11 โˆท [] octatonic01Scale octatonic02Scale octatonic12Scale : Scale 8 octatonic01Scale = # 0 โˆท # 1 โˆท # 3 โˆท # 4 โˆท # 6 โˆท # 7 โˆท # 9 โˆท # 10 โˆท [] octatonic02Scale = # 0 โˆท # 2 โˆท # 3 โˆท # 5 โˆท # 6 โˆท # 8 โˆท # 9 โˆท # 11 โˆท [] octatonic12Scale = # 1 โˆท # 2 โˆท # 4 โˆท # 5 โˆท # 7 โˆท # 8 โˆท # 10 โˆท # 11 โˆท [] majorPentatonicScale minorPentatonicScale ryukyuScale : Scale 5 majorPentatonicScale = # 0 โˆท # 2 โˆท # 4 โˆท # 7 โˆท # 9 โˆท [] minorPentatonicScale = # 0 โˆท # 2 โˆท # 4 โˆท # 7 โˆท # 9 โˆท [] ryukyuScale = # 0 โˆท # 4 โˆท # 5 โˆท # 7 โˆท # 11 โˆท [] indexInScale : {n : โ„•} โ†’ Vec PC n โ†’ Fin s12 โ†’ Maybe (Fin n) indexInScale [] p = nothing indexInScale (pc โˆท pcs) p with pc โ‰Ÿ p ... | yes _ = just fz ... | no _ = mmap fs (indexInScale pcs p) scaleSize : {n : โ„•} โ†’ Scale n โ†’ โ„• scaleSize {n} _ = n transposePitch : โ„ค โ†’ Pitch โ†’ Pitch transposePitch (+_ k) n = n + k transposePitch (-[1+_] k) n = n โˆธ suc k -- transpose pitch class Tp : โ„• โ†’ PC โ†’ PC Tp n pc = pc +N n -- invert pitch class Ip : PC โ†’ PC Ip = opposite -- Set of pitch classes represented as a bit vector. PCSet : Type PCSet = BitVec s12 toPCSet : List PC โ†’ PCSet toPCSet = foldr insert empty fromPCSet : PCSet โ†’ List PC fromPCSet pcs = fromPCS s12 pcs where fromPCS : (n : โ„•) โ†’ BitVec n โ†’ List PC fromPCS zero [] = [] fromPCS (suc n) (false โˆท xs) = fromPCS n xs fromPCS (suc n) (true โˆท xs) = fromโ„•< (nโˆธk<n 11 n) โˆท fromPCS n xs -- transpose pitch class set T : โ„• โ†’ PCSet โ†’ PCSet T n = toPCSet โˆ˜ map (Tp n) โˆ˜ fromPCSet -- invert pitch class set I : PCSet โ†’ PCSet I = toPCSet โˆ˜ map Ip โˆ˜ fromPCSet -- Standard Midi pitches -- first argument is relative pitch within octave -- second argument is octave (C5 = middle C for Midi) standardMidiPitch : Fin s12 โ†’ โ„• โ†’ Pitch standardMidiPitch p o = relativeToAbsolute (p , o) c cโ™ฏ d dโ™ฏ e f fโ™ฏ g gโ™ฏ a bโ™ญ b : โ„• โ†’ Pitch c = standardMidiPitch (# 0) cโ™ฏ = standardMidiPitch (# 1) d = standardMidiPitch (# 2) dโ™ฏ = standardMidiPitch (# 3) e = standardMidiPitch (# 4) f = standardMidiPitch (# 5) fโ™ฏ = standardMidiPitch (# 6) g = standardMidiPitch (# 7) gโ™ฏ = standardMidiPitch (# 8) a = standardMidiPitch (# 9) bโ™ญ = standardMidiPitch (# 10) b = standardMidiPitch (# 11) -- Equivalences relโ†’abs : PitchOctave โ†’ Pitch relโ†’abs = relativeToAbsolute absโ†’rel : Pitch โ†’ PitchOctave absโ†’rel = absoluteToRelative {- relโ†’absโ†’rel : (p : PitchOctave) โ†’ (absโ†’rel โˆ˜ relโ†’abs) p โ‰ก p relโ†’absโ†’rel (pitchClass p , octave o) i = let a = cong pitchClass (modUnique s12 o p) b = cong octave (divUnique s12 o p) in a i , b i absโ†’relโ†’abs : (p : Pitch) โ†’ (relโ†’abs โˆ˜ absโ†’rel) p โ‰ก p absโ†’relโ†’abs (pitch p) = cong pitch (sym (nโ‰กdivmod p s12)) absโ‰ƒrel : Iso Pitch PitchOctave absโ‰ƒrel = iso absโ†’rel relโ†’abs relโ†’absโ†’rel absโ†’relโ†’abs absโ‰กrel : Pitch โ‰ก PitchOctave absโ‰กrel = isoToPath absโ‰ƒrel -}
{ "alphanum_fraction": 0.6218800648, "avg_line_length": 31.641025641, "ext": "agda", "hexsha": "329bb7d55e7cd5e5d6293828ff11b7e48c306d77", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2020-11-10T04:04:40.000Z", "max_forks_repo_forks_event_min_datetime": "2019-01-12T17:02:36.000Z", "max_forks_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "halfaya/MusicTools", "max_forks_repo_path": "agda/Pitch.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_issues_repo_issues_event_max_datetime": "2020-11-17T00:58:55.000Z", "max_issues_repo_issues_event_min_datetime": "2020-11-13T01:26:20.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "halfaya/MusicTools", "max_issues_repo_path": "agda/Pitch.agda", "max_line_length": 107, "max_stars_count": 28, "max_stars_repo_head_hexsha": "04896c61b603d46011b7d718fcb47dd756e66021", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "halfaya/MusicTools", "max_stars_repo_path": "agda/Pitch.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-04T18:04:07.000Z", "max_stars_repo_stars_event_min_datetime": "2017-04-21T09:08:52.000Z", "num_tokens": 2301, "size": 6170 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Strings ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.String where open import Data.Vec as Vec using (Vec) open import Data.Char as Char using (Char) ------------------------------------------------------------------------ -- Re-export contents of base, and decidability of equality open import Data.String.Base public open import Data.String.Properties using (_โ‰Ÿ_; _==_) public ------------------------------------------------------------------------ -- Operations toVec : (s : String) โ†’ Vec Char (length s) toVec s = Vec.fromList (toList s)
{ "alphanum_fraction": 0.4289617486, "avg_line_length": 29.28, "ext": "agda", "hexsha": "7959353b7935168531baa9b3f37f0e0fa60d321c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/String.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/String.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/Data/String.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 117, "size": 732 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.ZCohomology.Groups.Torus where open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.Properties open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.Groups.Connected open import Cubical.ZCohomology.MayerVietorisUnreduced open import Cubical.ZCohomology.Groups.Unit open import Cubical.ZCohomology.Groups.Sn open import Cubical.ZCohomology.Groups.Prelims open import Cubical.Foundations.HLevels open import Cubical.Foundations.Function open import Cubical.Foundations.Univalence open import Cubical.Foundations.Prelude open import Cubical.Foundations.Pointed open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Equiv open import Cubical.Data.Sigma open import Cubical.Data.Int renaming (_+_ to _+โ„ค_; +Comm to +โ„ค-comm ; +Assoc to +โ„ค-assoc) open import Cubical.Data.Nat open import Cubical.Data.Unit open import Cubical.Algebra.Group renaming (โ„ค to โ„คGroup ; Bool to BoolGroup ; Unit to UnitGroup) open import Cubical.HITs.Pushout open import Cubical.HITs.S1 open import Cubical.HITs.Sn open import Cubical.HITs.Susp open import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2) hiding (map) open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim2 to pElim2 ; โˆฃ_โˆฃ to โˆฃ_โˆฃโ‚) hiding (map) open import Cubical.HITs.Nullification open import Cubical.HITs.Truncation renaming (elim to trElim ; elim2 to trElim2 ; map to trMap ; rec to trRec) open import Cubical.Homotopy.Connected open import Cubical.Homotopy.Loopspace open IsGroupHom open Iso -- The following section contains stengthened induction principles for cohomology groups of Tยฒ. They are particularly useful for showing that -- that some Isos are morphisms. They make things type-check faster, but should probably not be used for computations. -- We first need some functions elimFunTยฒ : (n : โ„•) (p q : typ (ฮฉ (coHomK-ptd (suc n)))) โ†’ Square q q p p โ†’ Sยน ร— Sยน โ†’ coHomK (suc n) elimFunTยฒ n p q P (base , base) = โˆฃ ptSn (suc n) โˆฃ elimFunTยฒ n p q P (base , loop i) = q i elimFunTยฒ n p q P (loop i , base) = p i elimFunTยฒ n p q P (loop i , loop j) = P i j elimFunTยฒ' : (n : โ„•) โ†’ Square (refl {โ„“-zero} {coHomK (suc n)} {โˆฃ ptSn (suc n) โˆฃ}) refl refl refl โ†’ Sยน ร— Sยน โ†’ coHomK (suc n) elimFunTยฒ' n P (x , base) = โˆฃ ptSn (suc n) โˆฃ elimFunTยฒ' n P (base , loop j) = โˆฃ ptSn (suc n) โˆฃ elimFunTยฒ' n P (loop i , loop j) = P i j elimFunTยฒ'โ‰กelimFunTยฒ : (n : โ„•) โ†’ (P : _) โ†’ elimFunTยฒ' n P โ‰ก elimFunTยฒ n refl refl P elimFunTยฒ'โ‰กelimFunTยฒ n P i (base , base) = โˆฃ ptSn (suc n) โˆฃ elimFunTยฒ'โ‰กelimFunTยฒ n P i (base , loop k) = โˆฃ ptSn (suc n) โˆฃ elimFunTยฒ'โ‰กelimFunTยฒ n P i (loop j , base) = โˆฃ ptSn (suc n) โˆฃ elimFunTยฒ'โ‰กelimFunTยฒ n P i (loop j , loop k) = P j k {- The first induction principle says that when proving a proposition for some x : Hโฟ(Tยฒ), n โ‰ฅ 1, it suffices to show that it holds for (elimFunTยฒ p q P) for any paths p q : ฮฉKโ‚™, and square P : Square q q p p. This is useful because elimFunTยฒ p q P (base , base) recudes to 0 -} coHomPointedElimTยฒ : โˆ€ {โ„“} (n : โ„•) {B : coHom (suc n) (Sยน ร— Sยน) โ†’ Type โ„“} โ†’ ((x : coHom (suc n) (Sยน ร— Sยน)) โ†’ isProp (B x)) โ†’ ((p q : _) (P : _) โ†’ B โˆฃ elimFunTยฒ n p q P โˆฃโ‚‚) โ†’ (x : coHom (suc n) (Sยน ร— Sยน)) โ†’ B x coHomPointedElimTยฒ n {B = B} isprop indp = coHomPointedElim _ (base , base) isprop ฮป f fId โ†’ subst B (cong โˆฃ_โˆฃโ‚‚ (funExt (ฮป { (base , base) โ†’ sym fId ; (base , loop i) j โ†’ helper f fId i1 i (~ j) ; (loop i , base) j โ†’ helper f fId i i1 (~ j) ; (loop i , loop j) k โ†’ helper f fId i j (~ k)}))) (indp (ฮป i โ†’ helper f fId i i1 i1) (ฮป i โ†’ helper f fId i1 i i1) ฮป i j โ†’ helper f fId i j i1) where helper : (f : Sยน ร— Sยน โ†’ coHomK (suc n)) โ†’ f (base , base) โ‰ก โˆฃ ptSn (suc n) โˆฃ โ†’ I โ†’ I โ†’ I โ†’ coHomK (suc n) helper f fId i j k = hfill (ฮป k โ†’ ฮป {(i = i0) โ†’ doubleCompPath-filler (sym fId) (cong f (ฮป i โ†’ (base , loop i))) fId k j ; (i = i1) โ†’ doubleCompPath-filler (sym fId) (cong f (ฮป i โ†’ (base , loop i))) fId k j ; (j = i0) โ†’ doubleCompPath-filler (sym fId) (cong f (ฮป i โ†’ (loop i , base))) fId k i ; (j = i1) โ†’ doubleCompPath-filler (sym fId) (cong f (ฮป i โ†’ (loop i , base))) fId k i}) (inS (f ((loop i) , (loop j)))) k private lem : โˆ€ {โ„“} (n : โ„•) {B : coHom (2 + n) (Sยน ร— Sยน) โ†’ Type โ„“} โ†’ ((P : _) โ†’ B โˆฃ elimFunTยฒ (suc n) refl refl P โˆฃโ‚‚) โ†’ (p : _) โ†’ (refl โ‰ก p) โ†’ (q : _) โ†’ (refl โ‰ก q) โ†’ (P : _) โ†’ B โˆฃ elimFunTยฒ (suc n) p q P โˆฃโ‚‚ lem n {B = B} elimP p = J (ฮป p _ โ†’ (q : _) โ†’ (refl โ‰ก q) โ†’ (P : _) โ†’ B โˆฃ elimFunTยฒ (suc n) p q P โˆฃโ‚‚) ฮป q โ†’ J (ฮป q _ โ†’ (P : _) โ†’ B โˆฃ elimFunTยฒ (suc n) refl q P โˆฃโ‚‚) elimP {- When working with Hโฟ(Tยฒ) , n โ‰ฅ 2, we are, in the case described above, allowed to assume that any f : Hโฟ(Tยฒ) is elimFunTยฒ n refl refl P -} coHomPointedElimTยฒ' : โˆ€ {โ„“} (n : โ„•) {B : coHom (2 + n) (Sยน ร— Sยน) โ†’ Type โ„“} โ†’ ((x : coHom (2 + n) (Sยน ร— Sยน)) โ†’ isProp (B x)) โ†’ ((P : _) โ†’ B โˆฃ elimFunTยฒ (suc n) refl refl P โˆฃโ‚‚) โ†’ (x : coHom (2 + n) (Sยน ร— Sยน)) โ†’ B x coHomPointedElimTยฒ' n {B = B} prop ind = coHomPointedElimTยฒ (suc n) prop ฮป p q P โ†’ trRec (isPropโ†’isOfHLevelSuc n (prop _)) (ฮป p-refl โ†’ trRec (isPropโ†’isOfHLevelSuc n (prop _)) (ฮป q-refl โ†’ lem n {B = B} ind p (sym p-refl) q (sym q-refl) P) (isConnectedPath _ (isConnectedPathKn (suc n) _ _) q refl .fst)) (isConnectedPath _ (isConnectedPathKn (suc n) _ _) p refl .fst) {- A slight variation of the above which gives definitional equalities for all points (x , base) -} private coHomPointedElimTยฒ'' : โˆ€ {โ„“} (n : โ„•) {B : coHom (2 + n) (Sยน ร— Sยน) โ†’ Type โ„“} โ†’ ((x : coHom (2 + n) (Sยน ร— Sยน)) โ†’ isProp (B x)) โ†’ ((P : _) โ†’ B โˆฃ elimFunTยฒ' (suc n) P โˆฃโ‚‚) โ†’ (x : coHom (2 + n) (Sยน ร— Sยน)) โ†’ B x coHomPointedElimTยฒ'' n {B = B} prop ind = coHomPointedElimTยฒ' n prop ฮป P โ†’ subst (ฮป x โ†’ B โˆฃ x โˆฃโ‚‚) (elimFunTยฒ'โ‰กelimFunTยฒ (suc n) P) (ind P) --------- Hโฐ(Tยฒ) ------------ Hโฐ-Tยฒโ‰…โ„ค : GroupIso (coHomGr 0 (Sโ‚Š 1 ร— Sโ‚Š 1)) โ„คGroup Hโฐ-Tยฒโ‰…โ„ค = Hโฐ-connected (base , base) ฮป (a , b) โ†’ pRec isPropPropTrunc (ฮป id1 โ†’ pRec isPropPropTrunc (ฮป id2 โ†’ โˆฃ ฮฃPathP (id1 , id2) โˆฃโ‚) (Sn-connected 0 b) ) (Sn-connected 0 a) --------- Hยน(Tยฒ) ------------------------------- Hยน-Tยฒโ‰…โ„คร—โ„ค : GroupIso (coHomGr 1 ((Sโ‚Š 1) ร— (Sโ‚Š 1))) (DirProd โ„คGroup โ„คGroup) Hยน-Tยฒโ‰…โ„คร—โ„ค = theIso โ–ก GroupIsoDirProd (Hโฟ-Sโฟโ‰…โ„ค 0) (Hโฐ-Sโฟโ‰…โ„ค 0) where typIso : Iso _ _ typIso = setTruncIso (curryIso โ‹„ codomainIso S1โ†’Kโ‚โ‰กS1ร—โ„ค โ‹„ toProdIso) โ‹„ setTruncOfProdIso theIso : GroupIso _ _ fst theIso = typIso snd theIso = makeIsGroupHom (coHomPointedElimTยฒ _ (ฮป _ โ†’ isPropฮ  ฮป _ โ†’ isSetร— isSetSetTrunc isSetSetTrunc _ _) ฮป pf qf Pf โ†’ coHomPointedElimTยฒ _ (ฮป _ โ†’ isSetร— isSetSetTrunc isSetSetTrunc _ _) ฮป pg qg Pg i โ†’ โˆฃ funExt (helperFst pf qf pg qg Pg Pf) i โˆฃโ‚‚ , โˆฃ funExt (helperSnd pf qf pg qg Pg Pf) i โˆฃโ‚‚) where module _ (pf qf pg qg : 0โ‚– 1 โ‰ก 0โ‚– 1) (Pg : Square qg qg pg pg) (Pf : Square qf qf pf pf) where helperFst : (x : Sยน) โ†’ fun S1โ†’Kโ‚โ‰กS1ร—โ„ค (ฮป y โ†’ elimFunTยฒ 0 pf qf Pf (x , y) +โ‚– elimFunTยฒ 0 pg qg Pg (x , y)) .fst โ‰ก fun S1โ†’Kโ‚โ‰กS1ร—โ„ค (ฮป y โ†’ elimFunTยฒ 0 pf qf Pf (x , y)) .fst +โ‚– fun S1โ†’Kโ‚โ‰กS1ร—โ„ค (ฮป y โ†’ elimFunTยฒ 0 pg qg Pg (x , y)) .fst helperFst base = refl helperFst (loop i) j = loopLem j i where loopLem : cong (ฮป x โ†’ fun S1โ†’Kโ‚โ‰กS1ร—โ„ค (ฮป y โ†’ elimFunTยฒ 0 pf qf Pf (x , y) +โ‚– elimFunTยฒ 0 pg qg Pg (x , y)) .fst) loop โ‰ก cong (ฮป x โ†’ fun S1โ†’Kโ‚โ‰กS1ร—โ„ค (ฮป y โ†’ elimFunTยฒ 0 pf qf Pf (x , y)) .fst +โ‚– fun S1โ†’Kโ‚โ‰กS1ร—โ„ค (ฮป y โ†’ elimFunTยฒ 0 pg qg Pg (x , y)) .fst) loop loopLem = (ฮป i j โ†’ Sยนmap-id (pf j +โ‚– pg j) i) โˆ™ (ฮป i j โ†’ Sยนmap-id (pf j) (~ i) +โ‚– Sยนmap-id (pg j) (~ i)) helperSnd : (x : Sยน) โ†’ fun S1โ†’Kโ‚โ‰กS1ร—โ„ค (ฮป y โ†’ elimFunTยฒ 0 pf qf Pf (x , y) +โ‚– elimFunTยฒ 0 pg qg Pg (x , y)) .snd โ‰ก fun S1โ†’Kโ‚โ‰กS1ร—โ„ค (ฮป y โ†’ elimFunTยฒ 0 pf qf Pf (x , y)) .snd +โ„ค fun S1โ†’Kโ‚โ‰กS1ร—โ„ค (ฮป y โ†’ elimFunTยฒ 0 pg qg Pg (x , y)) .snd helperSnd = toPropElim (ฮป _ โ†’ isSetโ„ค _ _) ((ฮป i โ†’ winding (basechange2โป base ฮป j โ†’ Sยนmap (โˆ™โ‰ก+โ‚ qf qg (~ i) j))) โˆ™โˆ™ cong (winding โˆ˜ basechange2โป base) (congFunct Sยนmap qf qg) โˆ™โˆ™ (cong winding (basechange2โป-morph base (cong Sยนmap qf) (cong Sยนmap qg)) โˆ™ winding-hom (basechange2โป base (cong Sยนmap qf)) (basechange2โป base (cong Sยนmap qg)))) ----------------------- Hยฒ(Tยฒ) ------------------------------ Hยฒ-Tยฒโ‰…โ„ค : GroupIso (coHomGr 2 (Sโ‚Š 1 ร— Sโ‚Š 1)) โ„คGroup Hยฒ-Tยฒโ‰…โ„ค = compGroupIso helper2 (Hโฟ-Sโฟโ‰…โ„ค 0) where helper : Iso (โˆฅ ((a : Sยน) โ†’ coHomK 2) โˆฅโ‚‚ ร— โˆฅ ((a : Sยน) โ†’ coHomK 1) โˆฅโ‚‚) (coHom 1 Sยน) inv helper s = 0โ‚• _ , s fun helper = snd leftInv helper _ = ฮฃPathP (isOfHLevelSuc 0 (isOfHLevelRetractFromIso 0 (fst (Hโฟ-Sยนโ‰…0 0)) (isContrUnit)) _ _ , refl) rightInv helper _ = refl theIso : Iso (coHom 2 (Sยน ร— Sยน)) (coHom 1 Sยน) theIso = setTruncIso (curryIso โ‹„ codomainIso S1โ†’K2โ‰กK2ร—K1 โ‹„ toProdIso) โ‹„ setTruncOfProdIso โ‹„ helper helper2 : GroupIso (coHomGr 2 (Sยน ร— Sยน)) (coHomGr 1 Sยน) helper2 .fst = theIso helper2 .snd = makeIsGroupHom ( coHomPointedElimTยฒ'' 0 (ฮป _ โ†’ isPropฮ  ฮป _ โ†’ isSetSetTrunc _ _) ฮป P โ†’ coHomPointedElimTยฒ'' 0 (ฮป _ โ†’ isSetSetTrunc _ _) ฮป Q โ†’ ((ฮป i โ†’ โˆฃ (ฮป a โ†’ ฮฉKn+1โ†’Kn 1 (sym (rCancelโ‰กrefl 0 i) โˆ™โˆ™ cong (ฮป x โ†’ (elimFunTยฒ' 1 P (a , x) +โ‚– elimFunTยฒ' 1 Q (a , x)) -โ‚– โˆฃ north โˆฃ) loop โˆ™โˆ™ rCancelโ‰กrefl 0 i)) โˆฃโ‚‚)) โˆ™โˆ™ (ฮป i โ†’ โˆฃ (ฮป a โ†’ ฮฉKn+1โ†’Kn 1 (rUnit (cong (ฮป x โ†’ rUnitโ‚– 2 (elimFunTยฒ' 1 P (a , x) +โ‚– elimFunTยฒ' 1 Q (a , x)) i) loop) (~ i))) โˆฃโ‚‚) โˆ™โˆ™ (ฮป i โ†’ โˆฃ (ฮป a โ†’ ฮฉKn+1โ†’Kn 1 (โˆ™โ‰ก+โ‚‚ 0 (cong (ฮป x โ†’ elimFunTยฒ' 1 P (a , x)) loop) (cong (ฮป x โ†’ elimFunTยฒ' 1 Q (a , x)) loop) (~ i))) โˆฃโ‚‚) โˆ™โˆ™ (ฮป i โ†’ โˆฃ (ฮป a โ†’ ฮฉKn+1โ†’Kn-hom 1 (cong (ฮป x โ†’ elimFunTยฒ' 1 P (a , x)) loop) (cong (ฮป x โ†’ elimFunTยฒ' 1 Q (a , x)) loop) i) โˆฃโ‚‚) โˆ™โˆ™ (ฮป i โ†’ โˆฃ ((ฮป a โ†’ ฮฉKn+1โ†’Kn 1 (rUnit (cong (ฮป x โ†’ rUnitโ‚– 2 (elimFunTยฒ' 1 P (a , x)) (~ i)) loop) i) +โ‚– ฮฉKn+1โ†’Kn 1 (rUnit (cong (ฮป x โ†’ rUnitโ‚– 2 (elimFunTยฒ' 1 Q (a , x)) (~ i)) loop) i))) โˆฃโ‚‚) โˆ™ (ฮป i โ†’ โˆฃ ((ฮป a โ†’ ฮฉKn+1โ†’Kn 1 (sym (rCancelโ‰กrefl 0 (~ i)) โˆ™โˆ™ cong (ฮป x โ†’ elimFunTยฒ' 1 P (a , x) +โ‚– โˆฃ north โˆฃ) loop โˆ™โˆ™ rCancelโ‰กrefl 0 (~ i)) +โ‚– ฮฉKn+1โ†’Kn 1 (sym (rCancelโ‰กrefl 0 (~ i)) โˆ™โˆ™ cong (ฮป x โ†’ elimFunTยฒ' 1 Q (a , x) +โ‚– โˆฃ north โˆฃ) loop โˆ™โˆ™ rCancelโ‰กrefl 0 (~ i)))) โˆฃโ‚‚)) -- >>>>>>> master private toโ‚‚ : coHom 2 (Sโ‚Š 1 ร— Sโ‚Š 1) โ†’ โ„ค toโ‚‚ = fun (fst Hยฒ-Tยฒโ‰…โ„ค) fromโ‚‚ : โ„ค โ†’ coHom 2 (Sโ‚Š 1 ร— Sโ‚Š 1) fromโ‚‚ = inv (fst Hยฒ-Tยฒโ‰…โ„ค) toโ‚ : coHom 1 (Sโ‚Š 1 ร— Sโ‚Š 1) โ†’ โ„ค ร— โ„ค toโ‚ = fun (fst Hยน-Tยฒโ‰…โ„คร—โ„ค) fromโ‚ : โ„ค ร— โ„ค โ†’ coHom 1 (Sโ‚Š 1 ร— Sโ‚Š 1) fromโ‚ = inv (fst Hยน-Tยฒโ‰…โ„คร—โ„ค) toโ‚€ : coHom 0 (Sโ‚Š 1 ร— Sโ‚Š 1) โ†’ โ„ค toโ‚€ = fun (fst Hโฐ-Tยฒโ‰…โ„ค) fromโ‚€ : โ„ค โ†’ coHom 0 (Sโ‚Š 1 ร— Sโ‚Š 1) fromโ‚€ = inv (fst Hโฐ-Tยฒโ‰…โ„ค) {- -- Compute fast: test : toโ‚ (fromโ‚ (0 , 1) +โ‚• fromโ‚ (1 , 0)) โ‰ก (1 , 1) test = refl test2 : toโ‚ (fromโ‚ (5 , 1) +โ‚• fromโ‚ (-2 , 3)) โ‰ก (3 , 4) test2 = refl -- Compute pretty fast test3 : toโ‚‚ (fromโ‚‚ 1) โ‰ก 1 test3 = refl test4 : toโ‚‚ (fromโ‚‚ 2) โ‰ก 2 test4 = refl test5 : toโ‚‚ (fromโ‚‚ 3) โ‰ก 3 test5 = refl -- Compute, but slower test6 : toโ‚‚ (fromโ‚‚ 0 +โ‚• fromโ‚‚ 0) โ‰ก 0 test6 = refl test6 : toโ‚‚ (fromโ‚‚ 0 +โ‚• fromโ‚‚ 1) โ‰ก 1 test6 = refl -- Does not compute test7 : toโ‚‚ (fromโ‚‚ 1 +โ‚• fromโ‚‚ 0) โ‰ก 1 test7 = refl -}
{ "alphanum_fraction": 0.5286088406, "avg_line_length": 45.8218181818, "ext": "agda", "hexsha": "918ea48af5f0ec1d75cb4bcf54131d79835efc7e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "kl-i/cubical-0.3", "max_forks_repo_path": "Cubical/ZCohomology/Groups/Torus.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "kl-i/cubical-0.3", "max_issues_repo_path": "Cubical/ZCohomology/Groups/Torus.agda", "max_line_length": 145, "max_stars_count": null, "max_stars_repo_head_hexsha": "f2d74ae8e2e176963029a35bd886364480948214", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "kl-i/cubical-0.3", "max_stars_repo_path": "Cubical/ZCohomology/Groups/Torus.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 5064, "size": 12601 }
{-# OPTIONS --without-K --safe #-} -- In this module, we define the subtyping relation of D<: according to Lemma 2. module Dsub where open import Data.List as List open import Data.List.All as All open import Data.Nat as โ„• open import Data.Maybe as Maybe open import Data.Product as ฮฃ open import Data.Sum open import Data.Empty renaming (โŠฅ to False) open import Data.Vec as Vec renaming (_โˆท_ to _โ€ผ_ ; [] to nil) hiding (_++_) open import Function open import Data.Maybe.Properties as Maybeโ‚š open import Data.Nat.Properties as โ„•โ‚š open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import DsubDef open import Utils module Dsub where infix 4 _โŠข_<:_ data _โŠข_<:_ : Env โ†’ Typ โ†’ Typ โ†’ Set where dtop : โˆ€ {ฮ“ T} โ†’ ฮ“ โŠข T <: โŠค dbot : โˆ€ {ฮ“ T} โ†’ ฮ“ โŠข โŠฅ <: T drefl : โˆ€ {ฮ“ T} โ†’ ฮ“ โŠข T <: T dtrans : โˆ€ {ฮ“ S U} T โ†’ (S<:T : ฮ“ โŠข S <: T) โ†’ (T<:U : ฮ“ โŠข T <: U) โ†’ ฮ“ โŠข S <: U dbnd : โˆ€ {ฮ“ S U Sโ€ฒ Uโ€ฒ} โ†’ (Sโ€ฒ<:S : ฮ“ โŠข Sโ€ฒ <: S) โ†’ (U<:Uโ€ฒ : ฮ“ โŠข U <: Uโ€ฒ) โ†’ ฮ“ โŠข โŸจA: S โ‹ฏ U โŸฉ <: โŸจA: Sโ€ฒ โ‹ฏ Uโ€ฒ โŸฉ dall : โˆ€ {ฮ“ S U Sโ€ฒ Uโ€ฒ} โ†’ (Sโ€ฒ<:S : ฮ“ โŠข Sโ€ฒ <: S) โ†’ (U<:Uโ€ฒ : (Sโ€ฒ โˆท ฮ“) โŠข U <: Uโ€ฒ) โ†’ ฮ“ โŠข ฮ  S โˆ™ U <: ฮ  Sโ€ฒ โˆ™ Uโ€ฒ dselโ‚ : โˆ€ {ฮ“ n T S} โ†’ (Tโˆˆฮ“ : env-lookup ฮ“ n โ‰ก just T) โ†’ (D : ฮ“ โŠข T <: โŸจA: S โ‹ฏ โŠค โŸฉ) โ†’ ฮ“ โŠข S <: n โˆ™A dselโ‚‚ : โˆ€ {ฮ“ n T U} โ†’ (Tโˆˆฮ“ : env-lookup ฮ“ n โ‰ก just T) โ†’ (D : ฮ“ โŠข T <: โŸจA: โŠฅ โ‹ฏ U โŸฉ) โ†’ ฮ“ โŠข n โˆ™A <: U D-measure : โˆ€ {ฮ“ S U} (D : ฮ“ โŠข S <: U) โ†’ โ„• D-measure dtop = 1 D-measure dbot = 1 D-measure drefl = 1 D-measure (dtrans _ S<:T T<:U) = 1 + D-measure S<:T + D-measure T<:U D-measure (dbnd Dโ‚ Dโ‚‚) = 1 + D-measure Dโ‚ + D-measure Dโ‚‚ D-measure (dall Dp Db) = 1 + D-measure Dp + D-measure Db D-measure (dselโ‚ Tโˆˆฮ“ D) = 1 + D-measure D D-measure (dselโ‚‚ Tโˆˆฮ“ D) = 1 + D-measure D D-measureโ‰ฅ1 : โˆ€ {ฮ“ S U} (D : ฮ“ โŠข S <: U) โ†’ D-measure D โ‰ฅ 1 D-measureโ‰ฅ1 dtop = sโ‰คs zโ‰คn D-measureโ‰ฅ1 dbot = sโ‰คs zโ‰คn D-measureโ‰ฅ1 drefl = sโ‰คs zโ‰คn D-measureโ‰ฅ1 (dtrans _ _ _) = sโ‰คs zโ‰คn D-measureโ‰ฅ1 (dbnd _ _) = sโ‰คs zโ‰คn D-measureโ‰ฅ1 (dall _ _) = sโ‰คs zโ‰คn D-measureโ‰ฅ1 (dselโ‚ _ _) = sโ‰คs zโ‰คn D-measureโ‰ฅ1 (dselโ‚‚ _ _) = sโ‰คs zโ‰คn D-deriv : Set D-deriv = ฮฃ (Env ร— Typ ร— Typ) ฮป { (ฮ“ , S , U) โ†’ ฮ“ โŠข S <: U } env : D-deriv โ†’ Env env ((ฮ“ , _) , _) = ฮ“ typโ‚ : D-deriv โ†’ Typ typโ‚ ((_ , S , U) , _) = S typโ‚‚ : D-deriv โ†’ Typ typโ‚‚ ((_ , S , U) , _) = U drefl-dec : โˆ€ (D : D-deriv) โ†’ Dec (D โ‰ก ((env D , typโ‚ D , _) , drefl)) drefl-dec (_ , dtop) = no (ฮป ()) drefl-dec (_ , dbot) = no (ฮป ()) drefl-dec (_ , drefl) = yes refl drefl-dec (_ , dtrans _ _ _) = no (ฮป ()) drefl-dec (_ , dbnd _ _) = no (ฮป ()) drefl-dec (_ , dall _ _) = no (ฮป ()) drefl-dec (_ , dselโ‚ _ _) = no (ฮป ()) drefl-dec (_ , dselโ‚‚ _ _) = no (ฮป ()) -- weakening infixl 7 _โ‡‘ _โ‡‘ : Env โ†’ Env [] โ‡‘ = [] (T โˆท ฮ“) โ‡‘ = T โ†‘ length ฮ“ โˆท ฮ“ โ‡‘ โ†ฆโˆˆ-weaken-โ‰ค : โˆ€ {n T ฮ“} โ†’ n โ†ฆ T โˆˆ ฮ“ โ†’ โˆ€ ฮ“โ‚ ฮ“โ‚‚ Tโ€ฒ โ†’ ฮ“ โ‰ก ฮ“โ‚ โ€ฃ ฮ“โ‚‚ โ†’ length ฮ“โ‚‚ โ‰ค n โ†’ suc n โ†ฆ T โ†‘ length ฮ“โ‚‚ โˆˆ ฮ“โ‚ โ€ฃ Tโ€ฒ ! โ€ฃ ฮ“โ‚‚ โ‡‘ โ†ฆโˆˆ-weaken-โ‰ค hd .(_ โˆท _) [] Tโ€ฒ refl zโ‰คn = tl hd โ†ฆโˆˆ-weaken-โ‰ค hd ฮ“โ‚ (_ โˆท ฮ“โ‚‚) Tโ€ฒ eqฮ“ () โ†ฆโˆˆ-weaken-โ‰ค (tl Tโˆˆฮ“) .(_ โˆท _) [] Tโ€ฒ refl zโ‰คn = tl (tl Tโˆˆฮ“) โ†ฆโˆˆ-weaken-โ‰ค (tl {_} {T} Tโˆˆฮ“) ฮ“โ‚ (_ โˆท ฮ“โ‚‚) Tโ€ฒ refl (sโ‰คs lโ‰คn) rewrite โ†‘-โ†‘-comm T 0 (length ฮ“โ‚‚) zโ‰คn = tl (โ†ฆโˆˆ-weaken-โ‰ค Tโˆˆฮ“ ฮ“โ‚ ฮ“โ‚‚ Tโ€ฒ refl lโ‰คn) โ†ฆโˆˆ-weaken-> : โˆ€ {n T ฮ“} โ†’ n โ†ฆ T โˆˆ ฮ“ โ†’ โˆ€ ฮ“โ‚ ฮ“โ‚‚ Tโ€ฒ โ†’ ฮ“ โ‰ก ฮ“โ‚ โ€ฃ ฮ“โ‚‚ โ†’ length ฮ“โ‚‚ > n โ†’ n โ†ฆ T โ†‘ length ฮ“โ‚‚ โˆˆ ฮ“โ‚ โ€ฃ Tโ€ฒ ! โ€ฃ ฮ“โ‚‚ โ‡‘ โ†ฆโˆˆ-weaken-> Tโˆˆฮ“ ฮ“โ‚ [] Tโ€ฒ eqฮ“ () โ†ฆโˆˆ-weaken-> (hd {T}) ฮ“โ‚ (_ โˆท ฮ“โ‚‚) Tโ€ฒ refl (sโ‰คs l>n) rewrite โ†‘-โ†‘-comm T 0 (length ฮ“โ‚‚) l>n = hd โ†ฆโˆˆ-weaken-> (tl {_} {T} Tโˆˆฮ“) ฮ“โ‚ (_ โˆท ฮ“โ‚‚) Tโ€ฒ refl (sโ‰คs l>n) rewrite โ†‘-โ†‘-comm T 0 (length ฮ“โ‚‚) zโ‰คn = tl (โ†ฆโˆˆ-weaken-> Tโˆˆฮ“ ฮ“โ‚ ฮ“โ‚‚ Tโ€ฒ refl l>n) โ†ฆโˆˆ-weaken : โˆ€ {n T ฮ“} โ†’ n โ†ฆ T โˆˆ ฮ“ โ†’ โˆ€ ฮ“โ‚ ฮ“โ‚‚ Tโ€ฒ โ†’ ฮ“ โ‰ก ฮ“โ‚ โ€ฃ ฮ“โ‚‚ โ†’ โ†‘-idx n (length ฮ“โ‚‚) โ†ฆ T โ†‘ length ฮ“โ‚‚ โˆˆ ฮ“โ‚ โ€ฃ Tโ€ฒ ! โ€ฃ ฮ“โ‚‚ โ‡‘ โ†ฆโˆˆ-weaken {n} Tโˆˆฮ“ _ ฮ“โ‚‚ _ eqฮ“ with length ฮ“โ‚‚ โ‰ค? n ... | yes lโ‰คn = โ†ฆโˆˆ-weaken-โ‰ค Tโˆˆฮ“ _ ฮ“โ‚‚ _ eqฮ“ lโ‰คn ... | no l>n = โ†ฆโˆˆ-weaken-> Tโˆˆฮ“ _ ฮ“โ‚‚ _ eqฮ“ (โ‰ฐโ‡’> l>n) โ†ฆโˆˆ-weakenโ€ฒ : โˆ€ {n T ฮ“} โ†’ env-lookup ฮ“ n โ‰ก just T โ†’ โˆ€ ฮ“โ‚ ฮ“โ‚‚ Tโ€ฒ โ†’ ฮ“ โ‰ก ฮ“โ‚ โ€ฃ ฮ“โ‚‚ โ†’ env-lookup (ฮ“โ‚ โ€ฃ Tโ€ฒ ! โ€ฃ ฮ“โ‚‚ โ‡‘) (โ†‘-idx n (length ฮ“โ‚‚)) โ‰ก just (T โ†‘ length ฮ“โ‚‚) โ†ฆโˆˆ-weakenโ€ฒ Tโˆˆฮ“ ฮ“โ‚ ฮ“โ‚‚ Tโ€ฒ eqฮ“ = โ†ฆโˆˆโ‡’lookup (โ†ฆโˆˆ-weaken (lookupโ‡’โ†ฆโˆˆ Tโˆˆฮ“) ฮ“โ‚ ฮ“โ‚‚ Tโ€ฒ eqฮ“) <:-weakening-gen : โˆ€ {ฮ“ S U} โ†’ ฮ“ โŠข S <: U โ†’ โˆ€ ฮ“โ‚ ฮ“โ‚‚ T โ†’ ฮ“ โ‰ก ฮ“โ‚ โ€ฃ ฮ“โ‚‚ โ†’ ฮ“โ‚ โ€ฃ T ! โ€ฃ ฮ“โ‚‚ โ‡‘ โŠข S โ†‘ length ฮ“โ‚‚ <: U โ†‘ length ฮ“โ‚‚ <:-weakening-gen dtop ฮ“โ‚ ฮ“โ‚‚ T eqฮ“ = dtop <:-weakening-gen dbot ฮ“โ‚ ฮ“โ‚‚ T eqฮ“ = dbot <:-weakening-gen drefl ฮ“โ‚ ฮ“โ‚‚ T eqฮ“ = drefl <:-weakening-gen (dtrans Tโ€ฒ S<:Tโ€ฒ Tโ€ฒ<:U) ฮ“โ‚ ฮ“โ‚‚ T eqฮ“ = dtrans _ (<:-weakening-gen S<:Tโ€ฒ ฮ“โ‚ ฮ“โ‚‚ T eqฮ“) (<:-weakening-gen Tโ€ฒ<:U ฮ“โ‚ ฮ“โ‚‚ T eqฮ“) <:-weakening-gen (dbnd Sโ€ฒ<:S U<:Uโ€ฒ) ฮ“โ‚ ฮ“โ‚‚ T eqฮ“ = dbnd (<:-weakening-gen Sโ€ฒ<:S ฮ“โ‚ ฮ“โ‚‚ T eqฮ“) (<:-weakening-gen U<:Uโ€ฒ ฮ“โ‚ ฮ“โ‚‚ T eqฮ“) <:-weakening-gen (dall Sโ€ฒ<:S U<:Uโ€ฒ) ฮ“โ‚ ฮ“โ‚‚ T eqฮ“ = dall (<:-weakening-gen Sโ€ฒ<:S ฮ“โ‚ ฮ“โ‚‚ T eqฮ“) (<:-weakening-gen U<:Uโ€ฒ ฮ“โ‚ (_ โˆท ฮ“โ‚‚) T (cong (_ โˆท_) eqฮ“)) <:-weakening-gen (dselโ‚ {_} {n} Tโˆˆฮ“ T<:B) ฮ“โ‚ ฮ“โ‚‚ T eqฮ“ rewrite โ†‘-var n (length ฮ“โ‚‚) = dselโ‚ (โ†ฆโˆˆ-weakenโ€ฒ Tโˆˆฮ“ ฮ“โ‚ ฮ“โ‚‚ T eqฮ“) (<:-weakening-gen T<:B ฮ“โ‚ ฮ“โ‚‚ T eqฮ“) <:-weakening-gen (dselโ‚‚ {_} {n} Tโˆˆฮ“ T<:B) ฮ“โ‚ ฮ“โ‚‚ T eqฮ“ rewrite โ†‘-var n (length ฮ“โ‚‚) = dselโ‚‚ (โ†ฆโˆˆ-weakenโ€ฒ Tโˆˆฮ“ ฮ“โ‚ ฮ“โ‚‚ T eqฮ“) (<:-weakening-gen T<:B ฮ“โ‚ ฮ“โ‚‚ T eqฮ“) <:-weakening : โˆ€ {ฮ“โ‚ ฮ“โ‚‚ S U} T โ†’ ฮ“โ‚ โ€ฃ ฮ“โ‚‚ โŠข S <: U โ†’ ฮ“โ‚ โ€ฃ T ! โ€ฃ ฮ“โ‚‚ โ‡‘ โŠข S โ†‘ length ฮ“โ‚‚ <: U โ†‘ length ฮ“โ‚‚ <:-weakening T S<:U = <:-weakening-gen S<:U _ _ T refl <:-weakening-hd : โˆ€ {ฮ“ S U} T โ†’ ฮ“ โŠข S <: U โ†’ ฮ“ โ€ฃ T ! โŠข S โ†‘ 0 <: U โ†‘ 0 <:-weakening-hd T = <:-weakening {ฮ“โ‚‚ = []} T -- narrowing infix 4 _โ‰บ:[_]_ data _โ‰บ:[_]_ : Env โ†’ โ„• โ†’ Env โ†’ Set where โ‰บ[_,_] : โˆ€ {ฮ“ U} S โ†’ ฮ“ โŠข S <: U โ†’ ฮ“ โ€ฃ S ! โ‰บ:[ 0 ] ฮ“ โ€ฃ U ! _โˆท_ : โˆ€ {ฮ“โ‚ n ฮ“โ‚‚} T โ†’ ฮ“โ‚ โ‰บ:[ n ] ฮ“โ‚‚ โ†’ ฮ“โ‚ โ€ฃ T ! โ‰บ:[ suc n ] ฮ“โ‚‚ โ€ฃ T ! <:โˆˆ-find : โˆ€ {x T ฮ“ ฮ“โ€ฒ n} โ†’ x โ†ฆ T โˆˆ ฮ“ โ†’ ฮ“โ€ฒ โ‰บ:[ n ] ฮ“ โ†’ x โ‰ก n ร— (โˆƒ ฮป Tโ€ฒ โ†’ n โ†ฆ Tโ€ฒ โˆˆ ฮ“โ€ฒ ร— ฮ“โ€ฒ โŠข Tโ€ฒ <: T) โŠŽ x โ‰ข n ร— x โ†ฆ T โˆˆ ฮ“โ€ฒ <:โˆˆ-find hd โ‰บ[ Tโ€ฒ , Tโ€ฒ<:T ] = injโ‚ (refl , Tโ€ฒ โ†‘ 0 , hd , <:-weakening-hd Tโ€ฒ Tโ€ฒ<:T) <:โˆˆ-find hd (T โˆท ฮ“โ€ฒโ‰บ:ฮ“) = injโ‚‚ ((ฮป ()) , hd) <:โˆˆ-find (tl Tโˆˆฮ“) โ‰บ[ Tโ€ฒ , Tโ€ฒ<:T ] = injโ‚‚ ((ฮป ()) , tl Tโˆˆฮ“) <:โˆˆ-find (tl Tโˆˆฮ“) (S โˆท ฮ“โ€ฒโ‰บ:ฮ“) with <:โˆˆ-find Tโˆˆฮ“ ฮ“โ€ฒโ‰บ:ฮ“ ... | injโ‚ (xโ‰กn , Tโ€ฒ , Tโ€ฒโˆˆฮ“โ€ฒ , Tโ€ฒ<:T) = injโ‚ (cong suc xโ‰กn , Tโ€ฒ โ†‘ 0 , tl Tโ€ฒโˆˆฮ“โ€ฒ , <:-weakening-hd S Tโ€ฒ<:T) ... | injโ‚‚ (xโ‰ขn , Tโˆˆฮ“โ€ฒ) = injโ‚‚ (xโ‰ขn โˆ˜ suc-injective , tl Tโˆˆฮ“โ€ฒ) <:โˆˆ-findโ€ฒ : โˆ€ {x T ฮ“ ฮ“โ€ฒ n} โ†’ env-lookup ฮ“ x โ‰ก just T โ†’ ฮ“โ€ฒ โ‰บ:[ n ] ฮ“ โ†’ x โ‰ก n ร— (โˆƒ ฮป Tโ€ฒ โ†’ env-lookup ฮ“โ€ฒ n โ‰ก just Tโ€ฒ ร— ฮ“โ€ฒ โŠข Tโ€ฒ <: T) โŠŽ x โ‰ข n ร— env-lookup ฮ“โ€ฒ x โ‰ก just T <:โˆˆ-findโ€ฒ Tโˆˆฮ“ ฮ“โ€ฒโ‰บฮ“ with <:โˆˆ-find (lookupโ‡’โ†ฆโˆˆ Tโˆˆฮ“) ฮ“โ€ฒโ‰บฮ“ ... | injโ‚ (xโ‰กn , Tโ€ฒ , Tโ€ฒโˆˆฮ“โ€ฒ , Tโ€ฒ<:T) = injโ‚ (xโ‰กn , Tโ€ฒ , โ†ฆโˆˆโ‡’lookup Tโ€ฒโˆˆฮ“โ€ฒ , Tโ€ฒ<:T) ... | injโ‚‚ (xโ‰ขn , Tโˆˆฮ“โ€ฒ) = injโ‚‚ (xโ‰ขn , โ†ฆโˆˆโ‡’lookup Tโˆˆฮ“โ€ฒ) <:-narrow : โˆ€ {ฮ“ ฮ“โ€ฒ n S U T} โ†’ ฮ“ โŠข S <: U โ†’ ฮ“โ€ฒ โ‰บ:[ n ] ฮ“ โ†’ env-lookup ฮ“ n โ‰ก just T โ†’ ฮ“โ€ฒ โŠข S <: U <:-narrow dtop ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“ = dtop <:-narrow dbot ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“ = dbot <:-narrow drefl ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“ = drefl <:-narrow (dtrans T S<:T T<:U) ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“ = dtrans T (<:-narrow S<:T ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“) (<:-narrow T<:U ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“) <:-narrow (dbnd Sโ€ฒ<:S U<:Uโ€ฒ) ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“ = dbnd (<:-narrow Sโ€ฒ<:S ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“) (<:-narrow U<:Uโ€ฒ ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“) <:-narrow {ฮ“} {ฮ“โ€ฒ} {n} (dall {Sโ€ฒ = Sโ€ฒ} Sโ€ฒ<:S U<:Uโ€ฒ) ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“ = dall (<:-narrow Sโ€ฒ<:S ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“) (<:-narrow U<:Uโ€ฒ (_ โˆท ฮ“โ€ฒโ‰บฮ“) (โ†ฆโˆˆโ‡’lookup (tl {n} {Tโ€ฒ = Sโ€ฒ} {ฮ“} (lookupโ‡’โ†ฆโˆˆ Tโˆˆฮ“)))) <:-narrow (dselโ‚ Tโ€ฒโˆˆฮ“ Tโ€ฒ<:B) ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“ with <:โˆˆ-findโ€ฒ Tโ€ฒโˆˆฮ“ ฮ“โ€ฒโ‰บฮ“ ... | injโ‚ (refl , Tโ€ณ , Tโ€ณโˆˆฮ“โ€ฒ , Tโ€ณ<:T) rewrite just-injective (trans (sym Tโ€ฒโˆˆฮ“) Tโˆˆฮ“) = dselโ‚ Tโ€ณโˆˆฮ“โ€ฒ (dtrans _ Tโ€ณ<:T (<:-narrow Tโ€ฒ<:B ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“)) ... | injโ‚‚ (xโ‰ขn , Tโ€ฒโˆˆฮ“โ€ฒ) = dselโ‚ Tโ€ฒโˆˆฮ“โ€ฒ (<:-narrow Tโ€ฒ<:B ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“) <:-narrow (dselโ‚‚ Tโ€ฒโˆˆฮ“ Tโ€ฒ<:B) ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“ with <:โˆˆ-findโ€ฒ Tโ€ฒโˆˆฮ“ ฮ“โ€ฒโ‰บฮ“ ... | injโ‚ (refl , Tโ€ณ , Tโ€ณโˆˆฮ“โ€ฒ , Tโ€ณ<:T) rewrite just-injective (trans (sym Tโ€ฒโˆˆฮ“) Tโˆˆฮ“) = dselโ‚‚ Tโ€ณโˆˆฮ“โ€ฒ (dtrans _ Tโ€ณ<:T (<:-narrow Tโ€ฒ<:B ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“)) ... | injโ‚‚ (xโ‰ขn , Tโ€ฒโˆˆฮ“โ€ฒ) = dselโ‚‚ Tโ€ฒโˆˆฮ“โ€ฒ (<:-narrow Tโ€ฒ<:B ฮ“โ€ฒโ‰บฮ“ Tโˆˆฮ“) open Dsub hiding (<:-weakening-gen; <:-weakening; <:-weakening-hd ; _โ‰บ:[_]_; โ‰บ[_,_]; _โˆท_; <:โˆˆ-find; <:โˆˆ-findโ€ฒ; <:-narrow) public -- materialization of inversion properties in invertible contexts module DsubInvProperties {P : Env โ†’ Set} (invertible : InvertibleEnv P) where module ContraEnvProperties = InvertibleProperties invertible _โŠข_<:_ open ContraEnvProperties public mutual <:โ‡’<:แตข : โˆ€ {ฮ“ S U} โ†’ ฮ“ โŠข S <: U โ†’ P ฮ“ โ†’ ฮ“ โŠขแตข S <: U <:โ‡’<:แตข dtop pฮ“ = ditop <:โ‡’<:แตข dbot pฮ“ = dibot <:โ‡’<:แตข drefl pฮ“ = direfl <:โ‡’<:แตข (dtrans T S<:T T<:U) pฮ“ = ditrans T (<:โ‡’<:แตข S<:T pฮ“) (<:โ‡’<:แตข T<:U pฮ“) <:โ‡’<:แตข (dbnd Sโ€ฒ<:S U<:Uโ€ฒ) pฮ“ = dibnd (<:โ‡’<:แตข Sโ€ฒ<:S pฮ“) (<:โ‡’<:แตข U<:Uโ€ฒ pฮ“) <:โ‡’<:แตข (dall Sโ€ฒ<:S U<:Uโ€ฒ) pฮ“ = diall (<:โ‡’<:แตข Sโ€ฒ<:S pฮ“) U<:Uโ€ฒ <:โ‡’<:แตข (dselโ‚ Tโˆˆฮ“ T<:B) pฮ“ with sel-case Tโˆˆฮ“ T<:B pฮ“ ... | refl , _ = dibot <:โ‡’<:แตข (dselโ‚‚ Tโˆˆฮ“ T<:B) pฮ“ with sel-case Tโˆˆฮ“ T<:B pฮ“ ... | refl , Uโ€ฒ , refl with โŸจA:โŸฉ<:โŸจA:โŸฉ (<:โ‡’<:แตข T<:B pฮ“) pฮ“ ... | _ , Uโ€ฒ<:U = ditrans Uโ€ฒ (disel Tโˆˆฮ“) Uโ€ฒ<:U sel-case : โˆ€ {T ฮ“ n S U} โ†’ env-lookup ฮ“ n โ‰ก just T โ†’ ฮ“ โŠข T <: โŸจA: S โ‹ฏ U โŸฉ โ†’ P ฮ“ โ†’ S โ‰ก โŠฅ ร— โˆƒ ฮป Uโ€ฒ โ†’ T โ‰ก โŸจA: โŠฅ โ‹ฏ Uโ€ฒ โŸฉ sel-case {โŠค} Tโˆˆฮ“ T<:B pฮ“ = case โŠค<: (<:โ‡’<:แตข T<:B pฮ“) of ฮป () sel-case {โŠฅ} Tโˆˆฮ“ T<:B pฮ“ = โŠฅ-elim (no-โŠฅ pฮ“ Tโˆˆฮ“) sel-case {n โˆ™A} Tโˆˆฮ“ T<:B pฮ“ with <:โŸจA:โŸฉ (<:โ‡’<:แตข T<:B pฮ“) pฮ“ ... | injโ‚ () ... | injโ‚‚ (_ , _ , ()) sel-case {ฮ  S โˆ™ U} Tโˆˆฮ“ T<:B pฮ“ with <:โŸจA:โŸฉ (<:โ‡’<:แตข T<:B pฮ“) pฮ“ ... | injโ‚ () ... | injโ‚‚ (_ , _ , ()) sel-case {โŸจA: S โ‹ฏ U โŸฉ} Tโˆˆฮ“ T<:B pฮ“ rewrite โŠฅ-lb pฮ“ Tโˆˆฮ“ with โŸจA:โŸฉ<:โŸจA:โŸฉ (<:โ‡’<:แตข T<:B pฮ“) pฮ“ ... | S<:โŠฅ , _ with <:โŠฅ S<:โŠฅ pฮ“ ... | refl = refl , U , refl <:แตขโ‡’<: : โˆ€ {ฮ“ S U} โ†’ ฮ“ โŠขแตข S <: U โ†’ ฮ“ โŠข S <: U <:แตขโ‡’<: ditop = dtop <:แตขโ‡’<: dibot = dbot <:แตขโ‡’<: direfl = drefl <:แตขโ‡’<: (ditrans T S<:T T<:U) = dtrans T (<:แตขโ‡’<: S<:T) (<:แตขโ‡’<: T<:U) <:แตขโ‡’<: (dibnd Sโ€ฒ<:S U<:Uโ€ฒ) = dbnd (<:แตขโ‡’<: Sโ€ฒ<:S) (<:แตขโ‡’<: U<:Uโ€ฒ) <:แตขโ‡’<: (diall Sโ€ฒ<:S U<:Uโ€ฒ) = dall (<:แตขโ‡’<: Sโ€ฒ<:S) U<:Uโ€ฒ <:แตขโ‡’<: (disel Tโˆˆฮ“) = dselโ‚‚ Tโˆˆฮ“ drefl โŠค<:โ€ฒ : โˆ€ {ฮ“ T} โ†’ ฮ“ โŠข โŠค <: T โ†’ P ฮ“ โ†’ T โ‰ก โŠค โŠค<:โ€ฒ โŠค<:T = โŠค<: โˆ˜ <:โ‡’<:แตข โŠค<:T <:โŠฅโ€ฒ : โˆ€ {ฮ“ T} โ†’ ฮ“ โŠข T <: โŠฅ โ†’ P ฮ“ โ†’ T โ‰ก โŠฅ <:โŠฅโ€ฒ T<:โŠฅ pฮ“ = <:โŠฅ (<:โ‡’<:แตข T<:โŠฅ pฮ“) pฮ“ โŸจA:โŸฉ<:โŸจA:โŸฉโ€ฒ : โˆ€ {ฮ“ Sโ€ฒ U Uโ€ฒ} โ†’ ฮ“ โŠข โŸจA: โŠฅ โ‹ฏ U โŸฉ <: โŸจA: Sโ€ฒ โ‹ฏ Uโ€ฒ โŸฉ โ†’ P ฮ“ โ†’ Sโ€ฒ โ‰ก โŠฅ โŸจA:โŸฉ<:โŸจA:โŸฉโ€ฒ B<:Bโ€ฒ pฮ“ with โŸจA:โŸฉ<:โŸจA:โŸฉ (<:โ‡’<:แตข B<:Bโ€ฒ pฮ“) pฮ“ ... | S<:โŠฅ , _ = <:โŠฅ S<:โŠฅ pฮ“ ฮ <:โŸจA:โŸฉโ‡’โŠฅ : โˆ€ {ฮ“ S U Sโ€ฒ Uโ€ฒ} โ†’ ฮ“ โŠขแตข ฮ  S โˆ™ U <: โŸจA: Sโ€ฒ โ‹ฏ Uโ€ฒ โŸฉ โ†’ P ฮ“ โ†’ False ฮ <:โŸจA:โŸฉโ‡’โŠฅ ฮ <:โŸจA:โŸฉ eฮ“ with <:โŸจA:โŸฉ ฮ <:โŸจA:โŸฉ eฮ“ ... | injโ‚ () ... | injโ‚‚ (_ , _ , ()) โˆ™A<:โŸจA:โŸฉโ‡’โŠฅ : โˆ€ {ฮ“ x S U} โ†’ ฮ“ โŠขแตข x โˆ™A <: โŸจA: S โ‹ฏ U โŸฉ โ†’ P ฮ“ โ†’ False โˆ™A<:โŸจA:โŸฉโ‡’โŠฅ xโˆ™A<:โŸจA:โŸฉ eฮ“ with <:โŸจA:โŸฉ xโˆ™A<:โŸจA:โŸฉ eฮ“ ... | injโ‚ () ... | injโ‚‚ (_ , _ , ()) ฮ <:ฮ  : โˆ€ {ฮ“ S U Sโ€ฒ Uโ€ฒ} โ†’ ฮ“ โŠข ฮ  S โˆ™ U <: ฮ  Sโ€ฒ โˆ™ Uโ€ฒ โ†’ P ฮ“ โ†’ ฮ“ โŠข Sโ€ฒ <: S ร— (Sโ€ฒ โˆท ฮ“) โŠข U <: Uโ€ฒ ฮ <:ฮ  <: pฮ“ = ฮฃ.mapโ‚ <:แตขโ‡’<: $ helper (<:โ‡’<:แตข <: pฮ“) pฮ“ where helper : โˆ€ {ฮ“ S U Sโ€ฒ Uโ€ฒ} โ†’ ฮ“ โŠขแตข ฮ  S โˆ™ U <: ฮ  Sโ€ฒ โˆ™ Uโ€ฒ โ†’ P ฮ“ โ†’ ฮ“ โŠขแตข Sโ€ฒ <: S ร— (Sโ€ฒ โˆท ฮ“) โŠข U <: Uโ€ฒ helper direfl pฮ“ = direfl , drefl helper (ditrans T <: <:โ€ฒ) pฮ“ with ฮ <: <: ... | injโ‚ refl = case โŠค<: <:โ€ฒ of ฮป () ... | injโ‚‚ (_ , _ , refl) with helper <: pฮ“ | helper <:โ€ฒ pฮ“ ... | Sโ€ณ<:Sโ€ฒ , Uโ€ฒ<:Uโ€ณ | Sโ€ด<:Sโ€ณ , Uโ€ณ<:Uโ€ด = ditrans _ Sโ€ด<:Sโ€ณ Sโ€ณ<:Sโ€ฒ , dtrans _ (Dsub.<:-narrow Uโ€ฒ<:Uโ€ณ Dsub.โ‰บ[ _ , <:แตขโ‡’<: Sโ€ด<:Sโ€ณ ] refl) Uโ€ณ<:Uโ€ด helper (diall <: U<:Uโ€ฒ) pฮ“ = <: , U<:Uโ€ฒ
{ "alphanum_fraction": 0.3749241505, "avg_line_length": 41.5899053628, "ext": "agda", "hexsha": "b3bdb7f9ae3f9ad25a5b08f94fd88447ebf9a414", "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": "48214a55ebb484fd06307df4320813d4a002535b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "HuStmpHrrr/popl20-artifact", "max_forks_repo_path": "agda/Dsub.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b", "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": "HuStmpHrrr/popl20-artifact", "max_issues_repo_path": "agda/Dsub.agda", "max_line_length": 127, "max_stars_count": 1, "max_stars_repo_head_hexsha": "48214a55ebb484fd06307df4320813d4a002535b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "HuStmpHrrr/popl20-artifact", "max_stars_repo_path": "agda/Dsub.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-23T08:40:28.000Z", "max_stars_repo_stars_event_min_datetime": "2021-09-23T08:40:28.000Z", "num_tokens": 6700, "size": 13184 }
{- This second-order equational theory was created from the following second-order syntax description: syntax Sum | S type _โŠ•_ : 2-ary | l30 term inl : ฮฑ -> ฮฑ โŠ• ฮฒ inr : ฮฒ -> ฮฑ โŠ• ฮฒ case : ฮฑ โŠ• ฮฒ ฮฑ.ฮณ ฮฒ.ฮณ -> ฮณ theory (lฮฒ) a : ฮฑ f : ฮฑ.ฮณ g : ฮฒ.ฮณ |> case (inl(a), x.f[x], y.g[y]) = f[a] (rฮฒ) b : ฮฒ f : ฮฑ.ฮณ g : ฮฒ.ฮณ |> case (inr(b), x.f[x], y.g[y]) = g[b] (cฮท) s : ฮฑ โŠ• ฮฒ c : (ฮฑ โŠ• ฮฒ).ฮณ |> case (s, x.c[inl(x)], y.c[inr(y)]) = c[s] -} module Sum.Equality where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Families.Build open import SOAS.ContextMaps.Inductive open import Sum.Signature open import Sum.Syntax open import SOAS.Metatheory.SecondOrder.Metasubstitution S:Syn open import SOAS.Metatheory.SecondOrder.Equality S:Syn private variable ฮฑ ฮฒ ฮณ ฯ„ : ST ฮ“ ฮ” ฮ  : Ctx infix 1 _โ–น_โŠข_โ‰‹โ‚_ -- Axioms of equality data _โ–น_โŠข_โ‰‹โ‚_ : โˆ€ ๐” ฮ“ {ฮฑ} โ†’ (๐” โ–ท S) ฮฑ ฮ“ โ†’ (๐” โ–ท S) ฮฑ ฮ“ โ†’ Set where lฮฒ : โ… ฮฑ โ† โ… ฮฑ โŠฉ ฮณ โ† โ… ฮฒ โŠฉ ฮณ โ†ฬฃ โ–น โˆ… โŠข case (inl ๐”ž) (๐”ŸโŸจ xโ‚€ โŸฉ) (๐” โŸจ xโ‚€ โŸฉ) โ‰‹โ‚ ๐”ŸโŸจ ๐”ž โŸฉ rฮฒ : โ… ฮฒ โ† โ… ฮฑ โŠฉ ฮณ โ† โ… ฮฒ โŠฉ ฮณ โ†ฬฃ โ–น โˆ… โŠข case (inr ๐”ž) (๐”ŸโŸจ xโ‚€ โŸฉ) (๐” โŸจ xโ‚€ โŸฉ) โ‰‹โ‚ ๐” โŸจ ๐”ž โŸฉ cฮท : โ… ฮฑ โŠ• ฮฒ โ† โ… (ฮฑ โŠ• ฮฒ) โŠฉ ฮณ โ†ฬฃ โ–น โˆ… โŠข case ๐”ž (๐”ŸโŸจ inl xโ‚€ โŸฉ) (๐”ŸโŸจ inr xโ‚€ โŸฉ) โ‰‹โ‚ ๐”ŸโŸจ ๐”ž โŸฉ open EqLogic _โ–น_โŠข_โ‰‹โ‚_ open โ‰‹-Reasoning
{ "alphanum_fraction": 0.5562403698, "avg_line_length": 25.96, "ext": "agda", "hexsha": "860df4c5d98e9c0893989137438cdfa86c432c67", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/Sum/Equality.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/Sum/Equality.agda", "max_line_length": 99, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/Sum/Equality.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 665, "size": 1298 }
open import Relation.Binary.Core module BBHeap.Subtyping {A : Set} (_โ‰ค_ : A โ†’ A โ†’ Set) (transโ‰ค : Transitive _โ‰ค_) where open import BBHeap _โ‰ค_ open import Bound.Lower A open import Bound.Lower.Order _โ‰ค_ open import Bound.Lower.Order.Properties _โ‰ค_ transโ‰ค subtyping : {b b' : Bound} โ†’ LeB b' b โ†’ BBHeap b โ†’ BBHeap b' subtyping _ leaf = leaf subtyping b'โ‰คb (left bโ‰คx lโ‹˜r) = left (transLeB b'โ‰คb bโ‰คx) lโ‹˜r subtyping b'โ‰คb (right bโ‰คx lโ‹™r) = right (transLeB b'โ‰คb bโ‰คx) lโ‹™r
{ "alphanum_fraction": 0.6316831683, "avg_line_length": 31.5625, "ext": "agda", "hexsha": "ed2a0959a153a61fbbc223f166af6963c92f0905", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bgbianchi/sorting", "max_forks_repo_path": "agda/BBHeap/Subtyping.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bgbianchi/sorting", "max_issues_repo_path": "agda/BBHeap/Subtyping.agda", "max_line_length": 62, "max_stars_count": 6, "max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bgbianchi/sorting", "max_stars_repo_path": "agda/BBHeap/Subtyping.agda", "max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z", "max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z", "num_tokens": 197, "size": 505 }
-- Andreas, 2016-12-22, issue #2354 -- Interaction between size solver, constraint solver, and instance search. -- The instance search fails initially because of a non rigid meta. -- Before freezing, there is another attempt. -- The instance search succeeds and instantiates the meta for M. -- Then, a size constraint is solved which had blocked a term. -- Finally the blocking constraint can be resolved. -- Thus, we need to -- * wake constraints -- * solve size constraints -- * wake constraints again. -- In principle, there could be many alternations needed!? -- {-# OPTIONS -v tc.meta:30 -v tc.instance:30 -v tc.constr:50 -v tc.size:30 -v tc.decl:10 #-} -- {-# OPTIONS -v tc.instance:30 -v tc.decl:20 #-} -- {-# OPTIONS -v tc.instance.rigid:100 -v tc.instance:70 -v tc.size:30 #-} -- {-# OPTIONS -v tc.term.con:50 #-} {-# BUILTIN SIZEUNIV SizeU #-} {-# BUILTIN SIZE Size #-} {-# BUILTIN SIZELT Size<_ #-} {-# BUILTIN SIZESUC โ†‘_ #-} {-# BUILTIN SIZEINF ฯ‰ #-} record โŠค : Set where constructor tt record RawMonad (M : Set โ†’ Set) : Setโ‚ where field return : โˆ€{A} โ†’ A โ†’ M A mutual data Delay (i : Size) (A : Set) : Set where now : A โ†’ Delay i A later : Delayโˆž i A โ†’ Delay i A record Delayโˆž (i : Size) (A : Set) : Set where coinductive field force : โˆ€ {j : Size< i} โ†’ Delay j A instance RawMonad-Delay : โˆ€ {i} โ†’ RawMonad (Delay i) RawMonad-Delay = record { return = Delay.now } open RawMonad {{...}} test : โˆ€ {i} โ†’ Delay i โŠค test {i} = return tt -- Solution: return {{RawMonad-Delay {i}}} tt -- Should find solution!
{ "alphanum_fraction": 0.6376262626, "avg_line_length": 29.3333333333, "ext": "agda", "hexsha": "905a6ff16bbf743c8b9a2356efc366f913d98474", "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/Issue2354.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/Issue2354.agda", "max_line_length": 94, "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/Issue2354.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": 469, "size": 1584 }
{-# OPTIONS --allow-unsolved-metas #-} module TermByFunctionNames where open import OscarPrelude open import VariableName open import FunctionName data TermByFunctionNames : Nat โ†’ Set where variable : VariableName โ†’ TermByFunctionNames zero function : FunctionName โ†’ {arity : Nat} โ†’ (ฯ„s : Vec (ฮฃ Nat TermByFunctionNames) arity) โ†’ {n : Nat} โ†’ n โ‰ก sum (vecToList $ (fst <$> ฯ„s)) โ†’ TermByFunctionNames (suc n) mutual eqTermByFunctionNames : โˆ€ {n} โ†’ (x y : TermByFunctionNames n) โ†’ Dec (x โ‰ก y) eqTermByFunctionNames = {!!} {- eqTermByFunctionNames : โˆ€ {n} โ†’ (x y : TermByFunctionNames n) โ†’ Dec (x โ‰ก y) eqTermByFunctionNames {.0} (variable x) (variable xโ‚) = {!!} eqTermByFunctionNames {.(suc n)} (function x {arity = arityโ‚} ฯ„s {n = n} xโ‚) (function xโ‚‚ {arity = arityโ‚‚} ฯ„sโ‚ {n = .n} xโ‚ƒ) with x โ‰Ÿ xโ‚‚ | arityโ‚ โ‰Ÿ arityโ‚‚ eqTermByFunctionNames {.(suc n)} (function x {arityโ‚} ฯ„s {n} xโ‚„) (function .x {.arityโ‚} ฯ„sโ‚ {.n} xโ‚…) | yes refl | (yes refl) with eqTermByFunctionNamess ฯ„s ฯ„sโ‚ eqTermByFunctionNames {.(suc n)} (function xโ‚ {arityโ‚} ฯ„s {n} xโ‚„) (function .xโ‚ {.arityโ‚} .ฯ„s {.n} xโ‚…) | yes refl | (yes refl) | (yes refl) rewrite xโ‚„ | xโ‚… = yes refl eqTermByFunctionNames {.(suc n)} (function xโ‚ {arityโ‚} ฯ„s {n} xโ‚„) (function .xโ‚ {.arityโ‚} ฯ„sโ‚ {.n} xโ‚…) | yes refl | (yes refl) | (no x) = {!!} eqTermByFunctionNames {.(suc n)} (function x {arityโ‚} ฯ„s {n} xโ‚„) (function xโ‚‚ {arityโ‚‚} ฯ„sโ‚ {.n} xโ‚…) | yes xโ‚ | (no xโ‚ƒ) = {!!} eqTermByFunctionNames {.(suc n)} (function x {arityโ‚} ฯ„s {n} xโ‚„) (function xโ‚‚ {arityโ‚‚} ฯ„sโ‚ {.n} xโ‚…) | no xโ‚ | (yes xโ‚ƒ) = {!!} eqTermByFunctionNames {.(suc n)} (function x {arityโ‚} ฯ„s {n} xโ‚„) (function xโ‚‚ {arityโ‚‚} ฯ„sโ‚ {.n} xโ‚…) | no xโ‚ | (no xโ‚ƒ) = {!!} -} eqTermByFunctionNamess : โˆ€ {n} โ†’ (x y : Vec (ฮฃ Nat TermByFunctionNames) n) โ†’ Dec (x โ‰ก y) eqTermByFunctionNamess {.0} [] [] = {!!} eqTermByFunctionNamess (_โˆท_ {n = n} (fstโ‚ , sndโ‚) xโ‚) (_โˆท_ {n = .n} (fstโ‚‚ , sndโ‚‚) y) with fstโ‚ โ‰Ÿ fstโ‚‚ eqTermByFunctionNamess (_โˆท_ {n = n} (fstโ‚ , sndโ‚) xโ‚) (_โˆท_ {n = .n} (fstโ‚‚ , sndโ‚‚) y) | yes refl with eqTermByFunctionNames sndโ‚ sndโ‚‚ eqTermByFunctionNamess (_โˆท_ {n = n} (fstโ‚ , sndโ‚) xโ‚) (_โˆท_ {n = .n} (fstโ‚‚ , sndโ‚‚) y) | yes refl | yes refl with eqTermByFunctionNamess xโ‚ y eqTermByFunctionNamess (_โˆท_ {n = n} (fstโ‚ , sndโ‚) xโ‚) (_โˆท_ {n = .n} (fstโ‚‚ , sndโ‚‚) y) | yes refl | yes refl | yes refl = yes refl eqTermByFunctionNamess (_โˆท_ {n = n} (fstโ‚ , sndโ‚) xโ‚) (_โˆท_ {n = .n} (fstโ‚‚ , sndโ‚‚) y) | yes refl | yes refl | no ref = {!!} eqTermByFunctionNamess (_โˆท_ {n = n} (fstโ‚ , sndโ‚) xโ‚) (_โˆท_ {n = .n} (fstโ‚‚ , sndโ‚‚) y) | yes refl | no ref = {!!} eqTermByFunctionNamess (_โˆท_ {n = n} (fstโ‚ , sndโ‚) xโ‚) (_โˆท_ {n = .n} (fstโ‚‚ , sndโ‚‚) y) | no ref = {!!} instance EqTermByFunctionNames : โˆ€ {n} โ†’ Eq (TermByFunctionNames n) Eq._==_ EqTermByFunctionNames = eqTermByFunctionNames {- instance EqTermByFunctionNames : โˆ€ {n} โ†’ Eq (TermByFunctionNames n) Eq._==_ EqTermByFunctionNames (variable x) (variable xโ‚) = {!!} Eq._==_ EqTermByFunctionNames (function x {arity = arityโ‚} ฯ„s {n = n} xโ‚) (function xโ‚‚ {arity = arityโ‚‚} ฯ„sโ‚ {n = .n} xโ‚ƒ) with x โ‰Ÿ xโ‚‚ | arityโ‚ โ‰Ÿ arityโ‚‚ Eq._==_ EqTermByFunctionNames (function x {arityโ‚} ฯ„s {n} xโ‚„) (function .x {.arityโ‚} ฯ„sโ‚ {.n} xโ‚…) | yes refl | (yes refl) with ฯ„s โ‰Ÿ ฯ„sโ‚ Eq._==_ EqTermByFunctionNames (function x {arityโ‚} ฯ„s {n} xโ‚„) (function .x {.arityโ‚} ฯ„sโ‚ {.n} xโ‚…) | yes refl | (yes refl) | ฯ„sโ‰กฯ„sโ‚ = {!!} Eq._==_ EqTermByFunctionNames (function x {arityโ‚} ฯ„s {n} xโ‚„) (function xโ‚‚ {arityโ‚‚} ฯ„sโ‚ {.n} xโ‚…) | yes xโ‚ | (no xโ‚ƒ) = {!!} Eq._==_ EqTermByFunctionNames (function x {arityโ‚} ฯ„s {n} xโ‚„) (function xโ‚‚ {arityโ‚‚} ฯ„sโ‚ {.n} xโ‚…) | no xโ‚ | (yes xโ‚ƒ) = {!!} Eq._==_ EqTermByFunctionNames (function x {arityโ‚} ฯ„s {n} xโ‚„) (function xโ‚‚ {arityโ‚‚} ฯ„sโ‚ {.n} xโ‚…) | no xโ‚ | (no xโ‚ƒ) = {!!} -}
{ "alphanum_fraction": 0.6349036403, "avg_line_length": 74.72, "ext": "agda", "hexsha": "d8c29ccd65a2442424f77b353b9d47a3536ba783", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/TermByFunctionNames.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/TermByFunctionNames.agda", "max_line_length": 168, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/TermByFunctionNames.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1550, "size": 3736 }
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.ZCohomology.RingStructure.CohomologyRing where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Transport open import Cubical.Data.Nat renaming (_+_ to _+n_ ; _ยท_ to _ยทn_) open import Cubical.Data.Sum open import Cubical.Algebra.Group open import Cubical.Algebra.Group.Morphisms open import Cubical.Algebra.Group.MorphismProperties open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Ring open import Cubical.Algebra.DirectSum.Base open import Cubical.Algebra.AbGroup.Instances.DirectSum open import Cubical.HITs.SetTruncation as ST open import Cubical.ZCohomology.Base open import Cubical.ZCohomology.GroupStructure open import Cubical.ZCohomology.RingStructure.CupProduct open import Cubical.ZCohomology.RingStructure.RingLaws open import Cubical.ZCohomology.RingStructure.GradedCommutativity private variable โ„“ โ„“' : Level open Iso ----------------------------------------------------------------------------- -- Definition Cohomology Ring module intermediate-def where H*AbGr : (A : Type โ„“) โ†’ AbGroup โ„“ H*AbGr A = โŠ•-AbGr โ„• (ฮป n โ†’ coHom n A) (ฮป n โ†’ snd (coHomGroup n A)) H* : (A : Type โ„“) โ†’ Type โ„“ H* A = fst (H*AbGr A) module CupRingProperties (A : Type โ„“) where open intermediate-def open AbGroupStr (snd (H*AbGr A)) open AbGroupTheory (H*AbGr A) _cup_ : H* A โ†’ H* A โ†’ H* A _cup_ = DS-Rec-Set.f โ„• (ฮป n โ†’ coHom n A) (ฮป n โ†’ snd (coHomGroup n A)) (H* A โ†’ H* A) (ฮป f g p q i j x โ†’ is-set (f x) (g x) (ฮป X โ†’ p X x) (ฮป X โ†’ q X x) i j) -- elements (ฮป x โ†’ 0g) (ฮป n a โ†’ DS-Rec-Set.f โ„• _ _ (H* A) is-set -- elements 0g (ฮป m b โ†’ base (n +' m) (a โŒฃ b)) _+_ -- equations assoc rid comm (ฮป m โ†’ (cong (base (n +' m)) (โŒฃ-0โ‚• n m a)) โˆ™ (base-neutral (n +' m))) ฮป m b c โ†’ base-add (n +' m) (a โŒฃ b) (a โŒฃ c) โˆ™ cong (base (n +' m)) (sym (leftDistr-โŒฃ n m a b c))) (ฮป U V y โ†’ (U y) + (V y)) -- equations (ฮป xs ys zs i y โ†’ assoc (xs y) (ys y) (zs y) i) (ฮป xs i y โ†’ rid (xs y) i) (ฮป xs ys i y โ†’ comm (xs y) (ys y) i) (ฮป n โ†’ funExt( DS-Ind-Prop.f โ„• _ _ _ (ฮป _ โ†’ is-set _ _) refl (ฮป m b โ†’ cong (base (n +' m)) (0โ‚•-โŒฃ n m b) โˆ™ base-neutral (n +' m)) ฮป {U V} ind-U ind-V โ†’ (congโ‚‚ _+_ ind-U ind-V) โˆ™ (rid 0g))) ฮป n a b โ†’ funExt ( DS-Ind-Prop.f โ„• _ _ _ (ฮป _ โ†’ is-set _ _) (rid 0g) (ฮป m c โ†’ (base-add (n +' m) (a โŒฃ c) (b โŒฃ c)) โˆ™ (cong (base (n +' m)) (sym (rightDistr-โŒฃ n m a b c)))) ฮป {U V} ind-U ind-V โ†’ comm-4 _ _ _ _ โˆ™ congโ‚‚ _+_ ind-U ind-V) 1H* : H* A 1H* = base 0 1โŒฃ cupAssoc : (x y z : H* A) โ†’ x cup (y cup z) โ‰ก (x cup y) cup z cupAssoc = DS-Ind-Prop.f โ„• _ _ _ (ฮป x p q i y z j โ†’ is-set _ _ (p y z) (q y z) i j) (ฮป y z โ†’ refl) (ฮป n a โ†’ DS-Ind-Prop.f โ„• _ _ _ (ฮป y p q i z j โ†’ is-set _ _ (p z) (q z) i j) (ฮป z โ†’ refl) (ฮป m b โ†’ DS-Ind-Prop.f โ„• _ _ _ (ฮป _ โ†’ is-set _ _) refl (ฮป k c โ†’ (cong (base (n +' (m +' k))) (assoc-โŒฃ n m k a b c)) โˆ™ sym (constSubstCommSlice (ฮป n โ†’ coHom n A) (H* A) base (sym (+'-assoc n m k)) ((a โŒฃ b) โŒฃ c))) ฮป {U V} ind-U ind-V โ†’ congโ‚‚ _+_ ind-U ind-V) ฮป {U V} ind-U ind-V z โ†’ congโ‚‚ _+_ (ind-U z) (ind-V z)) ฮป {U V} ind-U ind-V y z โ†’ congโ‚‚ _+_ (ind-U y z) (ind-V y z) cupIdR : (x : H* A) โ†’ x cup 1H* โ‰ก x cupIdR = DS-Ind-Prop.f โ„• _ _ _ (ฮป _ โ†’ is-set _ _) refl (ฮป n a โ†’ (cong (base (n +' 0)) (lUnitโŒฃ n a)) โˆ™ sym (constSubstCommSlice (ฮป n โ†’ coHom n A) (H* A) base (sym (n+'0 n)) a)) ฮป {U V} ind-U ind-V โ†’ (congโ‚‚ _+_ ind-U ind-V) cupIdL : (x : H* A) โ†’ 1H* cup x โ‰ก x cupIdL = DS-Ind-Prop.f โ„• _ _ _ (ฮป _ โ†’ is-set _ _) refl (ฮป n a โ†’ cong (base n) (rUnitโŒฃ n a)) (ฮป {U V} ind-U ind-V โ†’ congโ‚‚ _+_ ind-U ind-V) cupDistR : (x y z : H* A) โ†’ x cup (y + z) โ‰ก (x cup y) + (x cup z) cupDistR = DS-Ind-Prop.f โ„• _ _ _ (ฮป x p q i y z j โ†’ is-set _ _ (p y z) (q y z) i j) (ฮป y z โ†’ sym (rid 0g)) (ฮป n a y z โ†’ refl) ฮป {U V} ind-U ind-V y z โ†’ congโ‚‚ _+_ (ind-U y z) (ind-V y z) โˆ™ comm-4 (U cup y) (U cup z) (V cup y) (V cup z) cupDistL : (x y z : H* A) โ†’ (x + y) cup z โ‰ก (x cup z) + (y cup z) cupDistL = ฮป x y z โ†’ refl ----------------------------------------------------------------------------- -- Graded Comutative Ring -- def + commutation with base -^-gen : (n m : โ„•) โ†’ (p : isEvenT n โŠŽ isOddT n) โ†’ (q : isEvenT m โŠŽ isOddT m) โ†’ H* A โ†’ H* A -^-gen n m (inl p) q x = x -^-gen n m (inr p) (inl q) x = x -^-gen n m (inr p) (inr q) x = - x -^_ยท_ : (n m : โ„•) โ†’ H* A โ†’ H* A -^_ยท_ n m x = -^-gen n m (evenOrOdd n) (evenOrOdd m) x -^-gen-base : {k : โ„•} โ†’ (n m : โ„•) โ†’ (p : isEvenT n โŠŽ isOddT n) โ†’ (q : isEvenT m โŠŽ isOddT m) (a : coHom k A) โ†’ -^-gen n m p q (base k a) โ‰ก base k (-โ‚•^-gen n m p q a) -^-gen-base n m (inl p) q a = refl -^-gen-base n m (inr p) (inl q) a = refl -^-gen-base n m (inr p) (inr q) a = refl -^-base : {k : โ„•} โ†’ (n m : โ„•) โ†’ (a : coHom k A) โ†’ (-^ n ยท m) (base k a) โ‰ก base k ((-โ‚•^ n ยท m) a) -^-base n m a = -^-gen-base n m (evenOrOdd n) (evenOrOdd m) a module _ (A : Type โ„“) where open intermediate-def renaming (H* to H*') open CupRingProperties A open AbGroupStr (snd (H*AbGr A)) open AbGroupTheory (H*AbGr A) H*R : Ring โ„“ fst H*R = H*' A RingStr.0r (snd H*R) = 0g RingStr.1r (snd H*R) = 1H* RingStr._+_ (snd H*R) = _+_ RingStr._ยท_ (snd H*R) = _cup_ RingStr.- snd H*R = -_ RingStr.isRing (snd H*R) = makeIsRing is-set assoc rid (ฮป x โ†’ fst (inverse x)) comm cupAssoc cupIdR cupIdL cupDistR cupDistL H* : Type โ„“ H* = fst H*R gradCommRing : (n m : โ„•) โ†’ (a : coHom n A) โ†’ (b : coHom m A) โ†’ (base n a) cup (base m b) โ‰ก (-^ n ยท m) ((base m b) cup (base n a)) gradCommRing n m a b = base (n +' m) (a โŒฃ b) โ‰กโŸจ cong (base (n +' m)) (gradedComm-โŒฃ n m a b) โŸฉ base (n +' m) ((-โ‚•^ n ยท m) (subst (ฮป nโ‚ โ†’ coHom nโ‚ A) (+'-comm m n) (b โŒฃ a))) โ‰กโŸจ sym (-^-base n m (subst (ฮป k โ†’ coHom k A) (+'-comm m n) (b โŒฃ a))) โŸฉ (-^ n ยท m) (base (n +' m) (subst (ฮป k โ†’ coHom k A) (+'-comm m n) (b โŒฃ a))) โ‰กโŸจ cong (-^ n ยท m) (sym (constSubstCommSlice (ฮป k โ†’ coHom k A) H* base (+'-comm m n) (b โŒฃ a))) โŸฉ (-^ n ยท m) (base (m +' n) (b โŒฃ a)) โˆŽ ----------------------------------------------------------------------------- -- Equivalence of Type implies equivalence of Cohomology Ring module CohomologyRing-Equiv {X : Type โ„“} {Y : Type โ„“'} (e : Iso X Y) where open IsGroupHom open RingStr (snd (H*R X)) using () renaming ( 0r to 0H*X ; 1r to 1H*X ; _+_ to _+H*X_ ; -_ to -H*X_ ; _ยท_ to _cupX_ ; +Assoc to +H*XAssoc ; +Identity to +H*XIdentity ; +Lid to +H*XLid ; +Rid to +H*XRid ; +Inv to +H*XInv ; +Linv to +H*XLinv ; +Rinv to +H*XRinv ; +Comm to +H*XComm ; ยทAssoc to ยทH*XAssoc ; ยทIdentity to ยทH*XIdentity ; ยทLid to ยทH*XLid ; ยทRid to ยทH*XRid ; ยทRdist+ to ยทH*XRdist+ ; ยทLdist+ to ยทH*XLdist+ ; is-set to isSetH*X ) open RingStr (snd (H*R Y)) using () renaming ( 0r to 0H*Y ; 1r to 1H*Y ; _+_ to _+H*Y_ ; -_ to -H*Y_ ; _ยท_ to _cupY_ ; +Assoc to +H*YAssoc ; +Identity to +H*YIdentity ; +Lid to +H*YLid ; +Rid to +H*YRid ; +Inv to +H*YInv ; +Linv to +H*YLinv ; +Rinv to +H*YRinv ; +Comm to +H*YComm ; ยทAssoc to ยทH*YAssoc ; ยทIdentity to ยทH*YIdentity ; ยทLid to ยทH*YLid ; ยทRid to ยทH*YRid ; ยทRdist+ to ยทH*YRdist+ ; ยทLdist+ to ยทH*YLdist+ ; is-set to isSetH*Y ) coHomGr-Iso : {n : โ„•} โ†’ GroupIso (coHomGr n X) (coHomGr n Y) fst (coHomGr-Iso {n}) = is where is : Iso (coHom n X) (coHom n Y) fun is = ST.rec squashโ‚‚ (ฮป f โ†’ โˆฃ (ฮป y โ†’ f (inv e y)) โˆฃโ‚‚) inv is = ST.rec squashโ‚‚ (ฮป g โ†’ โˆฃ (ฮป x โ†’ g (fun e x)) โˆฃโ‚‚) rightInv is = ST.elim (ฮป _ โ†’ isPropโ†’isSet (squashโ‚‚ _ _)) (ฮป f โ†’ cong โˆฃ_โˆฃโ‚‚ (funExt (ฮป y โ†’ cong f (rightInv e y)))) leftInv is = ST.elim (ฮป _ โ†’ isPropโ†’isSet (squashโ‚‚ _ _)) (ฮป g โ†’ cong โˆฃ_โˆฃโ‚‚ (funExt (ฮป x โ†’ cong g (leftInv e x)))) snd (coHomGr-Iso {n}) = makeIsGroupHom (ST.elim (ฮป _ โ†’ isPropโ†’isSet ฮป u v i y โ†’ squashโ‚‚ _ _ (u y) (v y) i) (ฮป f โ†’ ST.elim (ฮป _ โ†’ isPropโ†’isSet (squashโ‚‚ _ _)) (ฮป f' โ†’ refl))) H*-Xโ†’H*-Y : H* X โ†’ H* Y H*-Xโ†’H*-Y = DS-Rec-Set.f _ _ _ _ isSetH*Y 0H*Y (ฮป n a โ†’ base n (fun (fst coHomGr-Iso) a)) _+H*Y_ +H*YAssoc +H*YRid +H*YComm (ฮป n โ†’ cong (base n) (pres1 (snd coHomGr-Iso)) โˆ™ base-neutral n) ฮป n a b โ†’ base-add _ _ _ โˆ™ cong (base n) (sym (presยท (snd coHomGr-Iso) a b)) H*-Yโ†’H*-X : H* Y โ†’ H* X H*-Yโ†’H*-X = DS-Rec-Set.f _ _ _ _ isSetH*X 0H*X (ฮป m a โ†’ base m (inv (fst coHomGr-Iso) a)) _+H*X_ +H*XAssoc +H*XRid +H*XComm (ฮป m โ†’ cong (base m) (pres1 (snd (invGroupIso coHomGr-Iso))) โˆ™ base-neutral m) ฮป m a b โ†’ base-add _ _ _ โˆ™ cong (base m) (sym (presยท (snd (invGroupIso coHomGr-Iso)) a b)) e-sect : (y : H* Y) โ†’ H*-Xโ†’H*-Y (H*-Yโ†’H*-X y) โ‰ก y e-sect = DS-Ind-Prop.f _ _ _ _ (ฮป _ โ†’ isSetH*Y _ _) refl (ฮป m a โ†’ cong (base m) (rightInv (fst coHomGr-Iso) a)) (ฮป {U V} ind-U ind-V โ†’ congโ‚‚ _+H*Y_ ind-U ind-V) e-retr : (x : H* X) โ†’ H*-Yโ†’H*-X (H*-Xโ†’H*-Y x) โ‰ก x e-retr = DS-Ind-Prop.f _ _ _ _ (ฮป _ โ†’ isSetH*X _ _) refl (ฮป n a โ†’ cong (base n) (leftInv (fst coHomGr-Iso) a)) (ฮป {U V} ind-U ind-V โ†’ congโ‚‚ _+H*X_ ind-U ind-V) H*-Xโ†’H*-Y-pres1 : H*-Xโ†’H*-Y 1H*X โ‰ก 1H*Y H*-Xโ†’H*-Y-pres1 = refl H*-Xโ†’H*-Y-pres+ : (x x' : H* X) โ†’ H*-Xโ†’H*-Y (x +H*X x') โ‰ก H*-Xโ†’H*-Y x +H*Y H*-Xโ†’H*-Y x' H*-Xโ†’H*-Y-pres+ x x' = refl H*-Xโ†’H*-Y-presยท : (x x' : H* X) โ†’ H*-Xโ†’H*-Y (x cupX x') โ‰ก H*-Xโ†’H*-Y x cupY H*-Xโ†’H*-Y x' H*-Xโ†’H*-Y-presยท = DS-Ind-Prop.f _ _ _ _ (ฮป x u v i y โ†’ isSetH*Y _ _ (u y) (v y) i) (ฮป _ โ†’ refl) (ฮป n โ†’ ST.elim (ฮป x โ†’ isPropโ†’isSet ฮป u v i y โ†’ isSetH*Y _ _ (u y) (v y) i) (ฮป f โ†’ DS-Ind-Prop.f _ _ _ _ (ฮป _ โ†’ isSetH*Y _ _) refl (ฮป m โ†’ ST.elim (ฮป _ โ†’ isPropโ†’isSet (isSetH*Y _ _)) (ฮป g โ†’ refl)) ฮป {U V} ind-U ind-V โ†’ congโ‚‚ _+H*Y_ ind-U ind-V) ) (ฮป {U V} ind-U ind-V y โ†’ congโ‚‚ _+H*Y_ (ind-U y) (ind-V y)) module _ {X : Type โ„“} {Y : Type โ„“'} (e : Iso X Y) where open CohomologyRing-Equiv e CohomologyRing-Equiv : RingEquiv (H*R X) (H*R Y) fst CohomologyRing-Equiv = isoToEquiv is where is : Iso (H* X) (H* Y) fun is = H*-Xโ†’H*-Y inv is = H*-Yโ†’H*-X rightInv is = e-sect leftInv is = e-retr snd CohomologyRing-Equiv = makeIsRingHom H*-Xโ†’H*-Y-pres1 H*-Xโ†’H*-Y-pres+ H*-Xโ†’H*-Y-presยท
{ "alphanum_fraction": 0.4543267236, "avg_line_length": 37.9025157233, "ext": "agda", "hexsha": "6970c1dd2f44d69c31104af472a8b8181f049e4a", "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": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "guilhermehas/cubical", "max_forks_repo_path": "Cubical/ZCohomology/RingStructure/CohomologyRing.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "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": "guilhermehas/cubical", "max_issues_repo_path": "Cubical/ZCohomology/RingStructure/CohomologyRing.agda", "max_line_length": 140, "max_stars_count": 1, "max_stars_repo_head_hexsha": "ce3120d3f8d692847b2744162bcd7a01f0b687eb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "guilhermehas/cubical", "max_stars_repo_path": "Cubical/ZCohomology/RingStructure/CohomologyRing.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": 4635, "size": 12053 }
module Setoid where module Logic where infix 4 _/\_ -- infix 2 _\/_ data True : Set where tt : True data False : Set where data _/\_ (P Q : Set) : Set where andI : P -> Q -> P /\ Q -- Not allowed if we have proof irrelevance -- data _\/_ (P Q : Set) : Set where -- orIL : P -> P \/ Q -- orIR : Q -> P \/ Q module Setoid where data Setoid : Set1 where setoid : (A : Set) -> (_==_ : A -> A -> Set) -> (refl : (x : A) -> x == x) -> (sym : (x y : A) -> x == y -> y == x) -> (trans : (x y z : A) -> x == y -> y == z -> x == z) -> Setoid El : Setoid -> Set El (setoid A _ _ _ _) = A module Projections where eq : (A : Setoid) -> El A -> El A -> Set eq (setoid _ e _ _ _) = e refl : (A : Setoid) -> {x : El A} -> eq A x x refl (setoid _ _ r _ _) = r _ sym : (A : Setoid) -> {x y : El A} -> (h : eq A x y) -> eq A y x sym (setoid _ _ _ s _) = s _ _ trans : (A : Setoid) -> {x y z : El A} -> eq A x y -> eq A y z -> eq A x z trans (setoid _ _ _ _ t) = t _ _ _ module Equality (A : Setoid) where infix 6 _==_ _==_ : El A -> El A -> Set _==_ = Projections.eq A refl : {x : El A} -> x == x refl = Projections.refl A sym : {x y : El A} -> x == y -> y == x sym = Projections.sym A trans : {x y z : El A} -> x == y -> y == z -> x == z trans = Projections.trans A module EqChain (A : Setoid.Setoid) where infixl 5 _===_ _=-=_ infix 8 _since_ open Setoid private open module EqA = Equality A eqProof>_ : (x : El A) -> x == x eqProof> x = refl _=-=_ : (x : El A) -> {y : El A} -> x == y -> x == y x =-= eq = eq _===_ : {x y z : El A} -> x == y -> y == z -> x == z _===_ = trans _since_ : {x : El A} -> (y : El A) -> x == y -> x == y _ since eq = eq module Fun where open Logic open Setoid infixr 10 _=>_ _==>_ open Setoid.Projections using (eq) data _=>_ (A B : Setoid) : Set where lam : (f : El A -> El B) -> ({x y : El A} -> eq A x y -> eq B (f x) (f y) ) -> A => B app : {A B : Setoid} -> (A => B) -> El A -> El B app (lam f _) = f cong : {A B : Setoid} -> (f : A => B) -> {x y : El A} -> eq A x y -> eq B (app f x) (app f y) cong (lam _ resp) = resp data EqFun {A B : Setoid}(f g : A => B) : Set where eqFunI : ({x y : El A} -> eq A x y -> eq B (app f x) (app g y)) -> EqFun f g eqFunE : {A B : Setoid} -> {f g : A => B} -> {x y : El A} -> EqFun f g -> eq A x y -> eq B (app f x) (app g y) eqFunE (eqFunI h) = h _==>_ : Setoid -> Setoid -> Setoid A ==> B = setoid (A => B) EqFun r s t where module Proof where open module EqChainB = EqChain B module EqA = Equality A open module EqB = Equality B -- either abstract or --proof-irrelevance needed -- (we don't want to compare the proofs for equality) -- abstract r : (f : A => B) -> EqFun f f r f = eqFunI (\xy -> cong f xy) s : (f g : A => B) -> EqFun f g -> EqFun g f s f g fg = eqFunI (\{x}{y} xy -> app g x =-= app g y since cong g xy === app f x since sym (eqFunE fg xy) === app f y since cong f xy ) t : (f g h : A => B) -> EqFun f g -> EqFun g h -> EqFun f h t f g h fg gh = eqFunI (\{x}{y} xy -> app f x =-= app g y since eqFunE fg xy === app g x since cong g (EqA.sym xy) === app h y since eqFunE gh xy ) open Proof infixl 100 _$_ _$_ : {A B : Setoid} -> El (A ==> B) -> El A -> El B _$_ = app lam2 : {A B C : Setoid} -> (f : El A -> El B -> El C) -> ({x x' : El A} -> eq A x x' -> {y y' : El B} -> eq B y y' -> eq C (f x y) (f x' y') ) -> El (A ==> B ==> C) lam2 {A} f h = lam (\x -> lam (\y -> f x y) (\y -> h EqA.refl y)) (\x -> eqFunI (\y -> h x y)) where module EqA = Equality A lam3 : {A B C D : Setoid} -> (f : El A -> El B -> El C -> El D) -> ({x x' : El A} -> eq A x x' -> {y y' : El B} -> eq B y y' -> {z z' : El C} -> eq C z z' -> eq D (f x y z) (f x' y' z') ) -> El (A ==> B ==> C ==> D) lam3 {A} f h = lam (\x -> lam2 (\y z -> f x y z) (\y z -> h EqA.refl y z)) (\x -> eqFunI (\y -> eqFunI (\z -> h x y z))) where module EqA = Equality A eta : {A B : Setoid} -> (f : El (A ==> B)) -> eq (A ==> B) f (lam (\x -> f $ x) (\xy -> cong f xy)) eta f = eqFunI (\xy -> cong f xy) id : {A : Setoid} -> El (A ==> A) id = lam (\x -> x) (\x -> x) {- Now it looks okay. But it's incredibly slow! Proof irrelevance makes it go fast again... The problem is equality checking of (function type) setoids which without proof irrelevance checks equality of the proof that EqFun is an equivalence relation. It's not clear why using lam3 involves so many more equality checks than using lam. Making the proofs abstract makes the problem go away. -} compose : {A B C : Setoid} -> El ((B ==> C) ==> (A ==> B) ==> (A ==> C)) compose = lam3 (\f g x -> f $ (g $ x)) (\f g x -> eqFunE f (eqFunE g x)) _โˆ˜_ : {A B C : Setoid} -> El (B ==> C) -> El (A ==> B) -> El (A ==> C) f โˆ˜ g = compose $ f $ g const : {A B : Setoid} -> El (A ==> B ==> A) const = lam2 (\x y -> x) (\x y -> x) module Nat where open Logic open Setoid open Fun infixl 10 _+_ data Nat : Set where zero : Nat suc : Nat -> Nat module NatSetoid where eqNat : Nat -> Nat -> Set eqNat zero zero = True eqNat zero (suc _) = False eqNat (suc _) zero = False eqNat (suc n) (suc m) = eqNat n m data EqNat (n m : Nat) : Set where eqnat : eqNat n m -> EqNat n m uneqnat : {n m : Nat} -> EqNat n m -> eqNat n m uneqnat (eqnat x) = x r : (x : Nat) -> eqNat x x r zero = tt r (suc n) = r n -- reflexivity of EqNat rf : (n : Nat) -> EqNat n n rf = \ x -> eqnat (r x) s : (x y : Nat) -> eqNat x y -> eqNat y x s zero zero _ = tt s (suc n) (suc m) h = s n m h s zero (suc _) () s (suc _) zero () -- symmetry of EqNat sy : (x y : Nat) -> EqNat x y -> EqNat y x sy = \x y h -> eqnat (s x y (uneqnat h)) t : (x y z : Nat) -> eqNat x y -> eqNat y z -> eqNat x z t zero zero z xy yz = yz t (suc x) (suc y) (suc z) xy yz = t x y z xy yz t zero (suc _) _ () _ t (suc _) zero _ () _ t (suc _) (suc _) zero _ () -- transitivity of EqNat tr : (x y z : Nat) -> EqNat x y -> EqNat y z -> EqNat x z tr = \x y z xy yz -> eqnat (t x y z (uneqnat xy) (uneqnat yz)) NAT : Setoid NAT = setoid Nat NatSetoid.EqNat NatSetoid.rf NatSetoid.sy NatSetoid.tr _+_ : Nat -> Nat -> Nat zero + m = m suc n + m = suc (n + m) plus : El (NAT ==> NAT ==> NAT) plus = lam2 (\n m -> n + m) eqPlus where module EqNat = Equality NAT open EqNat open NatSetoid eqPlus : {n n' : Nat} -> n == n' -> {m m' : Nat} -> m == m' -> n + m == n' + m' eqPlus {zero} {zero} _ mm = mm eqPlus {suc n} {suc n'} (eqnat nn) {m}{m'} (eqnat mm) = eqnat (uneqnat (eqPlus{n}{n'} (eqnat nn) {m}{m'} (eqnat mm) ) ) eqPlus {zero} {suc _} (eqnat ()) _ eqPlus {suc _} {zero} (eqnat ()) _ module List where open Logic open Setoid data List (A : Set) : Set where nil : List A _::_ : A -> List A -> List A LIST : Setoid -> Setoid LIST A = setoid (List (El A)) eqList r s t where module EqA = Equality A open EqA eqList : List (El A) -> List (El A) -> Set eqList nil nil = True eqList nil (_ :: _) = False eqList (_ :: _) nil = False eqList (x :: xs) (y :: ys) = x == y /\ eqList xs ys r : (x : List (El A)) -> eqList x x r nil = tt r (x :: xs) = andI refl (r xs) s : (x y : List (El A)) -> eqList x y -> eqList y x s nil nil h = h s (x :: xs) (y :: ys) (andI xy xys) = andI (sym xy) (s xs ys xys) s nil (_ :: _) () s (_ :: _) nil () t : (x y z : List (El A)) -> eqList x y -> eqList y z -> eqList x z t nil nil zs _ h = h t (x :: xs) (y :: ys) (z :: zs) (andI xy xys) (andI yz yzs) = andI (trans xy yz) (t xs ys zs xys yzs) t nil (_ :: _) _ () _ t (_ :: _) nil _ () _ t (_ :: _) (_ :: _) nil _ () open Fun
{ "alphanum_fraction": 0.4386713051, "avg_line_length": 28.0220125786, "ext": "agda", "hexsha": "3ad5d991e4a3a09a9656aff3de2fed46e8fead5f", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/Setoid.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/Setoid.agda", "max_line_length": 85, "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/Setoid.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": 3259, "size": 8911 }
{-# OPTIONS --rewriting --confluence-check -v rewriting:80 #-} open import Agda.Builtin.Equality postulate decorate : โˆ€{a} (A : Set a) โ†’ Set a rewriteMe : โˆ€{a b} {A : Set a} {B : A โ†’ Set b} โ†’ decorate ((x : A) โ†’ B x) โ‰ก (decorate A โ†’ โˆ€ x โ†’ decorate (B x)) {-# BUILTIN REWRITE _โ‰ก_ #-} {-# REWRITE rewriteMe #-} postulate A : Set test : decorate (A โ†’ A) โ‰ก (decorate A โ†’ โˆ€ (x : A) โ†’ decorate A) test = refl
{ "alphanum_fraction": 0.5491990847, "avg_line_length": 25.7058823529, "ext": "agda", "hexsha": "18a849a3c6fcd14c13e5f8300684d6e2e783a1eb", "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/Issue3971.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/Issue3971.agda", "max_line_length": 80, "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/Issue3971.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": 437 }
module interactiveProgramsAgda where open import NativeIO open import Function open import Size open import Data.Maybe.Base record IOInterface : Setโ‚ where field Command : Set Response : (c : Command) โ†’ Set open IOInterface public mutual record IO (I : IOInterface) (i : Size) (A : Set) : Set where coinductive constructor delay field force : {j : Size< i} โ†’ IO' I j A data IO' (I : IOInterface) (i : Size) (A : Set) : Set where do' : (c : Command I) (f : Response I c โ†’ IO I i A) โ†’ IO' I i A return' : (a : A) โ†’ IO' I i A open IO public module _ {I : IOInterface} (let C = Command I) (let R = Response I) where do : โˆ€{i A} (c : C) (f : R c โ†’ IO I i A) โ†’ IO I i A force (do c f) = do' c f return : โˆ€{i A} (a : A) โ†’ IO I i A force (return a) = return' a infixl 2 _>>=_ _>>=_ : โˆ€{i A B} (m : IO I i A) (k : A โ†’ IO I i B) โ†’ IO I i B force (m >>= k) with force m ... | do' c f = do' c ฮป x โ†’ f x >>= k ... | return' a = force (k a) {-# NON_TERMINATING #-} translateIO : โˆ€ {A} (tr : (c : C) โ†’ NativeIO (R c)) โ†’ IO I โˆž A โ†’ NativeIO A translateIO tr m = case (force m) of ฮป { (do' c f) โ†’ (tr c) native>>= ฮป r โ†’ translateIO tr (f r) ; (return' a) โ†’ nativeReturn a } {- Specific case of Console IO -} data ConsoleCommand : Set where getLine : ConsoleCommand putStrLn : String โ†’ ConsoleCommand ConsoleResponse : ConsoleCommand โ†’ Set ConsoleResponse getLine = String ConsoleResponse (putStrLn s) = Unit ConsoleInterface : IOInterface Command ConsoleInterface = ConsoleCommand Response ConsoleInterface = ConsoleResponse IOConsole : (i : Size) โ†’ Set โ†’ Set IOConsole i = IO ConsoleInterface i translateIOConsoleLocal : (c : ConsoleCommand) โ†’ NativeIO (ConsoleResponse c) translateIOConsoleLocal (putStrLn s) = nativePutStrLn s translateIOConsoleLocal getLine = nativeGetLine translateIOConsole : {A : Set} โ†’ IOConsole โˆž A โ†’ NativeIO A translateIOConsole = translateIO translateIOConsoleLocal cat : โˆ€ {i} โ†’ IOConsole i Unit force cat = do' getLine ฮป line โ†’ do (putStrLn line) ฮป _ โ†’ cat main : NativeIO Unit main = translateIOConsole cat
{ "alphanum_fraction": 0.6132917038, "avg_line_length": 27.0120481928, "ext": "agda", "hexsha": "88da970a531e4e19e0d76496dad8935c06ef960a", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z", "max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z", "max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/ooAgda", "max_forks_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interactiveProgramsAgda.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/ooAgda", "max_issues_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interactiveProgramsAgda.agda", "max_line_length": 77, "max_stars_count": 23, "max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/ooAgda", "max_stars_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/interactiveProgramsAgda.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z", "max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z", "num_tokens": 715, "size": 2242 }
module _ where open import Common.Prelude hiding (_>>=_) open import Common.Reflection open import Common.Equality open import Imports.StaleMetaLiteral macro unquoteMeta : Meta โ†’ Tactic unquoteMeta m = give (meta m []) thm : unquoteMeta staleMeta โ‰ก 42 thm = refl
{ "alphanum_fraction": 0.7536764706, "avg_line_length": 17, "ext": "agda", "hexsha": "b9500a3f9c3f3f561a4fa7ffbc35a9e8d769b316", "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/StaleMetaLiteral.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/StaleMetaLiteral.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/StaleMetaLiteral.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": 75, "size": 272 }
{-# OPTIONS --cubical #-} module Data.Option.Equiv.Path where import Lvl open import Data open import Data.Option open import Data.Option.Functions open import Data.Option.Equiv open import Functional open import Structure.Function.Domain open import Structure.Operator open import Structure.Relator open import Type.Cubical.Path.Equality open import Type private variable โ„“ : Lvl.Level private variable T : Type{โ„“} instance Some-injectivity : Injective {B = Option(T)} (Some) Injective.proof Some-injectivity {x}{y} = congruenceโ‚‚โ‚—(_or_)(x) instance Path-Option-extensionality : Extensionality{A = T} (Path-equiv) Extensionality.cases-inequality (Path-Option-extensionality {T = T}) {x} p with () โ† substituteโ‚(elim{A = T}{B = ฮป _ โ†’ Type}(Option(T)) (const Empty)) p (Some x)
{ "alphanum_fraction": 0.7506297229, "avg_line_length": 29.4074074074, "ext": "agda", "hexsha": "3458c0585a47c2c48bc58f38b69c35186881410a", "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/Equiv/Path.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/Equiv/Path.agda", "max_line_length": 163, "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/Equiv/Path.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": 216, "size": 794 }
module Cats.Category.Cat.Facts.Terminal where open import Cats.Category open import Cats.Category.Cat using (Cat) open import Cats.Category.One using (One) instance hasTerminal : โˆ€ lo la lโ‰ˆ โ†’ HasTerminal (Cat lo la lโ‰ˆ) hasTerminal lo la lโ‰ˆ = record { One = One lo la lโ‰ˆ ; isTerminal = _ }
{ "alphanum_fraction": 0.6815286624, "avg_line_length": 22.4285714286, "ext": "agda", "hexsha": "758d4bb2c32934e5b7a6c7d1a95f5cad6c1e4bb1", "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": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "alessio-b-zak/cats", "max_forks_repo_path": "Cats/Category/Cat/Facts/Terminal.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "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": "alessio-b-zak/cats", "max_issues_repo_path": "Cats/Category/Cat/Facts/Terminal.agda", "max_line_length": 55, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "alessio-b-zak/cats", "max_stars_repo_path": "Cats/Category/Cat/Facts/Terminal.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 88, "size": 314 }
{-# OPTIONS --safe #-} module Cubical.Homotopy.WedgeConnectivity where open import Cubical.Foundations.Everything open import Cubical.Data.Nat open import Cubical.Data.Sigma open import Cubical.HITs.Susp open import Cubical.HITs.Truncation as Trunc open import Cubical.Homotopy.Connected module WedgeConnectivity {โ„“ โ„“' โ„“''} (n m : โ„•) (A : Pointed โ„“) (connA : isConnected (suc n) (typ A)) (B : Pointed โ„“') (connB : isConnected (suc m) (typ B)) (P : typ A โ†’ typ B โ†’ TypeOfHLevel โ„“'' (n + m)) (f : (a : typ A) โ†’ P a (pt B) .fst) (g : (b : typ B) โ†’ P (pt A) b .fst) (p : f (pt A) โ‰ก g (pt B)) where private Q : typ A โ†’ TypeOfHLevel _ n Q a = ( (ฮฃ[ k โˆˆ ((b : typ B) โ†’ P a b .fst) ] k (pt B) โ‰ก f a) , isOfHLevelRetract n (ฮป {(h , q) โ†’ h , funExt ฮป _ โ†’ q}) (ฮป {(h , q) โ†’ h , funExtโป q _}) (ฮป _ โ†’ refl) (isOfHLevelPrecomposeConnected n m (P a) (ฮป _ โ†’ pt B) (isConnectedPoint m connB (pt B)) (ฮป _ โ†’ f a)) ) main : isContr (fiber (ฮป s _ โ†’ s (pt A)) (ฮป _ โ†’ g , p โปยน)) main = elim.isEquivPrecompose (ฮป _ โ†’ pt A) n Q (isConnectedPoint n connA (pt A)) .equiv-proof (ฮป _ โ†’ g , p โปยน) extension : โˆ€ a b โ†’ P a b .fst extension a b = main .fst .fst a .fst b left : โˆ€ a โ†’ extension a (pt B) โ‰ก f a left a = main .fst .fst a .snd right : โˆ€ b โ†’ extension (pt A) b โ‰ก g b right = funExtโป (cong fst (funExtโป (main .fst .snd) _)) hom : left (pt A) โปยน โˆ™ right (pt B) โ‰ก p hom i j = hcomp (ฮป k โ†’ ฮป { (i = i1) โ†’ p j ; (j = i0) โ†’ (cong snd (funExtโป (main .fst .snd) tt)) i (~ j) ; (j = i1) โ†’ right (pt B) (i โˆจ k)}) (cong snd (funExtโป (main .fst .snd) tt) i (~ j)) hom' : left (pt A) โ‰ก right (pt B) โˆ™ sym p hom' = (lUnit (left _) โˆ™ cong (_โˆ™ left (pt A)) (sym (rCancel (right (pt B))))) โˆ™โˆ™ sym (assoc _ _ _) โˆ™โˆ™ cong (right (pt B) โˆ™_) (sym (symDistr (left (pt A) โปยน) (right (pt B))) โˆ™ (cong sym hom)) homSquare : PathP (ฮป i โ†’ extension (pt A) (pt B) โ‰ก p i) (left (pt A)) (right (pt B)) homSquare i j = hcomp (ฮป k โ†’ ฮป { (i = i0) โ†’ left (pt A) j ; (i = i1) โ†’ compPath-filler (right (pt B)) (sym p) (~ k) j ; (j = i0) โ†’ extension (pt A) (pt B) ; (j = i1) โ†’ p (i โˆง k) }) (hom' i j)
{ "alphanum_fraction": 0.4867219917, "avg_line_length": 37.0769230769, "ext": "agda", "hexsha": "27f1795c8dc75136c8037ef7aa9c2567dc2eb77a", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/Homotopy/WedgeConnectivity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/Homotopy/WedgeConnectivity.agda", "max_line_length": 98, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/Homotopy/WedgeConnectivity.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 914, "size": 2410 }
module #13 where {- Using propositions-as-types, derive the double negation of the principle of excluded middle, i.e. prove not (not (P or not P)). -} open import Data.Sum open import Relation.Nullary excluded-middle : (P : Set) โ†’ ยฌ (ยฌ (P โŠŽ (ยฌ P))) excluded-middle P z = z (injโ‚‚ (ฮป x โ†’ z (injโ‚ x)))
{ "alphanum_fraction": 0.6568627451, "avg_line_length": 23.5384615385, "ext": "agda", "hexsha": "0dee53a0240d0e12611ed56c29e8f11cac048c0b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CodaFi/HoTT-Exercises", "max_forks_repo_path": "Chapter1/#13.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CodaFi/HoTT-Exercises", "max_issues_repo_path": "Chapter1/#13.agda", "max_line_length": 86, "max_stars_count": null, "max_stars_repo_head_hexsha": "3411b253b0a49a5f9c3301df175ae8ecdc563b12", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CodaFi/HoTT-Exercises", "max_stars_repo_path": "Chapter1/#13.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 96, "size": 306 }
-- Andreas, 2015-06-24 Parsing of forall should be like lambda open import Common.Prelude open import Common.Product test : โŠค ร— โˆ€ (B : Set) โ†’ B โ†’ B -- should parse test = _ , ฮป B b โ†’ b test1 : โŠค ร— forall (B : Set) โ†’ B โ†’ B -- should parse test1 = _ , ฮป B b โ†’ b
{ "alphanum_fraction": 0.6113207547, "avg_line_length": 24.0909090909, "ext": "agda", "hexsha": "23d8a8720d406ff818bb447af12c038d8e44fcf6", "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/Issue1583.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/Issue1583.agda", "max_line_length": 62, "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/Issue1583.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": 91, "size": 265 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cohomology.Theory open import cw.CW module cw.cohomology.ZerothCohomologyGroupOnDiag {i} (OT : OrdinaryTheory i) (โŠ™skel : โŠ™Skeleton {i} 0) (ac : โŠ™has-cells-with-choice 0 โŠ™skel i) where open OrdinaryTheory OT open import cw.cohomology.TipAndAugment OT โŠ™skel open import groups.KernelSndImageInl (C2 0) {H = CXโ‚€ 0} {K = Lift-group {j = i} Unit-group} cst-hom cst-hom (ฮป _ โ†’ idp) (C2ร—CXโ‚€-is-abelian 0) open import groups.KernelImage (cst-hom {G = C2ร—CXโ‚€ 0} {H = Lift-group {j = i} Unit-group}) cw-coฮต (C2ร—CXโ‚€-is-abelian 0) C-cw-iso-ker/im : C 0 โŠ™โŸฆ โŠ™skel โŸง โ‰ƒแดณ Ker/Im C-cw-iso-ker/im = Ker-ฯ†-snd-quot-Im-inl โˆ˜eแดณ full-subgroup (ker-cst-hom-is-full (CXโ‚€ 0) (Lift-group {j = i} Unit-group)) โปยนแดณ
{ "alphanum_fraction": 0.6730523627, "avg_line_length": 29, "ext": "agda", "hexsha": "83a599c7937a957b71d5868453ae5e0b89eb464d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/cw/cohomology/ZerothCohomologyGroupOnDiag.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/cw/cohomology/ZerothCohomologyGroupOnDiag.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/cw/cohomology/ZerothCohomologyGroupOnDiag.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 330, "size": 783 }
module Data.Nat.Properties.Extra where open import Data.Nat.Base open import Data.Nat.Properties open import Relation.Binary.PropositionalEquality open โ‰ก-Reasoning open import Data.Empty โ‰คโ€ฒ-unique : โˆ€ {i u} (p q : i โ‰คโ€ฒ u) โ†’ p โ‰ก q โ‰คโ€ฒ-unique โ‰คโ€ฒ-refl โ‰คโ€ฒ-refl = refl โ‰คโ€ฒ-unique โ‰คโ€ฒ-refl (โ‰คโ€ฒ-step q) = โŠฅ-elim (1+nโ‰ฐn (โ‰คโ€ฒโ‡’โ‰ค q)) โ‰คโ€ฒ-unique (โ‰คโ€ฒ-step p) โ‰คโ€ฒ-refl = โŠฅ-elim (1+nโ‰ฐn (โ‰คโ€ฒโ‡’โ‰ค p)) โ‰คโ€ฒ-unique (โ‰คโ€ฒ-step p) (โ‰คโ€ฒ-step q) = cong โ‰คโ€ฒ-step (โ‰คโ€ฒ-unique p q) m+n+oโ‰กn+m+o : โˆ€ m n o โ†’ m + (n + o) โ‰ก n + (m + o) m+n+oโ‰กn+m+o m n o = begin m + (n + o) โ‰กโŸจ sym (+-assoc m n o) โŸฉ (m + n) + o โ‰กโŸจ cong (ฮป x โ†’ x + o) (+-comm m n) โŸฉ (n + m) + o โ‰กโŸจ +-assoc n m o โŸฉ n + (m + o) โˆŽ
{ "alphanum_fraction": 0.5189681335, "avg_line_length": 29.9545454545, "ext": "agda", "hexsha": "13d4ea10fa73950daf74c6d6b6f90c047594ca8e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/Data/Nat/Properties/Extra.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/Data/Nat/Properties/Extra.agda", "max_line_length": 64, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/Data/Nat/Properties/Extra.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 337, "size": 659 }
module Data.List.First {โ„“}{A : Set โ„“} where open import Data.Product open import Data.List open import Relation.Nullary open import Relation.Binary.PropositionalEquality open import Level open import Function open import Data.Empty -- proof that an element is the first in a vector to satisfy the predicate B data First {b}(B : A โ†’ Set b) : (x : A) โ†’ List A โ†’ Set (โ„“ โŠ” 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 : โˆ€ {B : A โ†’ Set} {x l} โ†’ First B x l โ†’ B x firstโŸถwitness (here p) = p firstโŸถwitness (there x ยฌpx f) = firstโŸถwitness f -- more likable syntax for the above structure first_โˆˆ_โ‡’_ : โˆ€ {p} โ†’ A โ†’ List A โ†’ (B : A โ†’ Set p) โ†’ Set (p โŠ” โ„“) first_โˆˆ_โ‡’_ x v p = First p x v -- a decision procedure to find the first element in a vector that satisfies a predicate find : โˆ€ (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) 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) = ยฌpx p helper ยฌpx ยฌfirstv (u , there ._ _ firstv) = ยฌfirstv (u , firstv)
{ "alphanum_fraction": 0.5824246312, "avg_line_length": 39.9743589744, "ext": "agda", "hexsha": "b350a774d08b9f919ccd6fc0e341ca5dafcbaf72", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/Data/List/First.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/Data/List/First.agda", "max_line_length": 88, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/Data/List/First.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 586, "size": 1559 }
------------------------------------------------------------------------ -- Example: Left recursive expression grammar ------------------------------------------------------------------------ module TotalRecognisers.LeftRecursion.Expression where open import Codata.Musical.Notation open import Data.Bool hiding (_โˆง_; _โ‰ค_; _โ‰ค?_) open import Data.Char as Char using (Char) open import Data.Nat using (โ„•; _โ‰ค?_) open import Data.String as String using (String) open import Relation.Binary.PropositionalEquality open import Relation.Nullary.Decidable import TotalRecognisers.LeftRecursion as P import TotalRecognisers.LeftRecursion.Lib as Lib open P Char open Lib Char open KleeneStarโ‚ open Tok Char._โ‰Ÿ_ ------------------------------------------------------------------------ -- Recognisers for digits and numbers -- Digits. digit : P _ digit = sat in-range where in-range : Char โ†’ Bool in-range t = โŒŠ Char.toโ„• '0' โ‰ค? Char.toโ„• t โŒ‹ โˆง โŒŠ Char.toโ„• t โ‰ค? Char.toโ„• '9' โŒ‹ -- Numbers. number : P _ number = digit + ------------------------------------------------------------------------ -- An expression grammar -- t โˆท= t '+' f โˆฃ f -- f โˆท= f '*' a โˆฃ a -- a โˆท= '(' t ')' โˆฃ n mutual term = โ™ฏ (โ™ฏ term ยท โ™ฏ tok '+') ยท โ™ฏ factor โˆฃ factor factor = โ™ฏ (โ™ฏ factor ยท โ™ฏ tok '*') ยท โ™ฏ atom โˆฃ atom atom = โ™ฏ (โ™ฏ tok '(' ยท โ™ฏ term) ยท โ™ฏ tok ')' โˆฃ number ------------------------------------------------------------------------ -- Unit tests module Tests where test : โˆ€ {n} โ†’ P n โ†’ String โ†’ Bool test p s = โŒŠ String.toList s โˆˆ? p โŒ‹ exโ‚ : test term "1*(2+3)" โ‰ก true exโ‚ = refl exโ‚‚ : test term "1*(2+3" โ‰ก false exโ‚‚ = refl
{ "alphanum_fraction": 0.4833333333, "avg_line_length": 23.661971831, "ext": "agda", "hexsha": "9195bb533273f4632409cd13deb96b26f04d0be6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "TotalRecognisers/LeftRecursion/Expression.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "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/parser-combinators", "max_issues_repo_path": "TotalRecognisers/LeftRecursion/Expression.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "TotalRecognisers/LeftRecursion/Expression.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 456, "size": 1680 }
{-# OPTIONS --without-K --safe #-} module Math.NumberTheory.Summation.Generic.Properties.Lemma where -- agda-stdlib open import Data.Nat open import Data.Nat.Properties open import Data.Nat.Solver open import Relation.Binary.PropositionalEquality open import Function.Base lemmaโ‚ : โˆ€ m n โ†’ 2 + m + n โ‰ก suc m + suc n lemmaโ‚ = solve 2 (ฮป m n โ†’ con 2 :+ m :+ n := con 1 :+ m :+ (con 1 :+ n)) refl where open +-*-Solver
{ "alphanum_fraction": 0.6888361045, "avg_line_length": 28.0666666667, "ext": "agda", "hexsha": "59dc43967ecd8dcf237b5d3c5cdf44730003683e", "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": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Math/NumberTheory/Summation/Generic/Properties/Lemma.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "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": "rei1024/agda-misc", "max_issues_repo_path": "Math/NumberTheory/Summation/Generic/Properties/Lemma.agda", "max_line_length": 77, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Math/NumberTheory/Summation/Generic/Properties/Lemma.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 129, "size": 421 }
{-# OPTIONS --cubical --safe #-} module Cubical.Foundations.Logic where import Cubical.Data.Empty as โŠฅ open import Cubical.Data.Prod as ร— using (_ร—_; _,_; projโ‚; projโ‚‚) open import Cubical.Data.Sum as โŠŽ using (_โŠŽ_) open import Cubical.Data.Unit open import Cubical.Foundations.Prelude open import Cubical.HITs.PropositionalTruncation as PropTrunc open import Cubical.Foundations.HLevels using (hProp; ฮฃPropโ‰ก; isPropPi) public open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Function open import Cubical.Relation.Nullary hiding (ยฌ_) infix 10 ยฌ_ infixr 8 _โŠ”_ infixr 8 _โŠ”โ€ฒ_ infixr 8 _โŠ“_ infixr 8 _โŠ“โ€ฒ_ infixr 6 _โ‡’_ infixr 4 _โ‡”_ infix 30 _โ‰กโ‚š_ infix 30 _โ‰ขโ‚š_ infix 2 โˆƒ[]-syntax infix 2 โˆƒ[โˆถ]-syntax infix 2 โˆ€[โˆถ]-syntax infix 2 โˆ€[]-syntax infix 2 โ‡’โˆถ_โ‡โˆถ_ infix 2 โ‡โˆถ_โ‡’โˆถ_ -------------------------------------------------------------------------------- -- The type hProp of mere propositions -- the definition hProp is given in Foundations.HLevels -- hProp โ„“ = ฮฃ (Type โ„“) isProp private variable โ„“ โ„“' โ„“'' : Level P Q R : hProp โ„“ A B C : Type โ„“ [_] : hProp โ„“ โ†’ Type โ„“ [_] = fst โˆฅ_โˆฅโ‚š : Type โ„“ โ†’ hProp โ„“ โˆฅ A โˆฅโ‚š = โˆฅ A โˆฅ , propTruncIsProp _โ‰กโ‚š_ : (x y : A) โ†’ hProp _ x โ‰กโ‚š y = โˆฅ x โ‰ก y โˆฅโ‚š hPropโ‰ก : [ P ] โ‰ก [ Q ] โ†’ P โ‰ก Q hPropโ‰ก p = ฮฃPropโ‰ก (\ _ โ†’ isPropIsProp) p -------------------------------------------------------------------------------- -- Logical implication of mere propositions _โ‡’_ : (A : hProp โ„“) โ†’ (B : hProp โ„“') โ†’ hProp _ A โ‡’ B = ([ A ] โ†’ [ B ]) , isPropPi ฮป _ โ†’ B .snd โ‡”toPath : [ P โ‡’ Q ] โ†’ [ Q โ‡’ P ] โ†’ P โ‰ก Q โ‡”toPath {P = P} {Q = Q} Pโ‡’Q Qโ‡’P = hPropโ‰ก (isoToPath (iso Pโ‡’Q Qโ‡’P (ฮป b โ†’ Q .snd (Pโ‡’Q (Qโ‡’P b)) b) ฮป a โ†’ P .snd (Qโ‡’P (Pโ‡’Q a)) a)) pathToโ‡’ : P โ‰ก Q โ†’ [ P โ‡’ Q ] pathToโ‡’ p x = subst fst p x pathToโ‡ : P โ‰ก Q โ†’ [ Q โ‡’ P ] pathToโ‡ p x = subst fst (sym p) x substโ‚š : {x y : A} (B : A โ†’ hProp โ„“) โ†’ [ x โ‰กโ‚š y โ‡’ B x โ‡’ B y ] substโ‚š {x = x} {y = y} B = PropTrunc.elim (ฮป _ โ†’ isPropPi ฮป _ โ†’ B y .snd) (subst (fst โˆ˜ B)) -------------------------------------------------------------------------------- -- Mixfix notations for โ‡”-toPath -- see โŠ”-identityหก and โŠ”-identityสณ for the difference โ‡’โˆถ_โ‡โˆถ_ : [ P โ‡’ Q ] โ†’ [ Q โ‡’ P ] โ†’ P โ‰ก Q โ‡’โˆถ_โ‡โˆถ_ = โ‡”toPath โ‡โˆถ_โ‡’โˆถ_ : [ Q โ‡’ P ] โ†’ [ P โ‡’ Q ] โ†’ P โ‰ก Q โ‡โˆถ g โ‡’โˆถ f = โ‡”toPath f g -------------------------------------------------------------------------------- -- False and True โŠฅ : hProp _ โŠฅ = โŠฅ.โŠฅ , ฮป () โŠค : hProp _ โŠค = Unit , (ฮป _ _ _ โ†’ tt) -------------------------------------------------------------------------------- -- Pseudo-complement of mere propositions ยฌ_ : hProp โ„“ โ†’ hProp _ ยฌ A = ([ A ] โ†’ โŠฅ.โŠฅ) , isPropPi ฮป _ โ†’ โŠฅ.isPropโŠฅ _โ‰ขโ‚š_ : (x y : A) โ†’ hProp _ x โ‰ขโ‚š y = ยฌ x โ‰กโ‚š y -------------------------------------------------------------------------------- -- Disjunction of mere propositions _โŠ”โ€ฒ_ : Type โ„“ โ†’ Type โ„“' โ†’ Type _ A โŠ”โ€ฒ B = โˆฅ A โŠŽ B โˆฅ _โŠ”_ : hProp โ„“ โ†’ hProp โ„“' โ†’ hProp _ P โŠ” Q = โˆฅ [ P ] โŠŽ [ Q ] โˆฅโ‚š inl : A โ†’ A โŠ”โ€ฒ B inl x = โˆฃ โŠŽ.inl x โˆฃ inr : B โ†’ A โŠ”โ€ฒ B inr x = โˆฃ โŠŽ.inr x โˆฃ โŠ”-elim : (P : hProp โ„“) (Q : hProp โ„“') (R : [ P โŠ” Q ] โ†’ hProp โ„“'') โ†’ (โˆ€ x โ†’ [ R (inl x) ]) โ†’ (โˆ€ y โ†’ [ R (inr y) ]) โ†’ (โˆ€ z โ†’ [ R z ]) โŠ”-elim _ _ R Pโ‡’R Qโ‡’R = PropTrunc.elim (snd โˆ˜ R) (โŠŽ.elim Pโ‡’R Qโ‡’R) -------------------------------------------------------------------------------- -- Conjunction of mere propositions _โŠ“โ€ฒ_ : Type โ„“ โ†’ Type โ„“' โ†’ Type _ A โŠ“โ€ฒ B = A ร— B _โŠ“_ : hProp โ„“ โ†’ hProp โ„“' โ†’ hProp _ A โŠ“ B = [ A ] โŠ“โ€ฒ [ B ] , ร—.isOfHLevelProd 1 (A .snd) (B .snd) โŠ“-intro : (P : hProp โ„“) (Q : [ P ] โ†’ hProp โ„“') (R : [ P ] โ†’ hProp โ„“'') โ†’ (โˆ€ a โ†’ [ Q a ]) โ†’ (โˆ€ a โ†’ [ R a ]) โ†’ (โˆ€ (a : [ P ]) โ†’ [ Q a โŠ“ R a ] ) โŠ“-intro _ _ _ = ร—.intro -------------------------------------------------------------------------------- -- Logical bi-implication of mere propositions _โ‡”_ : hProp โ„“ โ†’ hProp โ„“' โ†’ hProp _ A โ‡” B = (A โ‡’ B) โŠ“ (B โ‡’ A) -------------------------------------------------------------------------------- -- Universal Quantifier โˆ€[โˆถ]-syntax : (A โ†’ hProp โ„“) โ†’ hProp _ โˆ€[โˆถ]-syntax {A = A} P = (โˆ€ x โ†’ [ P x ]) , isPropPi (snd โˆ˜ P) โˆ€[]-syntax : (A โ†’ hProp โ„“) โ†’ hProp _ โˆ€[]-syntax {A = A} P = (โˆ€ x โ†’ [ P x ]) , isPropPi (snd โˆ˜ P) syntax โˆ€[โˆถ]-syntax {A = A} (ฮป a โ†’ P) = โˆ€[ a โˆถ A ] P syntax โˆ€[]-syntax (ฮป a โ†’ P) = โˆ€[ a ] P -------------------------------------------------------------------------------- -- Existential Quantifier โˆƒ[]-syntax : (A โ†’ hProp โ„“) โ†’ hProp _ โˆƒ[]-syntax {A = A} P = โˆฅ ฮฃ A (fst โˆ˜ P) โˆฅโ‚š โˆƒ[โˆถ]-syntax : (A โ†’ hProp โ„“) โ†’ hProp _ โˆƒ[โˆถ]-syntax {A = A} P = โˆฅ ฮฃ A (fst โˆ˜ P) โˆฅโ‚š syntax โˆƒ[]-syntax {A = A} (ฮป x โ†’ P) = โˆƒ[ x โˆถ A ] P syntax โˆƒ[โˆถ]-syntax (ฮป x โ†’ P) = โˆƒ[ x ] P -------------------------------------------------------------------------------- -- Decidable mere proposition Decโ‚š : (P : hProp โ„“) โ†’ hProp โ„“ Decโ‚š P = Dec [ P ] , isPropDec (snd P) -------------------------------------------------------------------------------- -- Negation commutes with truncation โˆฅยฌAโˆฅโ‰กยฌโˆฅAโˆฅ : (A : Type โ„“) โ†’ โˆฅ (A โ†’ โŠฅ.โŠฅ) โˆฅโ‚š โ‰ก (ยฌ โˆฅ A โˆฅโ‚š) โˆฅยฌAโˆฅโ‰กยฌโˆฅAโˆฅ _ = โ‡’โˆถ (ฮป ยฌA A โ†’ PropTrunc.elim (ฮป _ โ†’ โŠฅ.isPropโŠฅ) (PropTrunc.elim (ฮป _ โ†’ isPropPi ฮป _ โ†’ โŠฅ.isPropโŠฅ) (ฮป ยฌp p โ†’ ยฌp p) ยฌA) A) โ‡โˆถ ฮป ยฌp โ†’ โˆฃ (ฮป p โ†’ ยฌp โˆฃ p โˆฃ) โˆฃ -------------------------------------------------------------------------------- -- (hProp, โŠ”, โŠฅ) is a bounded โŠ”-semilattice โŠ”-assoc : (P : hProp โ„“) (Q : hProp โ„“') (R : hProp โ„“'') โ†’ P โŠ” (Q โŠ” R) โ‰ก (P โŠ” Q) โŠ” R โŠ”-assoc P Q R = โ‡’โˆถ โŠ”-elim P (Q โŠ” R) (ฮป _ โ†’ (P โŠ” Q) โŠ” R) (inl โˆ˜ inl) (โŠ”-elim Q R (ฮป _ โ†’ (P โŠ” Q) โŠ” R) (inl โˆ˜ inr) inr) โ‡โˆถ assoc2 where assoc2 : (A โŠ”โ€ฒ B) โŠ”โ€ฒ C โ†’ A โŠ”โ€ฒ (B โŠ”โ€ฒ C) assoc2 โˆฃ โŠŽ.inr a โˆฃ = โˆฃ โŠŽ.inr โˆฃ โŠŽ.inr a โˆฃ โˆฃ assoc2 โˆฃ โŠŽ.inl โˆฃ โŠŽ.inr b โˆฃ โˆฃ = โˆฃ โŠŽ.inr โˆฃ โŠŽ.inl b โˆฃ โˆฃ assoc2 โˆฃ โŠŽ.inl โˆฃ โŠŽ.inl c โˆฃ โˆฃ = โˆฃ โŠŽ.inl c โˆฃ assoc2 โˆฃ โŠŽ.inl (squash x y i) โˆฃ = propTruncIsProp (assoc2 โˆฃ โŠŽ.inl x โˆฃ) (assoc2 โˆฃ โŠŽ.inl y โˆฃ) i assoc2 (squash x y i) = propTruncIsProp (assoc2 x) (assoc2 y) i โŠ”-idem : (P : hProp โ„“) โ†’ P โŠ” P โ‰ก P โŠ”-idem P = โ‡’โˆถ (โŠ”-elim P P (\ _ โ†’ P) (\ x โ†’ x) (\ x โ†’ x)) โ‡โˆถ inl โŠ”-comm : (P : hProp โ„“) (Q : hProp โ„“') โ†’ P โŠ” Q โ‰ก Q โŠ” P โŠ”-comm P Q = โ‡’โˆถ (โŠ”-elim P Q (\ _ โ†’ (Q โŠ” P)) inr inl) โ‡โˆถ (โŠ”-elim Q P (\ _ โ†’ (P โŠ” Q)) inr inl) โŠ”-identityหก : (P : hProp โ„“) โ†’ โŠฅ โŠ” P โ‰ก P โŠ”-identityหก P = โ‡’โˆถ (โŠ”-elim โŠฅ P (ฮป _ โ†’ P) (ฮป ()) (ฮป x โ†’ x)) โ‡โˆถ inr โŠ”-identityสณ : (P : hProp โ„“) โ†’ P โŠ” โŠฅ โ‰ก P โŠ”-identityสณ P = โ‡”toPath (โŠ”-elim P โŠฅ (ฮป _ โ†’ P) (ฮป x โ†’ x) ฮป ()) inl -------------------------------------------------------------------------------- -- (hProp, โŠ“, โŠค) is a bounded โŠ“-lattice โŠ“-assoc : (P : hProp โ„“) (Q : hProp โ„“') (R : hProp โ„“'') โ†’ P โŠ“ Q โŠ“ R โ‰ก (P โŠ“ Q) โŠ“ R โŠ“-assoc _ _ _ = โ‡’โˆถ (ฮป {(x , (y , z)) โ†’ (x , y) , z}) โ‡โˆถ (ฮป {((x , y) , z) โ†’ x , (y , z) }) โŠ“-comm : (P : hProp โ„“) (Q : hProp โ„“') โ†’ P โŠ“ Q โ‰ก Q โŠ“ P โŠ“-comm _ _ = โ‡”toPath ร—.swap ร—.swap โŠ“-idem : (P : hProp โ„“) โ†’ P โŠ“ P โ‰ก P โŠ“-idem _ = โ‡”toPath projโ‚ (ฮป x โ†’ x , x) โŠ“-identityหก : (P : hProp โ„“) โ†’ โŠค โŠ“ P โ‰ก P โŠ“-identityหก _ = โ‡”toPath projโ‚‚ ฮป x โ†’ tt , x โŠ“-identityสณ : (P : hProp โ„“) โ†’ P โŠ“ โŠค โ‰ก P โŠ“-identityสณ _ = โ‡”toPath projโ‚ ฮป x โ†’ x , tt -------------------------------------------------------------------------------- -- Distributive laws โ‡’-โŠ“-distrib : (P : hProp โ„“) (Q : hProp โ„“')(R : hProp โ„“'') โ†’ P โ‡’ (Q โŠ“ R) โ‰ก (P โ‡’ Q) โŠ“ (P โ‡’ R) โ‡’-โŠ“-distrib _ _ _ = โ‡’โˆถ (ฮป f โ†’ (projโ‚ โˆ˜ f) , (projโ‚‚ โˆ˜ f)) โ‡โˆถ (ฮป { (f , g) x โ†’ f x , g x}) โŠ“-โŠ”-distribหก : (P : hProp โ„“) (Q : hProp โ„“')(R : hProp โ„“'') โ†’ P โŠ“ (Q โŠ” R) โ‰ก (P โŠ“ Q) โŠ” (P โŠ“ R) โŠ“-โŠ”-distribหก P Q R = โ‡’โˆถ (ฮป { (x , a) โ†’ โŠ”-elim Q R (ฮป _ โ†’ (P โŠ“ Q) โŠ” (P โŠ“ R)) (ฮป y โ†’ โˆฃ โŠŽ.inl (x , y) โˆฃ ) (ฮป z โ†’ โˆฃ โŠŽ.inr (x , z) โˆฃ ) a }) โ‡โˆถ โŠ”-elim (P โŠ“ Q) (P โŠ“ R) (ฮป _ โ†’ P โŠ“ Q โŠ” R) (ฮป y โ†’ projโ‚ y , inl (projโ‚‚ y)) (ฮป z โ†’ projโ‚ z , inr (projโ‚‚ z)) โŠ”-โŠ“-distribหก : (P : hProp โ„“) (Q : hProp โ„“')(R : hProp โ„“'') โ†’ P โŠ” (Q โŠ“ R) โ‰ก (P โŠ” Q) โŠ“ (P โŠ” R) โŠ”-โŠ“-distribหก P Q R = โ‡’โˆถ โŠ”-elim P (Q โŠ“ R) (ฮป _ โ†’ (P โŠ” Q) โŠ“ (P โŠ” R) ) (ร—.intro inl inl) (ร—.map inr inr) โ‡โˆถ (ฮป { (x , y) โ†’ โŠ”-elim P R (ฮป _ โ†’ P โŠ” Q โŠ“ R) inl (ฮป z โ†’ โŠ”-elim P Q (ฮป _ โ†’ P โŠ” Q โŠ“ R) inl (ฮป y โ†’ inr (y , z)) x) y }) โŠ“-โˆ€-distrib : (P : A โ†’ hProp โ„“) (Q : A โ†’ hProp โ„“') โ†’ (โˆ€[ a โˆถ A ] P a) โŠ“ (โˆ€[ a โˆถ A ] Q a) โ‰ก (โˆ€[ a โˆถ A ] (P a โŠ“ Q a)) โŠ“-โˆ€-distrib P Q = โ‡’โˆถ (ฮป {(p , q) a โ†’ p a , q a}) โ‡โˆถ ฮป pq โ†’ (projโ‚ โˆ˜ pq ) , (projโ‚‚ โˆ˜ pq)
{ "alphanum_fraction": 0.400122474, "avg_line_length": 29.5833333333, "ext": "agda", "hexsha": "eca0c29eb0a8fc06035da96c0c1b478b83003215", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "borsiemir/cubical", "max_forks_repo_path": "Cubical/Foundations/Logic.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "borsiemir/cubical", "max_issues_repo_path": "Cubical/Foundations/Logic.agda", "max_line_length": 97, "max_stars_count": null, "max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "borsiemir/cubical", "max_stars_repo_path": "Cubical/Foundations/Logic.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 3809, "size": 8165 }
module Monads.WriterT where open import Class.Monad open import Class.MonadTrans open import Class.Monad.Except open import Class.Monad.State open import Class.Monad.Writer open import Class.Monoid open import Data.Product open import Data.Unit.Polymorphic open import Function open import Level private variable a : Level A B W : Set a WriterT : (Set a โ†’ Set a) โ†’ Set a โ†’ Set a โ†’ Set a WriterT M W A = M (A ร— W) module _ {M : Set a โ†’ Set a} {{_ : Monad M}} {W} {{_ : Monoid W}} where WriterT-Monad : Monad (WriterT M W) WriterT-Monad = record { _>>=_ = helper ; return = ฮป a โ†’ return (a , mzero) } where helper : WriterT M W A โ†’ (A โ†’ WriterT M W B) โ†’ WriterT M W B helper a f = do (a' , w) โ† a (b , w') โ† f a' return (b , w + w') private tell' : W โ†’ WriterT M W โŠค tell' w = return (tt , w) listen' : WriterT M W A โ†’ WriterT M W (A ร— W) listen' x = do (a , w) โ† x return ((a , w) , w) pass' : WriterT M W (A ร— (W โ†’ W)) โ†’ WriterT M W A pass' x = do ((a , f) , w) โ† x return (a , f w) WriterT-MonadWriter : MonadWriter (WriterT M W) {{WriterT-Monad}} W WriterT-MonadWriter = record { tell = tell' ; listen = listen' ; pass = pass' } WriterT-MonadTrans : {W : Set a} {{_ : Monoid W}} โ†’ MonadTrans (ฮป (M : Set a โ†’ Set a) โ†’ WriterT M W) WriterT-MonadTrans = record { embed = ฮป x โ†’ x >>= ฮป a โ†’ return (a , mzero) } module _ {M : Set a โ†’ Set a} {{_ : Monad M}} {W} {{_ : Monoid W}} where WriterT-MonadState : โˆ€ {S : Set a} {{_ : MonadState M S}} โ†’ MonadState (WriterT M W) {{WriterT-Monad}} S WriterT-MonadState = record { get = embed {{WriterT-MonadTrans}} get ; put = embed {{WriterT-MonadTrans}} โˆ˜ put } WriterT-MonadExcept : โˆ€ {E : Set a} {{_ : MonadExcept M E}} โ†’ MonadExcept (WriterT M W) {{WriterT-Monad}} E WriterT-MonadExcept = record { throwError = embed {{WriterT-MonadTrans}} โˆ˜ throwError ; catchError = catchError }
{ "alphanum_fraction": 0.5948144382, "avg_line_length": 30.734375, "ext": "agda", "hexsha": "e6af81aa40de363e723f4d478c721cb4272a8bc2", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Monads/WriterT.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Monads/WriterT.agda", "max_line_length": 109, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Monads/WriterT.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 675, "size": 1967 }
{-# OPTIONS --without-K #-} module Pi1Cat where -- Proving that Pi with one level of interesting 2 path structure is a -- symmetric rig 2-groupoid open import Level using () renaming (zero to lzero) open import Data.Unit using (tt) open import Data.Product using (_,_) open import Function using (flip) open import Categories.Category using (Category) open import Categories.Terminal using (OneC) open import Categories.Groupoid using (Groupoid) open import Categories.Monoidal using (Monoidal) open import Categories.Monoidal.Helpers using (module MonoidalHelperFunctors) open import Categories.Functor using (Functor) open import Categories.Bifunctor using (Bifunctor) open import Categories.NaturalIsomorphism using (NaturalIsomorphism) open import Categories.Monoidal.Braided using (Braided) open import Categories.Monoidal.Symmetric using (Symmetric) open import Categories.RigCategory using (RigCategory; module BimonoidalHelperFunctors) open import Categories.Bicategory using (Bicategory) open import PiU using (U; PLUS; ZERO; TIMES; ONE) open import PiLevel0 using (_โŸท_; idโŸท; _โ—Ž_; !; !!; _โŠ•_; uniteโ‚Šl; unitiโ‚Šl; uniteโ‚Šr; unitiโ‚Šr; swapโ‚Š; assocrโ‚Š; assoclโ‚Š; _โŠ—_; uniteโ‹†l; unitiโ‹†l; uniteโ‹†r; unitiโ‹†r; swapโ‹†; assocrโ‹†; assoclโ‹†; absorbl; absorbr; factorzl; factorzr; dist; factor; distl; factorl) open import PiLevel1 using (_โ‡”_; โ‡”Equiv; trivโ‰ก; trivโ‰กEquiv; 2!; idโ‡”; transโ‡”; _โŠก_; assocโ—Žl; idrโ—Žl; idlโ—Žl; linvโ—Žl; rinvโ—Žl; idโŸทโŠ•idโŸทโ‡”; homโŠ•โ—Žโ‡”; respโŠ•โ‡”; uniteโ‚Šlโ‡”r; unitiโ‚Šlโ‡”r; uniteโ‚Šrโ‡”r; unitiโ‚Šrโ‡”r; assocrโŠ•r; assoclโŠ•l; triangleโŠ•l; pentagonโŠ•l; idโŸทโŠ—idโŸทโ‡”; homโŠ—โ—Žโ‡”; respโŠ—โ‡”; uniterโ‹†โ‡”l; unitirโ‹†โ‡”l; uniterโ‹†โ‡”r; unitirโ‹†โ‡”r; assocrโŠ—r; assoclโŠ—l; triangleโŠ—l; pentagonโŠ—l; swaprโ‚Šโ‡”; uniteโ‚Šl-coh-l; hexagonrโŠ•l; hexagonlโŠ•l; swaprโ‹†โ‡”; uniteโ‹†l-coh-l; hexagonrโŠ—l; hexagonlโŠ—l; absorblโ‡”l; factorzrโ‡”l; absorbrโ‡”l; factorzlโ‡”l; distlโ‡”l; factorlโ‡”l; distโ‡”l; factorโ‡”l; swapโ‚Šdistlโ‡”l; dist-swapโ‹†โ‡”l; assoclโ‚Š-dist-distโ‡”l; assoclโ‹†-distlโ‡”l; fully-distributeโ‡”l; absorbr0-absorbl0โ‡”; absorbrโ‡”distl-absorb-unite; uniteโ‹†r0-absorbr1โ‡”; absorblโ‰กswapโ‹†โ—Žabsorbr; absorbrโ‡”[assoclโ‹†โ—Ž[absorbrโŠ—idโŸท]]โ—Žabsorbr; [idโŸทโŠ—absorbr]โ—Žabsorblโ‡”assoclโ‹†โ—Ž[absorblโŠ—idโŸท]โ—Žabsorbr; elimโŠฅ-A[0โŠ•B]โ‡”l; elimโŠฅ-1[AโŠ•B]โ‡”l; -- for bicategory idrโ—Žr; idlโ—Žr; assocโ—Žr ) ------------------------------------------------------------------------------ -- Pi1 is a category... Pi1Cat : Category lzero lzero lzero Pi1Cat = record { Obj = U ; _โ‡’_ = _โŸท_ ; _โ‰ก_ = _โ‡”_ ; id = idโŸท ; _โˆ˜_ = ฮป yโŸทz xโŸทy โ†’ xโŸทy โ—Ž yโŸทz ; assoc = assocโ—Žl ; identityหก = idrโ—Žl ; identityสณ = idlโ—Žl ; equiv = โ‡”Equiv ; โˆ˜-resp-โ‰ก = ฮป f g โ†’ g โŠก f } -- and a groupoid ... Pi1Groupoid : Groupoid Pi1Cat Pi1Groupoid = record { _โปยน = ! ; iso = record { isoหก = linvโ—Žl ; isoสณ = rinvโ—Žl } } -- additive bifunctor and monoidal structure โŠ•-bifunctor : Bifunctor Pi1Cat Pi1Cat Pi1Cat โŠ•-bifunctor = record { Fโ‚€ = ฮป {(u , v) โ†’ PLUS u v} ; Fโ‚ = ฮป {(xโŸทy , zโŸทw) โ†’ xโŸทy โŠ• zโŸทw } ; identity = idโŸทโŠ•idโŸทโ‡” ; homomorphism = homโŠ•โ—Žโ‡” ; F-resp-โ‰ก = ฮป {(x , y) โ†’ respโŠ•โ‡” x y} } module โŠŽh = MonoidalHelperFunctors Pi1Cat โŠ•-bifunctor ZERO -- note how powerful linvโ—Žl/rinvโ—Žl are in iso below 0โŠ•xโ‰กx : NaturalIsomorphism โŠŽh.idโŠ—x โŠŽh.x 0โŠ•xโ‰กx = record { Fโ‡’G = record { ฮท = ฮป X โ†’ uniteโ‚Šl ; commute = ฮป f โ†’ uniteโ‚Šlโ‡”r } ; Fโ‡G = record { ฮท = ฮป X โ†’ unitiโ‚Šl ; commute = ฮป f โ†’ unitiโ‚Šlโ‡”r } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl; isoสณ = rinvโ—Žl } } xโŠ•0โ‰กx : NaturalIsomorphism โŠŽh.xโŠ—id โŠŽh.x xโŠ•0โ‰กx = record { Fโ‡’G = record { ฮท = ฮป X โ†’ uniteโ‚Šr ; commute = ฮป f โ†’ uniteโ‚Šrโ‡”r } ; Fโ‡G = record { ฮท = ฮป X โ†’ unitiโ‚Šr ; commute = ฮป f โ†’ unitiโ‚Šrโ‡”r } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl ; isoสณ = rinvโ—Žl } } [xโŠ•y]โŠ•zโ‰กxโŠ•[yโŠ•z] : NaturalIsomorphism โŠŽh.[xโŠ—y]โŠ—z โŠŽh.xโŠ—[yโŠ—z] [xโŠ•y]โŠ•zโ‰กxโŠ•[yโŠ•z] = record { Fโ‡’G = record { ฮท = ฮป X โ†’ assocrโ‚Š ; commute = ฮป f โ†’ assocrโŠ•r } ; Fโ‡G = record { ฮท = ฮป X โ†’ assoclโ‚Š ; commute = ฮป f โ†’ assoclโŠ•l } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl ; isoสณ = rinvโ—Žl } } -- and a monoidal category (additive) MโŠ• : Monoidal Pi1Cat MโŠ• = record { โŠ— = โŠ•-bifunctor ; id = ZERO ; identityหก = 0โŠ•xโ‰กx ; identityสณ = xโŠ•0โ‰กx ; assoc = [xโŠ•y]โŠ•zโ‰กxโŠ•[yโŠ•z] ; triangle = triangleโŠ•l ; pentagon = pentagonโŠ•l } -- multiplicative bifunctor and monoidal structure โŠ—-bifunctor : Bifunctor Pi1Cat Pi1Cat Pi1Cat โŠ—-bifunctor = record { Fโ‚€ = ฮป {(u , v) โ†’ TIMES u v} ; Fโ‚ = ฮป {(xโŸทy , zโŸทw) โ†’ xโŸทy โŠ— zโŸทw } ; identity = idโŸทโŠ—idโŸทโ‡” ; homomorphism = homโŠ—โ—Žโ‡” ; F-resp-โ‰ก = ฮป {(x , y) โ†’ respโŠ—โ‡” x y} } module ร—h = MonoidalHelperFunctors Pi1Cat โŠ—-bifunctor ONE 1โŠ—xโ‰กx : NaturalIsomorphism ร—h.idโŠ—x ร—h.x 1โŠ—xโ‰กx = record { Fโ‡’G = record { ฮท = ฮป X โ†’ uniteโ‹†l ; commute = ฮป f โ†’ uniterโ‹†โ‡”l } ; Fโ‡G = record { ฮท = ฮป X โ†’ unitiโ‹†l ; commute = ฮป f โ†’ unitirโ‹†โ‡”l } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl; isoสณ = rinvโ—Žl } } xโŠ—1โ‰กx : NaturalIsomorphism ร—h.xโŠ—id ร—h.x xโŠ—1โ‰กx = record { Fโ‡’G = record { ฮท = ฮป X โ†’ uniteโ‹†r ; commute = ฮป f โ†’ uniterโ‹†โ‡”r } ; Fโ‡G = record { ฮท = ฮป X โ†’ unitiโ‹†r ; commute = ฮป f โ†’ unitirโ‹†โ‡”r } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl ; isoสณ = rinvโ—Žl } } [xโŠ—y]โŠ—zโ‰กxโŠ—[yโŠ—z] : NaturalIsomorphism ร—h.[xโŠ—y]โŠ—z ร—h.xโŠ—[yโŠ—z] [xโŠ—y]โŠ—zโ‰กxโŠ—[yโŠ—z] = record { Fโ‡’G = record { ฮท = ฮป X โ†’ assocrโ‹† ; commute = ฮป f โ†’ assocrโŠ—r } ; Fโ‡G = record { ฮท = ฮป X โ†’ assoclโ‹† ; commute = ฮป f โ†’ assoclโŠ—l } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl ; isoสณ = rinvโ—Žl } } -- and a monoidal category (multiplicative) MโŠ— : Monoidal Pi1Cat MโŠ— = record { โŠ— = โŠ—-bifunctor ; id = ONE ; identityหก = 1โŠ—xโ‰กx ; identityสณ = xโŠ—1โ‰กx ; assoc = [xโŠ—y]โŠ—zโ‰กxโŠ—[yโŠ—z] ; triangle = triangleโŠ—l ; pentagon = pentagonโŠ—l } xโŠ•yโ‰กyโŠ•x : NaturalIsomorphism โŠŽh.xโŠ—y โŠŽh.yโŠ—x xโŠ•yโ‰กyโŠ•x = record { Fโ‡’G = record { ฮท = ฮป X โ†’ swapโ‚Š ; commute = ฮป f โ†’ swaprโ‚Šโ‡” } ; Fโ‡G = record { ฮท = ฮป X โ†’ swapโ‚Š ; commute = ฮป f โ†’ swaprโ‚Šโ‡” } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl ; isoสณ = rinvโ—Žl } } BMโŠ• : Braided MโŠ• BMโŠ• = record { braid = xโŠ•yโ‰กyโŠ•x ; unit-coh = uniteโ‚Šl-coh-l ; hexagonโ‚ = hexagonrโŠ•l ; hexagonโ‚‚ = hexagonlโŠ•l } xโŠ—yโ‰กyโŠ—x : NaturalIsomorphism ร—h.xโŠ—y ร—h.yโŠ—x xโŠ—yโ‰กyโŠ—x = record { Fโ‡’G = record { ฮท = ฮป X โ†’ swapโ‹† ; commute = ฮป f โ†’ swaprโ‹†โ‡” } ; Fโ‡G = record { ฮท = ฮป X โ†’ swapโ‹† ; commute = ฮป f โ†’ swaprโ‹†โ‡” } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl ; isoสณ = rinvโ—Žl } } BMโŠ— : Braided MโŠ— BMโŠ— = record { braid = xโŠ—yโ‰กyโŠ—x ; unit-coh = uniteโ‹†l-coh-l ; hexagonโ‚ = hexagonrโŠ—l ; hexagonโ‚‚ = hexagonlโŠ—l } -- with both monoidal structures being symmetric SBMโŠ• : Symmetric BMโŠ• SBMโŠ• = record { symmetry = linvโ—Žl } SBMโŠ— : Symmetric BMโŠ— SBMโŠ— = record { symmetry = rinvโ—Žl } module r = BimonoidalHelperFunctors BMโŠ• BMโŠ— xโŠ—0โ‰ก0 : NaturalIsomorphism r.xโŠ—0 r.0โ†‘ xโŠ—0โ‰ก0 = record { Fโ‡’G = record { ฮท = ฮป X โ†’ absorbl ; commute = ฮป f โ†’ absorblโ‡”l } ; Fโ‡G = record { ฮท = ฮป X โ†’ factorzr ; commute = ฮป f โ†’ factorzrโ‡”l } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl ; isoสณ = rinvโ—Žl } } 0โŠ—xโ‰ก0 : NaturalIsomorphism r.0โŠ—x r.0โ†‘ 0โŠ—xโ‰ก0 = record { Fโ‡’G = record { ฮท = ฮป X โ†’ absorbr ; commute = ฮป f โ†’ absorbrโ‡”l } ; Fโ‡G = record { ฮท = ฮป X โ†’ factorzl ; commute = ฮป f โ†’ factorzlโ‡”l } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl ; isoสณ = rinvโ—Žl } } xโŠ—[yโŠ•z]โ‰ก[xโŠ—y]โŠ•[xโŠ—z] : NaturalIsomorphism r.xโŠ—[yโŠ•z] r.[xโŠ—y]โŠ•[xโŠ—z] xโŠ—[yโŠ•z]โ‰ก[xโŠ—y]โŠ•[xโŠ—z] = record { Fโ‡’G = record { ฮท = ฮป _ โ†’ distl ; commute = ฮป f โ†’ distlโ‡”l } ; Fโ‡G = record { ฮท = ฮป _ โ†’ factorl ; commute = ฮป f โ†’ factorlโ‡”l } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl ; isoสณ = rinvโ—Žl } } [xโŠ•y]โŠ—zโ‰ก[xโŠ—z]โŠ•[yโŠ—z] : NaturalIsomorphism r.[xโŠ•y]โŠ—z r.[xโŠ—z]โŠ•[yโŠ—z] [xโŠ•y]โŠ—zโ‰ก[xโŠ—z]โŠ•[yโŠ—z] = record { Fโ‡’G = record { ฮท = ฮป X โ†’ dist ; commute = ฮป f โ†’ distโ‡”l } ; Fโ‡G = record { ฮท = ฮป X โ†’ factor ; commute = ฮป f โ†’ factorโ‡”l } ; iso = ฮป X โ†’ record { isoหก = linvโ—Žl ; isoสณ = rinvโ—Žl } } -- and the multiplicative structure distributing over the additive one Pi1Rig : RigCategory SBMโŠ• SBMโŠ— Pi1Rig = record { distribโ‚— = xโŠ—[yโŠ•z]โ‰ก[xโŠ—y]โŠ•[xโŠ—z] ; distribแตฃ = [xโŠ•y]โŠ—zโ‰ก[xโŠ—z]โŠ•[yโŠ—z] ; annโ‚— = 0โŠ—xโ‰ก0 ; annแตฃ = xโŠ—0โ‰ก0 ; laplazaI = swapโ‚Šdistlโ‡”l ; laplazaII = dist-swapโ‹†โ‡”l ; laplazaIV = assoclโ‚Š-dist-distโ‡”l ; laplazaVI = assoclโ‹†-distlโ‡”l ; laplazaIX = fully-distributeโ‡”l ; laplazaX = absorbr0-absorbl0โ‡” ; laplazaXI = absorbrโ‡”distl-absorb-unite ; laplazaXIII = uniteโ‹†r0-absorbr1โ‡” ; laplazaXV = absorblโ‰กswapโ‹†โ—Žabsorbr ; laplazaXVI = absorbrโ‡”[assoclโ‹†โ—Ž[absorbrโŠ—idโŸท]]โ—Žabsorbr ; laplazaXVII = [idโŸทโŠ—absorbr]โ—Žabsorblโ‡”assoclโ‹†โ—Ž[absorblโŠ—idโŸท]โ—Žabsorbr ; laplazaXIX = elimโŠฅ-A[0โŠ•B]โ‡”l ; laplazaXXIII = elimโŠฅ-1[AโŠ•B]โ‡”l } ------------------------------------------------------------------------------ -- The morphisms of the Pi1 category have structure; they form a -- category, something like another Symmetric Rig Groupoid but more -- general โŸทCat : (tโ‚ tโ‚‚ : U) โ†’ Category lzero lzero lzero โŸทCat tโ‚ tโ‚‚ = record { Obj = tโ‚ โŸท tโ‚‚ ; _โ‡’_ = _โ‡”_ ; _โ‰ก_ = trivโ‰ก ; id = idโ‡” ; _โˆ˜_ = flip transโ‡” ; assoc = tt ; identityหก = tt ; identityสณ = tt ; equiv = trivโ‰กEquiv ; โˆ˜-resp-โ‰ก = ฮป _ _ โ†’ tt } โŸทGroupoid : (tโ‚ tโ‚‚ : U) โ†’ Groupoid (โŸทCat tโ‚ tโ‚‚) โŸทGroupoid tโ‚ tโ‚‚ = record { _โปยน = 2! ; iso = record { isoหก = tt ; isoสณ = tt } } -- These feel like the right notions of bifunctor but of course they -- are relating different categories so the rest of the development to -- RigCategory would need to be generalized if we were to use these -- definitions of bifunctors. โŠ•โŸท-bifunctor : (tโ‚ tโ‚‚ tโ‚ƒ tโ‚„ : U) โ†’ Bifunctor (โŸทCat tโ‚ tโ‚‚) (โŸทCat tโ‚ƒ tโ‚„) (โŸทCat (PLUS tโ‚ tโ‚ƒ) (PLUS tโ‚‚ tโ‚„)) โŠ•โŸท-bifunctor tโ‚ tโ‚‚ tโ‚ƒ tโ‚„ = record { Fโ‚€ = ฮป {(f , g) โ†’ f โŠ• g } ; Fโ‚ = ฮป {(ฮฑ , ฮฒ) โ†’ respโŠ•โ‡” ฮฑ ฮฒ } ; identity = tt ; homomorphism = tt ; F-resp-โ‰ก = ฮป _ โ†’ tt } โŠ—โŸท-bifunctor : (tโ‚ tโ‚‚ tโ‚ƒ tโ‚„ : U) โ†’ Bifunctor (โŸทCat tโ‚ tโ‚‚) (โŸทCat tโ‚ƒ tโ‚„) (โŸทCat (TIMES tโ‚ tโ‚ƒ) (TIMES tโ‚‚ tโ‚„)) โŠ—โŸท-bifunctor tโ‚ tโ‚‚ tโ‚ƒ tโ‚„ = record { Fโ‚€ = ฮป {(f , g) โ†’ f โŠ— g } ; Fโ‚ = ฮป {(ฮฑ , ฮฒ) โ†’ respโŠ—โ‡” ฮฑ ฮฒ } ; identity = tt ; homomorphism = tt ; F-resp-โ‰ก = ฮป _ โ†’ tt } ------------------------------------------------------------------------------ -- We have a 2-category but NOT a strict one. idF : {t : U} โ†’ Functor {lzero} {lzero} {lzero} OneC (โŸทCat t t) idF {t} = record { Fโ‚€ = ฮป _ โ†’ idโŸท {t} ; Fโ‚ = ฮป _ โ†’ idโ‡” ; identity = tt ; homomorphism = tt ; F-resp-โ‰ก = ฮป _ โ†’ tt } โˆ˜-bifunctor : {tโ‚ tโ‚‚ tโ‚ƒ : U} โ†’ Bifunctor (โŸทCat tโ‚‚ tโ‚ƒ) (โŸทCat tโ‚ tโ‚‚) (โŸทCat tโ‚ tโ‚ƒ) โˆ˜-bifunctor = record { Fโ‚€ = ฮป {(f , g) โ†’ g โ—Ž f} ; Fโ‚ = ฮป {(ฮฑ , ฮฒ) โ†’ ฮฒ โŠก ฮฑ} ; identity = tt ; homomorphism = tt ; F-resp-โ‰ก = ฮป _ โ†’ tt } Pi1-Bicat : Bicategory lzero lzero lzero lzero Pi1-Bicat = record { Obj = U ; _โ‡’_ = โŸทCat ; id = idF ; โ€”โˆ˜โ€” = โˆ˜-bifunctor ; ฮปแตค = record { Fโ‡’G = record { ฮท = ฮป X โ†’ idrโ—Žl ; commute = ฮป {f โ†’ tt} } ; Fโ‡G = record { ฮท = ฮป X โ†’ idrโ—Žr ; commute = ฮป {X} {Y} f โ†’ tt } ; iso = ฮป X โ†’ record { isoหก = tt ; isoสณ = tt } } ; ฯแตค = record { Fโ‡’G = record { ฮท = ฮป X โ†’ idlโ—Žl ; commute = ฮป {X} {Y} f โ†’ tt } ; Fโ‡G = record { ฮท = ฮป X โ†’ idlโ—Žr ; commute = ฮป {X} {Y} f โ†’ tt } ; iso = ฮป X โ†’ record { isoหก = tt ; isoสณ = tt } } ; ฮฑ = record { Fโ‡’G = record { ฮท = ฮป _ โ†’ assocโ—Žr ; commute = ฮป {X} {Y} f โ†’ tt } ; Fโ‡G = record { ฮท = ฮป _ โ†’ assocโ—Žl ; commute = ฮป {X} {Y} f โ†’ tt } ; iso = ฮป X โ†’ record { isoหก = tt ; isoสณ = tt } } ; triangle = ฮป {A} {B} {C} f g โ†’ tt ; pentagon = ฮป {A} {B} {C} {D} {E} f g h i โ†’ tt } {-- Here is why Pi1 is NOT a strict 2-Category: Pi1-2Cat : 2-Category lzero lzero lzero lzero Pi1-2Cat = record { Obj = U ; _โ‡’_ = โŸทCat ; id = idF ; โ€”โˆ˜โ€” = โˆ˜-bifunctor ; assoc = {!!} ; identityหก = {!!} } The definition of 2-Category is STRICT, which means that for proof of identityหก requires the following diagram to commute: Assume the following 1-paths: cโ‚ cโ‚‚ : A โŸท B id_B : B โŸท B and the following 2-paths: ฮฑ : cโ‚ โ‡” cโ‚‚ id_id_B : id_B โ‡” id_B We can construct the 2-path: ฮฑ โŠก id_id_B : cโ‚ โ—Ž id_B โ‡” cโ‚‚ โ—Ž id_B The property identityหก requires that there is a 3-path between ฮฑ and ฮฑ โŠก id_id_B and indeed there are "equivalent" in some sense as: ฮฑ โŠก id_id_B : cโ‚ โ—Ž id_B โ‡” cโ‚‚ โ—Ž id_B can be viewed as having the equivalent type: ฮฑ โŠก id_id_B : cโ‚ โ‡” cโ‚‚ and we identify all 2-paths of the same type. This reasoning however requires that identityหก is asserted up to the 2-paths relating cโ‚ โ—Ž id_B and cโ‚ on one hand and cโ‚‚ โ—Ž id_B and cโ‚‚ on the other hand. Formally the nlab page http://ncatlab.org/nlab/show/2-category explains this as follows: For some purposes, strict 2-categories are too strict: one would like to allow composition of morphisms to be associative and unital only up to coherent invertible 2-morphisms. A direct generalization of the above โ€œenrichedโ€ definition produces the classical notion of bicategory. So to conclude what we really need is a weak version of 2-Category which is known as 'bicategory'. --} ------------------------------------------------------------------------------
{ "alphanum_fraction": 0.5705078428, "avg_line_length": 27.9349240781, "ext": "agda", "hexsha": "e7029ce091e2f175df05c9e80722b241d768da8d", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z", "max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "JacquesCarette/pi-dual", "max_forks_repo_path": "Univalence/Pi1Cat.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "JacquesCarette/pi-dual", "max_issues_repo_path": "Univalence/Pi1Cat.agda", "max_line_length": 79, "max_stars_count": 14, "max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "JacquesCarette/pi-dual", "max_stars_repo_path": "Univalence/Pi1Cat.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z", "num_tokens": 6247, "size": 12878 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Sums of nullary relations ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Nullary.Sum where open import Data.Sum open import Data.Empty open import Level open import Relation.Nullary -- Some properties which are preserved by _โŠŽ_. infixr 1 _ยฌ-โŠŽ_ _โŠŽ-dec_ _ยฌ-โŠŽ_ : โˆ€ {p q} {P : Set p} {Q : Set q} โ†’ ยฌ P โ†’ ยฌ Q โ†’ ยฌ (P โŠŽ Q) (ยฌp ยฌ-โŠŽ ยฌq) (injโ‚ p) = ยฌp p (ยฌp ยฌ-โŠŽ ยฌq) (injโ‚‚ q) = ยฌq q _โŠŽ-dec_ : โˆ€ {p q} {P : Set p} {Q : Set q} โ†’ Dec P โ†’ Dec Q โ†’ Dec (P โŠŽ Q) yes p โŠŽ-dec _ = yes (injโ‚ p) _ โŠŽ-dec yes q = yes (injโ‚‚ q) no ยฌp โŠŽ-dec no ยฌq = no helper where helper : _ โŠŽ _ โ†’ โŠฅ helper (injโ‚ p) = ยฌp p helper (injโ‚‚ q) = ยฌq q
{ "alphanum_fraction": 0.4475271411, "avg_line_length": 24.3823529412, "ext": "agda", "hexsha": "3705c0f35fad3f422fdfe23af7f3e972a17e7b0b", "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/Sum.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/Sum.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/Sum.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 299, "size": 829 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties related to addition of integers ------------------------------------------------------------------------ module Data.Integer.Addition.Properties where open import Algebra import Algebra.FunctionProperties open import Algebra.Structures open import Data.Integer hiding (suc) open import Data.Nat using (suc; zero) renaming (_+_ to _โ„•+_) import Data.Nat.Properties as โ„• open import Relation.Binary.PropositionalEquality open Algebra.FunctionProperties (_โ‰ก_ {A = โ„ค}) open CommutativeSemiring โ„•.commutativeSemiring using (+-comm; +-assoc; +-identity) ------------------------------------------------------------------------ -- Addition and zero form a commutative monoid private comm : Commutative _+_ comm -[1+ a ] -[1+ b ] rewrite +-comm a b = refl comm (+ a ) (+ b ) rewrite +-comm a b = refl comm -[1+ _ ] (+ _ ) = refl comm (+ _ ) -[1+ _ ] = refl identityหก : LeftIdentity (+ 0) _+_ identityหก -[1+ _ ] = refl identityหก (+ _ ) = refl identityสณ : RightIdentity (+ 0) _+_ identityสณ x rewrite comm x (+ 0) = identityหก x distribหก-โŠ–-+-neg : โˆ€ a b c โ†’ b โŠ– c + -[1+ a ] โ‰ก b โŠ– (suc c โ„•+ a) distribหก-โŠ–-+-neg _ zero zero = refl distribหก-โŠ–-+-neg _ zero (suc _) = refl distribหก-โŠ–-+-neg _ (suc _) zero = refl distribหก-โŠ–-+-neg a (suc b) (suc c) = distribหก-โŠ–-+-neg a b c distribสณ-โŠ–-+-neg : โˆ€ a b c โ†’ -[1+ a ] + (b โŠ– c) โ‰ก b โŠ– (suc a โ„•+ c) distribสณ-โŠ–-+-neg a b c rewrite comm -[1+ a ] (b โŠ– c) | distribหก-โŠ–-+-neg a b c | +-comm a c = refl distribหก-โŠ–-+-pos : โˆ€ a b c โ†’ b โŠ– c + + a โ‰ก b โ„•+ a โŠ– c distribหก-โŠ–-+-pos _ zero zero = refl distribหก-โŠ–-+-pos _ zero (suc _) = refl distribหก-โŠ–-+-pos _ (suc _) zero = refl distribหก-โŠ–-+-pos a (suc b) (suc c) = distribหก-โŠ–-+-pos a b c distribสณ-โŠ–-+-pos : โˆ€ a b c โ†’ + a + (b โŠ– c) โ‰ก a โ„•+ b โŠ– c distribสณ-โŠ–-+-pos a b c rewrite comm (+ a) (b โŠ– c) | distribหก-โŠ–-+-pos a b c | +-comm a b = refl assoc : Associative _+_ assoc (+ zero) y z rewrite identityหก y | identityหก (y + z) = refl assoc x (+ zero) z rewrite identityสณ x | identityหก z = refl assoc x y (+ zero) rewrite identityสณ (x + y) | identityสณ y = refl assoc -[1+ a ] -[1+ b ] (+ suc c) = sym (distribสณ-โŠ–-+-neg a c b) assoc -[1+ a ] (+ suc b) (+ suc c) = distribหก-โŠ–-+-pos (suc c) b a assoc (+ suc a) -[1+ b ] -[1+ c ] = distribหก-โŠ–-+-neg c a b assoc (+ suc a) -[1+ b ] (+ suc c) rewrite distribหก-โŠ–-+-pos (suc c) a b | distribสณ-โŠ–-+-pos (suc a) c b | sym (+-assoc a 1 c) | +-comm a 1 = refl assoc (+ suc a) (+ suc b) -[1+ c ] rewrite distribสณ-โŠ–-+-pos (suc a) b c | sym (+-assoc a 1 b) | +-comm a 1 = refl assoc -[1+ a ] -[1+ b ] -[1+ c ] rewrite sym (+-assoc a 1 (b โ„•+ c)) | +-comm a 1 | +-assoc a b c = refl assoc -[1+ a ] (+ suc b) -[1+ c ] rewrite distribสณ-โŠ–-+-neg a b c | distribหก-โŠ–-+-neg c b a = refl assoc (+ suc a) (+ suc b) (+ suc c) rewrite +-assoc (suc a) (suc b) (suc c) = refl isSemigroup : IsSemigroup _โ‰ก_ _+_ isSemigroup = record { isEquivalence = isEquivalence ; assoc = assoc ; โˆ™-cong = congโ‚‚ _+_ } isCommutativeMonoid : IsCommutativeMonoid _โ‰ก_ _+_ (+ 0) isCommutativeMonoid = record { isSemigroup = isSemigroup ; identityหก = identityหก ; comm = comm } commutativeMonoid : CommutativeMonoid _ _ commutativeMonoid = record { Carrier = โ„ค ; _โ‰ˆ_ = _โ‰ก_ ; _โˆ™_ = _+_ ; ฮต = + 0 ; isCommutativeMonoid = isCommutativeMonoid }
{ "alphanum_fraction": 0.4994761655, "avg_line_length": 32.3559322034, "ext": "agda", "hexsha": "d4cd9c311f5743ab0cdab3bb2b8a63f1578051d9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Integer/Addition/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Integer/Addition/Properties.agda", "max_line_length": 73, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Integer/Addition/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 1430, "size": 3818 }
module Structure.Operator.Vector.Proofs where open import Data.Tuple open import Functional open import Function.Equals import Lvl open import Logic open import Logic.Propositional open import Logic.Predicate open import Structure.Setoid open import Structure.Operator open import Structure.Operator.Field open import Structure.Operator.Group open import Structure.Operator.Monoid import Structure.Operator.Names as Names open import Structure.Operator.Proofs open import Structure.Operator.Properties open import Structure.Operator.Vector open import Structure.Relator.Properties open import Syntax.Transitivity open import Type module _ {โ„“แตฅ โ„“โ‚› โ„“แตฅโ‚‘ โ„“โ‚›โ‚‘ : Lvl.Level} {V : Type{โ„“แตฅ}} โฆƒ equiv-V : Equiv{โ„“แตฅโ‚‘}(V) โฆ„ {S : Type{โ„“โ‚›}} โฆƒ equiv-S : Equiv{โ„“โ‚›โ‚‘}(S) โฆ„ {_+แตฅ_ : V โ†’ V โ†’ V} {_โ‹…โ‚›แตฅ_ : S โ†’ V โ†’ V} {_+โ‚›_ _โ‹…โ‚›_ : S โ†’ S โ†’ S} where module _ โฆƒ vectorSpace : VectorSpace(_+แตฅ_)(_โ‹…โ‚›แตฅ_)(_+โ‚›_)(_โ‹…โ‚›_) โฆ„ where open VectorSpace(vectorSpace) [โ‹…โ‚›แตฅ]-absorberโ‚— : โˆ€{v} โ†’ (๐ŸŽโ‚› โ‹…โ‚›แตฅ v โ‰ก ๐ŸŽแตฅ) [โ‹…โ‚›แตฅ]-absorberโ‚— {v} = cancellationแตฃ(_+แตฅ_) โฆƒ One.cancellationแตฃ-by-associativity-inverse โฆ„ $ (๐ŸŽโ‚› โ‹…โ‚›แตฅ v) +แตฅ (๐ŸŽโ‚› โ‹…โ‚›แตฅ v) ๐Ÿ–-[ [โ‹…โ‚›แตฅ][+โ‚›][+แตฅ]-distributivityแตฃ ]-sym (๐ŸŽโ‚› +โ‚› ๐ŸŽโ‚›) โ‹…โ‚›แตฅ v ๐Ÿ–-[ congruenceโ‚‚โ‚—(_โ‹…โ‚›แตฅ_)(v) (identityโ‚—(_+โ‚›_)(๐ŸŽโ‚›)) ] ๐ŸŽโ‚› โ‹…โ‚›แตฅ v ๐Ÿ–-[ identityโ‚—(_+แตฅ_)(๐ŸŽแตฅ) ]-sym ๐ŸŽแตฅ +แตฅ (๐ŸŽโ‚› โ‹…โ‚›แตฅ v) ๐Ÿ–-end [โ‹…โ‚›แตฅ]-absorberแตฃ : โˆ€{s} โ†’ (s โ‹…โ‚›แตฅ ๐ŸŽแตฅ โ‰ก ๐ŸŽแตฅ) [โ‹…โ‚›แตฅ]-absorberแตฃ {s} = cancellationแตฃ(_+แตฅ_) โฆƒ One.cancellationแตฃ-by-associativity-inverse โฆ„ $ (s โ‹…โ‚›แตฅ ๐ŸŽแตฅ) +แตฅ (s โ‹…โ‚›แตฅ ๐ŸŽแตฅ) ๐Ÿ–-[ distributivityโ‚—(_โ‹…โ‚›แตฅ_)(_+แตฅ_) ]-sym s โ‹…โ‚›แตฅ (๐ŸŽแตฅ +แตฅ ๐ŸŽแตฅ) ๐Ÿ–-[ congruenceโ‚‚แตฃ(_โ‹…โ‚›แตฅ_)(s) (identityโ‚—(_+แตฅ_)(๐ŸŽแตฅ)) ] s โ‹…โ‚›แตฅ ๐ŸŽแตฅ ๐Ÿ–-[ identityโ‚—(_+แตฅ_)(๐ŸŽแตฅ) ]-sym ๐ŸŽแตฅ +แตฅ (s โ‹…โ‚›แตฅ ๐ŸŽแตฅ) ๐Ÿ–-end [โ‹…โ‚›แตฅ]-negation : โˆ€{v} โ†’ ((โˆ’โ‚› ๐Ÿโ‚›) โ‹…โ‚›แตฅ v โ‰ก โˆ’แตฅ v) [โ‹…โ‚›แตฅ]-negation {v} = _โŠœ_.proof (One.unique-inverseFunctionแตฃ-by-id (intro p) [+แตฅ]-inverseแตฃ) {v} where p : Names.InverseFunctionแตฃ(_+แตฅ_) ๐ŸŽแตฅ ((โˆ’โ‚› ๐Ÿโ‚›) โ‹…โ‚›แตฅ_) p{v} = v +แตฅ ((โˆ’โ‚› ๐Ÿโ‚›) โ‹…โ‚›แตฅ v) ๐Ÿ–-[ congruenceโ‚‚โ‚—(_+แตฅ_) _ (identityโ‚—(_โ‹…โ‚›แตฅ_)(๐Ÿโ‚›)) ]-sym (๐Ÿโ‚› โ‹…โ‚›แตฅ v) +แตฅ ((โˆ’โ‚› ๐Ÿโ‚›) โ‹…โ‚›แตฅ v) ๐Ÿ–-[ [โ‹…โ‚›แตฅ][+โ‚›][+แตฅ]-distributivityแตฃ ]-sym (๐Ÿโ‚› +โ‚› (โˆ’โ‚› ๐Ÿโ‚›))โ‹…โ‚›แตฅ v ๐Ÿ–-[ congruenceโ‚‚โ‚—(_โ‹…โ‚›แตฅ_) v (inverseFunctionแตฃ(_+โ‚›_) โฆƒ [โˆƒ]-intro _ โฆƒ [+โ‚›]-identityแตฃ โฆ„ โฆ„ (โˆ’โ‚›_)) ] ๐ŸŽโ‚› โ‹…โ‚›แตฅ v ๐Ÿ–-[ [โ‹…โ‚›แตฅ]-absorberโ‚— ] ๐ŸŽแตฅ ๐Ÿ–-end
{ "alphanum_fraction": 0.5802105263, "avg_line_length": 39.5833333333, "ext": "agda", "hexsha": "9223da403506565149a14e1112ea3af66e739fd9", "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/Vector/Proofs.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Structure/Operator/Vector/Proofs.agda", "max_line_length": 131, "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/Vector/Proofs.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1399, "size": 2375 }
-- ASR (2016-02-15). In the Makefile in test/compiler founded in the -- 2.4.2.3 tag, this test used the options `+RTS -H1G -M1.5G -RTS`. module AllStdLib where -- Ensure that the entire standard library is compiled. import README open import Data.Unit.Base open import Data.String open import IO import IO.Primitive as Prim main : Prim.IO โŠค main = run (putStrLn "Hello World!")
{ "alphanum_fraction": 0.7329842932, "avg_line_length": 23.875, "ext": "agda", "hexsha": "884a624af40439bc909ac23b190e6f074545c039", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "redfish64/autonomic-agda", "max_forks_repo_path": "test/Compiler/with-stdlib/AllStdLib.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "redfish64/autonomic-agda", "max_issues_repo_path": "test/Compiler/with-stdlib/AllStdLib.agda", "max_line_length": 68, "max_stars_count": null, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Compiler/with-stdlib/AllStdLib.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 114, "size": 382 }
module maybe where open import level open import eq open import bool ---------------------------------------------------------------------- -- datatypes ---------------------------------------------------------------------- data maybe {โ„“}(A : Set โ„“) : Set โ„“ where just : A โ†’ maybe A nothing : maybe A ---------------------------------------------------------------------- -- operations ---------------------------------------------------------------------- _โ‰ซ=maybe_ : โˆ€ {โ„“}{A B : Set โ„“} โ†’ maybe A โ†’ (A โ†’ maybe B) โ†’ maybe B nothing โ‰ซ=maybe f = nothing (just x) โ‰ซ=maybe f = f x return-maybe : โˆ€ {โ„“}{A : Set โ„“} โ†’ A โ†’ maybe A return-maybe a = just a down-โ‰ก : โˆ€{โ„“}{A : Set โ„“}{a a' : A} โ†’ just a โ‰ก just a' โ†’ a โ‰ก a' down-โ‰ก refl = refl isJust : โˆ€{โ„“}{A : Set โ„“} โ†’ maybe A โ†’ ๐”น isJust nothing = ff isJust (just _) = tt maybe-extract : โˆ€{โ„“}{A : Set โ„“} โ†’ (x : maybe A) โ†’ isJust x โ‰ก tt โ†’ A maybe-extract (just x) p = x maybe-extract nothing () maybe-map : โˆ€{โ„“}{A B : Set โ„“} โ†’ (A โ†’ B) โ†’ maybe A โ†’ maybe B maybe-map f (just x) = just (f x) maybe-map f nothing = nothing
{ "alphanum_fraction": 0.4307116105, "avg_line_length": 27.3846153846, "ext": "agda", "hexsha": "dc93983dd928ef4f4f9b7e8c87d264ede3505463", "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": "maybe.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": "maybe.agda", "max_line_length": 70, "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": "maybe.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 320, "size": 1068 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.Properties.Reduction {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Typed open import Definition.Typed.Properties open import Definition.Typed.RedSteps open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties.Reflexivity open import Definition.LogicalRelation.Properties.Universe open import Definition.LogicalRelation.Properties.Escape open import Tools.Embedding open import Tools.Product import Tools.PropositionalEquality as PE -- Weak head expansion of reducible types. redSubst* : โˆ€ {A B l ฮ“} โ†’ ฮ“ โŠข A โ‡’* B โ†’ ฮ“ โŠฉโŸจ l โŸฉ B โ†’ โˆƒ ฮป ([A] : ฮ“ โŠฉโŸจ l โŸฉ A) โ†’ ฮ“ โŠฉโŸจ l โŸฉ A โ‰ก B / [A] redSubst* D (Uแตฃโ€ฒ lโ€ฒ l< โŠขฮ“) rewrite redU* D = Uแตฃโ€ฒ lโ€ฒ l< โŠขฮ“ , Uโ‚Œ PE.refl redSubst* D (โ„•แตฃ [ โŠขB , โŠขโ„• , Dโ€ฒ ]) = let โŠขA = redFirst* D in โ„•แตฃ ([ โŠขA , โŠขโ„• , D โ‡จ* Dโ€ฒ ]) , ฮนx (โ„•โ‚Œ Dโ€ฒ) redSubst* D (neโ€ฒ K [ โŠขB , โŠขK , Dโ€ฒ ] neK Kโ‰กK) = let โŠขA = redFirst* D in (neโ€ฒ K [ โŠขA , โŠขK , D โ‡จ* Dโ€ฒ ] neK Kโ‰กK) , ฮนx (neโ‚Œ _ [ โŠขB , โŠขK , Dโ€ฒ ] neK Kโ‰กK) redSubst* D (ฮ แตฃโ€ฒ F G [ โŠขB , โŠขฮ FG , Dโ€ฒ ] โŠขF โŠขG Aโ‰กA [F] [G] G-ext) = let โŠขA = redFirst* D in (ฮ แตฃโ€ฒ F G [ โŠขA , โŠขฮ FG , D โ‡จ* Dโ€ฒ ] โŠขF โŠขG Aโ‰กA [F] [G] G-ext) , (ฮ โ‚Œ _ _ Dโ€ฒ Aโ‰กA (ฮป ฯ โŠขฮ” โ†’ reflEq ([F] ฯ โŠขฮ”)) (ฮป ฯ โŠขฮ” [a] โ†’ reflEq ([G] ฯ โŠขฮ” [a]))) redSubst* D (embโ€ฒ 0<1 x) with redSubst* D x redSubst* D (embโ€ฒ 0<1 x) | y , yโ‚ = embโ€ฒ 0<1 y , ฮนx yโ‚ -- Weak head expansion of reducible terms. redSubst*Term : โˆ€ {A t u l ฮ“} โ†’ ฮ“ โŠข t โ‡’* u โˆท A โ†’ ([A] : ฮ“ โŠฉโŸจ l โŸฉ A) โ†’ ฮ“ โŠฉโŸจ l โŸฉ u โˆท A / [A] โ†’ ฮ“ โŠฉโŸจ l โŸฉ t โˆท A / [A] ร— ฮ“ โŠฉโŸจ l โŸฉ t โ‰ก u โˆท A / [A] redSubst*Term tโ‡’u (Uแตฃโ€ฒ .โฐ 0<1 โŠขฮ“) (Uโ‚œ A [ โŠขt , โŠขu , d ] typeA Aโ‰กA [u]) = let [d] = [ โŠขt , โŠขu , d ] [dโ€ฒ] = [ redFirst*Term tโ‡’u , โŠขu , tโ‡’u โ‡จโˆท* d ] q = redSubst* (univ* tโ‡’u) (univEq (Uแตฃโ€ฒ โฐ 0<1 โŠขฮ“) (Uโ‚œ A [d] typeA Aโ‰กA [u])) in Uโ‚œ A [dโ€ฒ] typeA Aโ‰กA (projโ‚ q) , Uโ‚œโ‚Œ A A [dโ€ฒ] [d] typeA typeA Aโ‰กA (projโ‚ q) [u] (projโ‚‚ q) redSubst*Term tโ‡’u (โ„•แตฃ D) (ฮนx (โ„•โ‚œ n [ โŠขu , โŠขn , d ] nโ‰กn prop)) = let Aโ‰กโ„• = subset* (red D) โŠขt = conv (redFirst*Term tโ‡’u) Aโ‰กโ„• tโ‡’uโ€ฒ = conv* tโ‡’u Aโ‰กโ„• in ฮนx (โ„•โ‚œ n [ โŠขt , โŠขn , tโ‡’uโ€ฒ โ‡จโˆท* d ] nโ‰กn prop) , ฮนx (โ„•โ‚œโ‚Œ n n [ โŠขt , โŠขn , tโ‡’uโ€ฒ โ‡จโˆท* d ] [ โŠขu , โŠขn , d ] nโ‰กn (reflNatural-prop prop)) redSubst*Term tโ‡’u (neโ€ฒ K D neK Kโ‰กK) (ฮนx (neโ‚œ k [ โŠขt , โŠขu , d ] (neNfโ‚œ neKโ‚ โŠขk kโ‰กk))) = let Aโ‰กK = subset* (red D) [d] = [ โŠขt , โŠขu , d ] [dโ€ฒ] = [ conv (redFirst*Term tโ‡’u) Aโ‰กK , โŠขu , conv* tโ‡’u Aโ‰กK โ‡จโˆท* d ] in ฮนx (neโ‚œ k [dโ€ฒ] (neNfโ‚œ neKโ‚ โŠขk kโ‰กk)) , ฮนx (neโ‚œโ‚Œ k k [dโ€ฒ] [d] (neNfโ‚œโ‚Œ neKโ‚ neKโ‚ kโ‰กk)) redSubst*Term {A} {t} {u} {l} {ฮ“} tโ‡’u (ฮ แตฃโ€ฒ F G D โŠขF โŠขG Aโ‰กA [F] [G] G-ext) (ฮ โ‚œ f [ โŠขt , โŠขu , d ] funcF fโ‰กf [f] [f]โ‚) = let Aโ‰กฮ FG = subset* (red D) tโ‡’uโ€ฒ = conv* tโ‡’u Aโ‰กฮ FG [d] = [ โŠขt , โŠขu , d ] [dโ€ฒ] = [ conv (redFirst*Term tโ‡’u) Aโ‰กฮ FG , โŠขu , conv* tโ‡’u Aโ‰กฮ FG โ‡จโˆท* d ] in ฮ โ‚œ f [dโ€ฒ] funcF fโ‰กf [f] [f]โ‚ , ฮ โ‚œโ‚Œ f f [dโ€ฒ] [d] funcF funcF fโ‰กf (ฮ โ‚œ f [dโ€ฒ] funcF fโ‰กf [f] [f]โ‚) (ฮ โ‚œ f [d] funcF fโ‰กf [f] [f]โ‚) (ฮป [ฯ] โŠขฮ” [a] โ†’ reflEqTerm ([G] [ฯ] โŠขฮ” [a]) ([f]โ‚ [ฯ] โŠขฮ” [a])) redSubst*Term tโ‡’u (embโ€ฒ 0<1 x) (ฮนx [u]) = let x = redSubst*Term tโ‡’u x [u] in ฮนx (projโ‚ x) , ฮนx (projโ‚‚ x) -- Weak head expansion of reducible types with single reduction step. redSubst : โˆ€ {A B l ฮ“} โ†’ ฮ“ โŠข A โ‡’ B โ†’ ฮ“ โŠฉโŸจ l โŸฉ B โ†’ โˆƒ ฮป ([A] : ฮ“ โŠฉโŸจ l โŸฉ A) โ†’ ฮ“ โŠฉโŸจ l โŸฉ A โ‰ก B / [A] redSubst Aโ‡’B [B] = redSubst* (Aโ‡’B โ‡จ id (escape [B])) [B] -- Weak head expansion of reducible terms with single reduction step. redSubstTerm : โˆ€ {A t u l ฮ“} โ†’ ฮ“ โŠข t โ‡’ u โˆท A โ†’ ([A] : ฮ“ โŠฉโŸจ l โŸฉ A) โ†’ ฮ“ โŠฉโŸจ l โŸฉ u โˆท A / [A] โ†’ ฮ“ โŠฉโŸจ l โŸฉ t โˆท A / [A] ร— ฮ“ โŠฉโŸจ l โŸฉ t โ‰ก u โˆท A / [A] redSubstTerm tโ‡’u [A] [u] = redSubst*Term (tโ‡’u โ‡จ id (escapeTerm [A] [u])) [A] [u]
{ "alphanum_fraction": 0.4769661491, "avg_line_length": 39.29, "ext": "agda", "hexsha": "e51e2cecb4c5637debdc2760cdc95800aebff4fc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "loic-p/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/Properties/Reduction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "loic-p/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/Properties/Reduction.agda", "max_line_length": 88, "max_stars_count": null, "max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "loic-p/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/Properties/Reduction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2059, "size": 3929 }
module Preliminary where open import Prelude public โˆƒ_ : โˆ€ {a b} {A : Set a} (B : A โ†’ Set b) โ†’ Set (a โŠ” b) โˆƒ_ = ฮฃ _ data IsYes {a} {P : Set a} : Dec P โ†’ Set a where yes : (p : P) โ†’ IsYes (yes p) getProof : โˆ€ {a} {P : Set a} โ†’ {d : Dec P} โ†’ IsYes d โ†’ P getProof (yes p) = p add-zero : โˆ€ n โ†’ n โ‰ก n +N 0 add-zero zero = refl add-zero (suc n) = cong suc (add-zero n) _โ‰ข_ : โˆ€ {โ„“} {A : Set โ„“} โ†’ A โ†’ A โ†’ Set โ„“ a โ‰ข b = ยฌ (a โ‰ก b)
{ "alphanum_fraction": 0.4823788546, "avg_line_length": 21.619047619, "ext": "agda", "hexsha": "bb5b5d5331f490f05cb69f77e267ea46aa50ab6b", "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/Preliminary.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/Preliminary.agda", "max_line_length": 58, "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/Preliminary.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 205, "size": 454 }
-- Andreas, 2014-08-19, issue reported by zcarterc -- {-# OPTIONS -v tc.meta.assign:10 -v tc.constr.findInScope:10 #-} -- {-# OPTIONS -v tc.constr.findInScope:49 #-} -- {-# OPTIONS --show-implicit #-} module Issue1254 where open import Agda.Primitive record Inhabited {i : Level} (carrier : Set i) : Set i where field elem : carrier open Inhabited {{...}} record Wrap {i : Level} (carrier : Set i) : Set i where field wrap-inhabited : Inhabited carrier instance wrap-as-inhabited : โˆ€ {i : Level} {carrier : Set i} โ†’ Wrap carrier โ†’ Inhabited carrier wrap-as-inhabited cat = Wrap.wrap-inhabited cat postulate Nat : Set one : Nat instance monoid-Nat : Wrap Nat monoid-Nat = record { wrap-inhabited = record { elem = one } } -- This is what caused the crash. op : Nat op = elem
{ "alphanum_fraction": 0.6687344913, "avg_line_length": 23.7058823529, "ext": "agda", "hexsha": "f6a4e63425593067f60628fea27240679d7b8806", "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/Issue1254.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/Issue1254.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/Issue1254.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": 250, "size": 806 }
{-# OPTIONS --cubical --no-import-sorts --safe --experimental-lossy-unification #-} module Cubical.Algebra.Group.EilenbergMacLane1 where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.GroupoidLaws renaming (assoc to โˆ™assoc) open import Cubical.Foundations.Path open import Cubical.Foundations.HLevels open import Cubical.Foundations.Univalence open import Cubical.Data.Unit open import Cubical.Data.Sigma open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Homotopy.Connected open import Cubical.HITs.Truncation as Trunc renaming (rec to trRec; elim to trElim) open import Cubical.HITs.EilenbergMacLane1 private variable โ„“ : Level module _ (Gฬ‚ : Group โ„“) where private G = fst Gฬ‚ open GroupStr (snd Gฬ‚) emloop-id : emloop 1g โ‰ก refl emloop-id = emloop 1g โ‰กโŸจ rUnit (emloop 1g) โŸฉ emloop 1g โˆ™ refl โ‰กโŸจ cong (emloop 1g โˆ™_) (rCancel (emloop 1g) โปยน) โŸฉ emloop 1g โˆ™ (emloop 1g โˆ™ (emloop 1g) โปยน) โ‰กโŸจ โˆ™assoc _ _ _ โŸฉ (emloop 1g โˆ™ emloop 1g) โˆ™ (emloop 1g) โปยน โ‰กโŸจ cong (_โˆ™ emloop 1g โปยน) ((emloop-comp Gฬ‚ 1g 1g) โปยน) โŸฉ emloop (1g ยท 1g) โˆ™ (emloop 1g) โปยน โ‰กโŸจ cong (ฮป g โ†’ emloop {Group = Gฬ‚} g โˆ™ (emloop 1g) โปยน) (rid 1g) โŸฉ emloop 1g โˆ™ (emloop 1g) โปยน โ‰กโŸจ rCancel (emloop 1g) โŸฉ refl โˆŽ emloop-inv : (g : G) โ†’ emloop (inv g) โ‰ก (emloop g) โปยน emloop-inv g = emloop (inv g) โ‰กโŸจ rUnit (emloop (inv g)) โŸฉ emloop (inv g) โˆ™ refl โ‰กโŸจ cong (emloop (inv g) โˆ™_) (rCancel (emloop g) โปยน) โŸฉ emloop (inv g) โˆ™ (emloop g โˆ™ (emloop g) โปยน) โ‰กโŸจ โˆ™assoc _ _ _ โŸฉ (emloop (inv g) โˆ™ emloop g) โˆ™ (emloop g) โปยน โ‰กโŸจ cong (_โˆ™ emloop g โปยน) ((emloop-comp Gฬ‚ (inv g) g) โปยน) โŸฉ emloop (inv g ยท g) โˆ™ (emloop g) โปยน โ‰กโŸจ cong (ฮป h โ†’ emloop {Group = Gฬ‚} h โˆ™ (emloop g) โปยน) (invl g) โŸฉ emloop 1g โˆ™ (emloop g) โปยน โ‰กโŸจ cong (_โˆ™ (emloop g) โปยน) emloop-id โŸฉ refl โˆ™ (emloop g) โปยน โ‰กโŸจ (lUnit ((emloop g) โปยน)) โปยน โŸฉ (emloop g) โปยน โˆŽ isGroupoidEMโ‚ : isGroupoid (EMโ‚ Gฬ‚) isGroupoidEMโ‚ = emsquash isConnectedEMโ‚ : isConnected 2 (EMโ‚ Gฬ‚) isConnectedEMโ‚ = โˆฃ embase โˆฃ , h where h : (y : hLevelTrunc 2 (EMโ‚ Gฬ‚)) โ†’ โˆฃ embase โˆฃ โ‰ก y h = trElim (ฮป y โ†’ isOfHLevelSuc 1 (isOfHLevelTrunc 2 โˆฃ embase โˆฃ y)) (elimProp Gฬ‚ (ฮป x โ†’ isOfHLevelTrunc 2 โˆฃ embase โˆฃ โˆฃ x โˆฃ) refl) {- since we write composition in diagrammatic order, and function composition in the other order, we need right multiplication here -} rightEquiv : (g : G) โ†’ G โ‰ƒ G rightEquiv g = isoToEquiv isom where isom : Iso G G isom .Iso.fun = _ยท g isom .Iso.inv = _ยท inv g isom .Iso.rightInv h = (h ยท inv g) ยท g โ‰กโŸจ (assoc h (inv g) g) โปยน โŸฉ h ยท inv g ยท g โ‰กโŸจ cong (h ยท_) (invl g) โŸฉ h ยท 1g โ‰กโŸจ rid h โŸฉ h โˆŽ isom .Iso.leftInv h = (h ยท g) ยท inv g โ‰กโŸจ (assoc h g (inv g)) โปยน โŸฉ h ยท g ยท inv g โ‰กโŸจ cong (h ยท_) (invr g) โŸฉ h ยท 1g โ‰กโŸจ rid h โŸฉ h โˆŽ compRightEquiv : (g h : G) โ†’ compEquiv (rightEquiv g) (rightEquiv h) โ‰ก rightEquiv (g ยท h) compRightEquiv g h = equivEq (funExt (ฮป x โ†’ (assoc x g h) โปยน)) CodesSet : EMโ‚ Gฬ‚ โ†’ hSet โ„“ CodesSet = rec Gฬ‚ (isOfHLevelTypeOfHLevel 2) (G , is-set) RE REComp where RE : (g : G) โ†’ Path (hSet โ„“) (G , is-set) (G , is-set) RE g = ฮฃโ‰กProp (ฮป X โ†’ isPropIsOfHLevel {A = X} 2) (ua (rightEquiv g)) lemmaโ‚ : (g h : G) โ†’ Square (ua (rightEquiv g)) (ua (rightEquiv (g ยท h))) refl (ua (rightEquiv h)) lemmaโ‚ g h = invEq (Squareโ‰ƒdoubleComp (ua (rightEquiv g)) (ua (rightEquiv (g ยท h))) refl (ua (rightEquiv h))) (ua (rightEquiv g) โˆ™ ua (rightEquiv h) โ‰กโŸจ (uaCompEquiv (rightEquiv g) (rightEquiv h)) โปยน โŸฉ ua (compEquiv (rightEquiv g) (rightEquiv h)) โ‰กโŸจ cong ua (compRightEquiv g h) โŸฉ ua (rightEquiv (g ยท h)) โˆŽ) lemmaโ‚‚ : {Aโ‚€โ‚€ Aโ‚€โ‚ : hSet โ„“} (pโ‚€โ‚‹ : Aโ‚€โ‚€ โ‰ก Aโ‚€โ‚) {Aโ‚โ‚€ Aโ‚โ‚ : hSet โ„“} (pโ‚โ‚‹ : Aโ‚โ‚€ โ‰ก Aโ‚โ‚) (pโ‚‹โ‚€ : Aโ‚€โ‚€ โ‰ก Aโ‚โ‚€) (pโ‚‹โ‚ : Aโ‚€โ‚ โ‰ก Aโ‚โ‚) (s : Square (cong fst pโ‚€โ‚‹) (cong fst pโ‚โ‚‹) (cong fst pโ‚‹โ‚€) (cong fst pโ‚‹โ‚)) โ†’ Square pโ‚€โ‚‹ pโ‚โ‚‹ pโ‚‹โ‚€ pโ‚‹โ‚ fst (lemmaโ‚‚ pโ‚€โ‚‹ pโ‚โ‚‹ pโ‚‹โ‚€ pโ‚‹โ‚ s i j) = s i j snd (lemmaโ‚‚ pโ‚€โ‚‹ pโ‚โ‚‹ pโ‚‹โ‚€ pโ‚‹โ‚ s i j) = isSetโ†’SquareP {A = (ฮป i j โ†’ isSet (s i j))} (ฮป i j โ†’ isPropโ†’isSet (isPropIsOfHLevel 2)) (cong snd pโ‚€โ‚‹) (cong snd pโ‚โ‚‹) (cong snd pโ‚‹โ‚€) (cong snd pโ‚‹โ‚) i j REComp : (g h : G) โ†’ Square (RE g) (RE (g ยท h)) refl (RE h) REComp g h = lemmaโ‚‚ (RE g) (RE (g ยท h)) refl (RE h) (lemmaโ‚ g h) Codes : EMโ‚ Gฬ‚ โ†’ Type โ„“ Codes x = CodesSet x .fst encode : (x : EMโ‚ Gฬ‚) โ†’ embase โ‰ก x โ†’ Codes x encode x p = subst Codes p 1g decode : (x : EMโ‚ Gฬ‚) โ†’ Codes x โ†’ embase โ‰ก x decode = elimSet Gฬ‚ (ฮป x โ†’ isOfHLevelฮ  2 (ฮป c โ†’ isGroupoidEMโ‚ (embase) x)) emloop ฮป g โ†’ uaโ†’ ฮป h โ†’ emcomp h g decode-encode : (x : EMโ‚ Gฬ‚) (p : embase โ‰ก x) โ†’ decode x (encode x p) โ‰ก p decode-encode x p = J (ฮป y q โ†’ decode y (encode y q) โ‰ก q) (emloop (transport refl 1g) โ‰กโŸจ cong emloop (transportRefl 1g) โŸฉ emloop 1g โ‰กโŸจ emloop-id โŸฉ refl โˆŽ) p encode-decode : (x : EMโ‚ Gฬ‚) (c : Codes x) โ†’ encode x (decode x c) โ‰ก c encode-decode = elimProp Gฬ‚ (ฮป x โ†’ isOfHLevelฮ  1 (ฮป c โ†’ CodesSet x .snd _ _)) ฮป g โ†’ encode embase (decode embase g) โ‰กโŸจ refl โŸฉ encode embase (emloop g) โ‰กโŸจ refl โŸฉ transport (ua (rightEquiv g)) 1g โ‰กโŸจ uaฮฒ (rightEquiv g) 1g โŸฉ 1g ยท g โ‰กโŸจ lid g โŸฉ g โˆŽ ฮฉEMโ‚Iso : Iso (Path (EMโ‚ Gฬ‚) embase embase) G Iso.fun ฮฉEMโ‚Iso = encode embase Iso.inv ฮฉEMโ‚Iso = emloop Iso.rightInv ฮฉEMโ‚Iso = encode-decode embase Iso.leftInv ฮฉEMโ‚Iso = decode-encode embase ฮฉEMโ‚โ‰ก : (Path (EMโ‚ Gฬ‚) embase embase) โ‰ก G ฮฉEMโ‚โ‰ก = isoToPath ฮฉEMโ‚Iso
{ "alphanum_fraction": 0.523217891, "avg_line_length": 42.3618421053, "ext": "agda", "hexsha": "93f0566b542de71d67612d1236579e9c7b10f84e", "lang": "Agda", "max_forks_count": 134, "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_path": "Cubical/Algebra/Group/EilenbergMacLane1.agda", "max_issues_count": 584, "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_path": "Cubical/Algebra/Group/EilenbergMacLane1.agda", "max_line_length": 95, "max_stars_count": 301, "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_path": "Cubical/Algebra/Group/EilenbergMacLane1.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "num_tokens": 2529, "size": 6439 }
data A (B : Set) : Set where module C where record D : Set where module E (F : Set) (G : A F) where open C public using (module D) module H (I : Set) (J : A I) where open E I J using ()
{ "alphanum_fraction": 0.6062176166, "avg_line_length": 21.4444444444, "ext": "agda", "hexsha": "913998e71ce86d724990b5d435f544ce94eb6a4e", "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/Issue1282.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/Issue1282.agda", "max_line_length": 34, "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/Issue1282.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": 69, "size": 193 }
module noetherian where open import sn-calculus open import Esterel.Lang open import Esterel.Lang.Properties open import Esterel.Context open import Esterel.Context.Properties open import Esterel.Environment open import Esterel.Variable.Signal as Signal using (Signal) open import Esterel.Variable.Shared as SharedVar using (SharedVar) open import Esterel.Variable.Sequential as SeqVar using (SeqVar) open import Data.Nat as Nat using (โ„• ; zero ; suc ; _+_ ; _>_ ; _โ‰คโ€ฒ_ ; _โ‰ค_ ; _*_ ; โ‰คโ€ฒ-refl) open import Data.Nat.Properties using (sโ‰คโ€ฒs ; zโ‰คโ€ฒn ; mโ‰คโ€ฒm+n ; nโ‰คโ€ฒm+n ; โ‰คโ‡’predโ‰ค) open import Data.Nat.Properties.Simple using (+-comm ; +-assoc ; +-suc) open import Data.MoreNatProp open import Data.Sum as Sum using (injโ‚ ; injโ‚‚ ; _โŠŽ_) open import Data.Maybe using (just ; nothing) open import Data.Product using (_ร—_ ; _,_ ; _,โ€ฒ_ ; projโ‚) open import Agda.Builtin.Equality using (refl ; _โ‰ก_) open import Data.List using (List ; _โˆท_ ; []) open import Data.Bool using (Bool ; true ; false) open import Relation.Nullary.Decidable using (โŒŠ_โŒ‹) open import Relation.Nullary using (Dec ; yes ; no ; ยฌ_) open import Relation.Binary.PropositionalEquality using (sym ; inspect ; Reveal_ยท_is_ ; trans ; cong) open import Data.Empty using (โŠฅ-elim ; โŠฅ) SM = SigMap.Map Signal.Status ShM = ShrMap.Map (SharedVar.Status ร— โ„•) is-unknownp : Signal.Status -> Bool is-unknownp x = โŒŠ x Signal.โ‰Ÿโ‚›โ‚œ Signal.unknown โŒ‹ is-notreadyp : SharedVar.Status ร— โ„• -> Bool is-notreadyp (SharedVar.ready , _) = false is-notreadyp (SharedVar.new , _) = true is-notreadyp (SharedVar.old , _) = true is-notreadyp-status : SharedVar.Status -> Bool is-notreadyp-status SharedVar.ready = false is-notreadyp-status SharedVar.new = true is-notreadyp-status SharedVar.old = true is-notreadyp' : SharedVar.Status ร— โ„• -> Bool is-notreadyp' x = is-notreadyp-status (projโ‚ x) hunch : โˆ€ x -> is-notreadyp x โ‰ก is-notreadyp' x hunch (SharedVar.ready , projโ‚ƒ) = refl hunch (SharedVar.new , projโ‚ƒ) = refl hunch (SharedVar.old , projโ‚ƒ) = refl numstepsSig : SM -> โ„• numstepsSig m = SigMap.count is-unknownp m numstepsShr : ShM -> โ„• numstepsShr m = ShrMap.count is-notreadyp m numstepsฮธ : Env -> โ„• numstepsฮธ (ฮ˜ sigโ‚ shrโ‚ varโ‚) = (numstepsSig sigโ‚) + (numstepsShr shrโ‚) โˆฅ_โˆฅs : Term -> โ„• โˆฅ nothin โˆฅs = 0 โˆฅ pause โˆฅs = 0 {- one for stepping to ฯ ฮธ p one for (maybe) setting S to absent one for (maybe) this ฯ mergeing with another one (same idea for `shared` and `var`) -} โˆฅ (signl S p) โˆฅs = suc (suc (suc (โˆฅ p โˆฅs))) โˆฅ (present S โˆฃโ‡’ p โˆฃโ‡’ q) โˆฅs = suc (โˆฅ p โˆฅs + โˆฅ q โˆฅs) โˆฅ (emit S) โˆฅs = 1 โˆฅ (p โˆฅ q) โˆฅs = suc (โˆฅ p โˆฅs + โˆฅ q โˆฅs) โˆฅ (loop p) โˆฅs = suc (suc (โˆฅ p โˆฅs + โˆฅ p โˆฅs)) โˆฅ (loopหข p q) โˆฅs = suc (โˆฅ p โˆฅs + โˆฅ q โˆฅs) โˆฅ (p >> q) โˆฅs = suc (โˆฅ p โˆฅs + โˆฅ q โˆฅs) โˆฅ (suspend p S) โˆฅs = suc (โˆฅ p โˆฅs) โˆฅ (trap p) โˆฅs = suc (โˆฅ p โˆฅs) โˆฅ (exit x) โˆฅs = 0 โˆฅ (shared s โ‰” e in: p) โˆฅs = suc (suc (suc (โˆฅ p โˆฅs))) โˆฅ (s โ‡ e) โˆฅs = 1 โˆฅ (var x โ‰” e in: p) โˆฅs = suc (suc (โˆฅ p โˆฅs)) โˆฅ (x โ‰” e) โˆฅs = 1 โˆฅ (if x โˆฃโ‡’ p โˆฃโ‡’ q) โˆฅs = suc (โˆฅ p โˆฅs + โˆฅ q โˆฅs) โˆฅ (ฯโŸจ ฮธ , A โŸฉยท p) โˆฅs = suc (numstepsฮธ ฮธ + โˆฅ p โˆฅs) arith1 : โˆ€ a b c -> suc b โ‰คโ€ฒ c -> suc (suc (a + b)) โ‰คโ€ฒ suc (a + c) arith1 a b c sucbโ‰คโ€ฒc rewrite sym (+-suc a b) = sโ‰คโ€ฒs (โ‰คโ€ฒ+r {z = a} sucbโ‰คโ€ฒc) arith2 : โˆ€ x y z -> suc x โ‰คโ€ฒ y -> suc (suc (x + z)) โ‰คโ€ฒ suc (y + z) arith2 x y z sucxโ‰คโ€ฒy = sโ‰คโ€ฒs (โ‰คโ€ฒ+l{z = z} sucxโ‰คโ€ฒy) arith3 : โˆ€ x y z -> suc x โ‰คโ€ฒ y -> suc (suc (z + x)) โ‰คโ€ฒ suc (z + y) arith3 x y z sucxโ‰คโ€ฒy rewrite sym (+-suc z x) = sโ‰คโ€ฒs (โ‰คโ€ฒ+r {z = z} sucxโ‰คโ€ฒy) arith4 : โˆ€ x y z -> suc (suc x + y + z) โ‰คโ€ฒ suc (x + suc y + z) arith4 x y z rewrite +-suc x y = sโ‰คโ€ฒs โ‰คโ€ฒ-refl arith5 : โˆ€ x y -> suc x โ‰คโ€ฒ y -> suc (suc (suc (x + x))) โ‰คโ€ฒ suc (suc (y + y)) arith5 x y sucxโ‰คโ€ฒy rewrite sym (+-suc x x) = sโ‰คโ€ฒs (sโ‰คโ€ฒs (โ‰คโ€ฒ+b x (suc x) y y (sucโ‰คโ€ฒโ‡’โ‰คโ€ฒ x y sucxโ‰คโ€ฒy) sucxโ‰คโ€ฒy)) decomposeโˆฅโˆฅs : โˆ€ E p -> โˆฅ E โŸฆ p โŸงe โˆฅs โ‰ก โˆฅ E โŸฆ nothin โŸงe โˆฅs + โˆฅ p โˆฅs decomposeโˆฅโˆฅs [] p = refl decomposeโˆฅโˆฅs (x โˆท E) p with decomposeโˆฅโˆฅs E decomposeโˆฅโˆฅs (eparโ‚ q โˆท E) p | R rewrite R p | +-assoc (โˆฅ E โŸฆ nothin โŸงe โˆฅs) โˆฅ p โˆฅs โˆฅ q โˆฅs | +-assoc (โˆฅ E โŸฆ nothin โŸงe โˆฅs) โˆฅ q โˆฅs โˆฅ p โˆฅs | +-comm (โˆฅ p โˆฅs) (โˆฅ q โˆฅs) = cong suc refl decomposeโˆฅโˆฅs (eparโ‚‚ p โˆท E) pโ‚ | R rewrite R pโ‚ | +-assoc โˆฅ p โˆฅs โˆฅ E โŸฆ nothin โŸงe โˆฅs โˆฅ pโ‚ โˆฅs = cong suc refl decomposeโˆฅโˆฅs (eseq q โˆท E) p | R rewrite R p | +-assoc (โˆฅ E โŸฆ nothin โŸงe โˆฅs) โˆฅ p โˆฅs โˆฅ q โˆฅs | +-assoc (โˆฅ E โŸฆ nothin โŸงe โˆฅs) โˆฅ q โˆฅs โˆฅ p โˆฅs | +-comm (โˆฅ p โˆฅs) (โˆฅ q โˆฅs) = cong suc refl decomposeโˆฅโˆฅs (eloopหข q โˆท E) p | R rewrite R p | +-assoc (โˆฅ E โŸฆ nothin โŸงe โˆฅs) โˆฅ p โˆฅs โˆฅ q โˆฅs | +-assoc (โˆฅ E โŸฆ nothin โŸงe โˆฅs) โˆฅ q โˆฅs โˆฅ p โˆฅs | +-comm (โˆฅ p โˆฅs) (โˆฅ q โˆฅs) = cong suc refl decomposeโˆฅโˆฅs (esuspend S โˆท E) p | R rewrite R p = refl decomposeโˆฅโˆฅs (etrap โˆท E) p | R rewrite R p = refl eplugโ‰ค : โˆ€ p q E -> โˆฅ p โˆฅs โ‰คโ€ฒ โˆฅ q โˆฅs -> โˆฅ E โŸฆ p โŸงe โˆฅs โ‰คโ€ฒ โˆฅ E โŸฆ q โŸงe โˆฅs eplugโ‰ค p q E โˆฅpโˆฅsโ‰คโ€ฒโˆฅqโˆฅs rewrite decomposeโˆฅโˆฅs E p | decomposeโˆฅโˆฅs E q = โ‰คโ€ฒ+r{z = โˆฅ E โŸฆ nothin โŸงe โˆฅs} โˆฅpโˆฅsโ‰คโ€ฒโˆฅqโˆฅs eplug< : โˆ€ p q E -> suc โˆฅ p โˆฅs โ‰คโ€ฒ โˆฅ q โˆฅs -> suc (โˆฅ (E โŸฆ p โŸงe) โˆฅs) โ‰คโ€ฒ (โˆฅ (E โŸฆ q โŸงe) โˆฅs) eplug< p q E โˆฅpโˆฅs<โˆฅqโˆฅs rewrite decomposeโˆฅโˆฅs E p | decomposeโˆฅโˆฅs E q | sym (+-suc โˆฅ E โŸฆ nothin โŸงe โˆฅs โˆฅ p โˆฅs) = โ‰คโ€ฒ+r{z = โˆฅ E โŸฆ nothin โŸงe โˆฅs} โˆฅpโˆฅs<โˆฅqโˆฅs valuemax-norm : โˆ€ {p q} -> (donep : done p) -> (doneq : done q) -> (haltedporq : halted p โŠŽ halted q) -> โˆฅ value-max donep doneq haltedporq โˆฅs โ‰คโ€ฒ โˆฅ p โˆฅs + โˆฅ q โˆฅs valuemax-norm (dhalted hnothin) (dhalted p/haltedโ‚) _ = โ‰คโ€ฒ-refl valuemax-norm (dhalted (hexit n)) (dhalted hnothin) _ = โ‰คโ€ฒ-refl valuemax-norm (dhalted (hexit n)) (dhalted (hexit m)) _ = โ‰คโ€ฒ-refl valuemax-norm (dhalted hnothin) (dpaused p/paused) _ = โ‰คโ€ฒ-refl valuemax-norm{q = q} (dhalted (hexit n)) (dpaused p/paused) _ = mโ‰คโ€ฒm+n 0 โˆฅ q โˆฅs valuemax-norm{p = p} (dpaused p/paused) (dhalted hnothin) _ = mโ‰คโ€ฒm+n โˆฅ p โˆฅs 0 valuemax-norm (dpaused p/paused) (dhalted (hexit n)) _ = zโ‰คโ€ฒn valuemax-norm (dpaused p/paused) (dpaused p/pausedโ‚) (injโ‚ x) = โŠฅ-elim (halted-paused-disjoint x p/paused) valuemax-norm (dpaused p/paused) (dpaused p/pausedโ‚) (injโ‚‚ y) = โŠฅ-elim (halted-paused-disjoint y p/pausedโ‚) halted-norm : โˆ€ {p} -> (haltedp : halted p) -> โˆฅ โ†“ haltedp โˆฅs โ‰ก 0 halted-norm hnothin = refl halted-norm (hexit zero) = refl halted-norm (hexit (suc n)) = refl noetherianโ‚ : โˆ€ {p q} -> p snโŸถโ‚ q -> (suc (โˆฅ q โˆฅs)) โ‰คโ€ฒ (โˆฅ p โˆฅs) noetherianโ‚ (rpar-done-right{p}{q} haltedp doneq) = sโ‰คโ€ฒs (valuemax-norm (dhalted haltedp) doneq (injโ‚ haltedp)) noetherianโ‚ (rpar-done-left{p}{q} donep haltedq) = sโ‰คโ€ฒs (valuemax-norm donep (dhalted haltedq) (injโ‚‚ haltedq)) noetherianโ‚ (ris-present{ฮธ}{S = S}{p = p}{q = q}{E = E} Sโˆˆ x xโ‚) with unplug xโ‚ ... | refl = arith1 (numstepsฮธ ฮธ) โˆฅ E โŸฆ p โŸงe โˆฅs โˆฅ E โŸฆ present S โˆฃโ‡’ p โˆฃโ‡’ q โŸงe โˆฅs (eplug< p (present S โˆฃโ‡’ p โˆฃโ‡’ q) E (sโ‰คโ€ฒs (mโ‰คโ€ฒm+n โˆฅ p โˆฅs โˆฅ q โˆฅs))) noetherianโ‚ (ris-absent{ฮธ}{S}{p = p}{q = q}{E = E} Sโˆˆ x xโ‚) with unplug xโ‚ ... | refl = arith1 (numstepsฮธ ฮธ) โˆฅ E โŸฆ q โŸงe โˆฅs โˆฅ E โŸฆ present S โˆฃโ‡’ p โˆฃโ‡’ q โŸงe โˆฅs (eplug< q (present S โˆฃโ‡’ p โˆฃโ‡’ q) E (sโ‰คโ€ฒs (nโ‰คโ€ฒm+n โˆฅ p โˆฅs โˆฅ q โˆฅs))) noetherianโ‚ (remit {ฮธ} {_} {S} {E} Sโˆˆ ยฌSโ‰กa x) with unplug x noetherianโ‚ (remit {ฮธ} {_} {S} {E} Sโˆˆ ยฌSโ‰กa x) | refl with is-unknownp (SigMap.lookup{k = S} (sig ฮธ) Sโˆˆ) | inspect is-unknownp (SigMap.lookup{k = S} (sig ฮธ) Sโˆˆ) | SigMap.lookup{k = S} (sig ฮธ) Sโˆˆ | inspect (SigMap.lookup{k = S} (sig ฮธ)) Sโˆˆ ... | true | Reveal_ยท_is_.[ eq1 ] | Signal.present | Reveal_ยท_is_.[ eq ] rewrite eq = โŠฅ-elim (false-not-true eq1) where false-not-true : false โ‰ก true -> โŠฅ false-not-true () ... | false | Reveal_ยท_is_.[ eq1 ] | Signal.absent | Reveal_ยท_is_.[ eq ] = โŠฅ-elim (ยฌSโ‰กa refl) ... | true | Reveal_ยท_is_.[ eq1 ] | Signal.absent | Reveal_ยท_is_.[ eq ] = โŠฅ-elim (ยฌSโ‰กa refl) ... | false | Reveal_ยท_is_.[ eq1 ] | Signal.unknown | Reveal_ยท_is_.[ eq ] rewrite eq = โŠฅ-elim (true-not-false eq1) where true-not-false : true โ‰ก false -> โŠฅ true-not-false () noetherianโ‚ (remit {ฮธ} {.(E โŸฆ emit S โŸงe)} {S} {E} Sโˆˆ ยฌSโ‰กa x) | refl | false | Reveal_ยท_is_.[ eq1 ] | Signal.present | Reveal_ยท_is_.[ eq ] with sym (SigMap.getput-m S (sig ฮธ) Sโˆˆ) ... | updateฮธ-S-to-presentโ‰กฮธ rewrite eq | updateฮธ-S-to-presentโ‰กฮธ = arith1 (numstepsฮธ ฮธ) โˆฅ E โŸฆ nothin โŸงe โˆฅs โˆฅ E โŸฆ emit S โŸงe โˆฅs (eplug< nothin (emit S) E โ‰คโ€ฒ-refl) noetherianโ‚ (remit {ฮธ} {.(E โŸฆ emit S โŸงe)} {S} {E} Sโˆˆ ยฌSโ‰กa x) | refl | true | Reveal_ยท_is_.[ eq1 ] | Signal.unknown | Reveal_ยท_is_.[ eq ] rewrite SigMap.change-one-count-goes-down (sig ฮธ) is-unknownp S Sโˆˆ eq1 Signal.present refl = sโ‰คโ€ฒs (sโ‰คโ€ฒs (โ‰คโ€ฒ+r {z = numstepsฮธ (set-sig{S} ฮธ Sโˆˆ Signal.present)} (eplugโ‰ค nothin (emit S) E (Nat.โ‰คโ€ฒ-step โ‰คโ€ฒ-refl)))) noetherianโ‚ rloop-unroll = โ‰คโ€ฒ-refl noetherianโ‚ rseq-done = โ‰คโ€ฒ-refl noetherianโ‚ (rseq-exit{q}) = sโ‰คโ€ฒs zโ‰คโ€ฒn noetherianโ‚ (rloopหข-exit{q}) = sโ‰คโ€ฒs zโ‰คโ€ฒn noetherianโ‚ (rsuspend-done x) = โ‰คโ€ฒ-refl noetherianโ‚ (rtrap-done{p} haltedp) rewrite halted-norm haltedp = sโ‰คโ€ฒs zโ‰คโ€ฒn noetherianโ‚ (rraise-signal{p}{S}) = ans where oneunknownโ‰ก1 : โˆ€ S -> numstepsฮธ (ฮ˜ SigMap.[ S โ†ฆ Signal.unknown ] [] []) โ‰ก 1 oneunknownโ‰ก1 (zero Signal.โ‚›) = refl oneunknownโ‰ก1 (suc n Signal.โ‚›) = oneunknownโ‰ก1 (n Signal.โ‚›) ans : suc (suc (numstepsฮธ (ฮ˜ SigMap.[ S โ†ฆ Signal.unknown ] [] []) + โˆฅ p โˆฅs)) โ‰คโ€ฒ suc (suc (suc โˆฅ p โˆฅs)) ans rewrite oneunknownโ‰ก1 S = โ‰คโ€ฒ-refl noetherianโ‚ (rraise-shared{ฮธ}{_}{s}{e}{p}{E} e' x) with unplug x ... | refl = arith1 (numstepsฮธ ฮธ) โˆฅ E โŸฆ ฯโŸจ [s,ฮดe]-env s (ฮด e') , WAIT โŸฉยท p โŸงe โˆฅs โˆฅ E โŸฆ shared s โ‰” e in: p โŸงe โˆฅs (eplug< (ฯโŸจ [s,ฮดe]-env s (ฮด e') , WAIT โŸฉยท p) (shared s โ‰” e in: p) E newฮธโ‰ก1) where silly : โˆ€ s -> numstepsฮธ ([s,ฮดe]-env s (ฮด e')) โ‰ก 1 silly (zero SharedVar.โ‚›โ‚•) = refl silly (suc xโ‚ SharedVar.โ‚›โ‚•) = silly (xโ‚ SharedVar.โ‚›โ‚•) newฮธโ‰ก1 : suc (suc (numstepsฮธ ([s,ฮดe]-env s (ฮด e')) + โˆฅ p โˆฅs)) โ‰คโ€ฒ suc (suc (suc โˆฅ p โˆฅs)) newฮธโ‰ก1 rewrite silly s = โ‰คโ€ฒ-refl noetherianโ‚ (rset-shared-value-old{ฮธ}{_}{s}{e}{E} e' sโˆˆ ฮธ[s]โ‰กold x) with unplug x ... | refl = ans where snotready : is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโˆˆ) โ‰ก true snotready rewrite hunch (ShrMap.lookup{k = s} (shr ฮธ) sโˆˆ) | ฮธ[s]โ‰กold = refl ฮธsame : numstepsฮธ (set-shr{s} ฮธ sโˆˆ (SharedVar.new) (ฮด e')) โ‰ก numstepsฮธ ฮธ ฮธsame rewrite ShrMap.change-nothing-count-stays-same (shr ฮธ) is-notreadyp s sโˆˆ (SharedVar.new , ฮด e') snotready = refl ans : suc โˆฅ (ฯโŸจ (set-shr{s} ฮธ sโˆˆ (SharedVar.new) (ฮด e')) , GO โŸฉยท E โŸฆ nothin โŸงe) โˆฅs โ‰คโ€ฒ โˆฅ ฯโŸจ ฮธ , GO โŸฉยท E โŸฆ s โ‡ e โŸงe โˆฅs ans rewrite ฮธsame = arith1 (numstepsฮธ ฮธ) โˆฅ E โŸฆ nothin โŸงe โˆฅs โˆฅ E โŸฆ s โ‡ e โŸงe โˆฅs (eplug< nothin (s โ‡ e) E โ‰คโ€ฒ-refl) noetherianโ‚ (rset-shared-value-new{ฮธ}{_}{s}{e}{E} e' sโˆˆ ฮธ[s]โ‰กnew x) with unplug x ... | refl = ans where snotready : is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโˆˆ) โ‰ก true snotready rewrite hunch (ShrMap.lookup{k = s} (shr ฮธ) sโˆˆ) | ฮธ[s]โ‰กnew = refl ฮธsame : numstepsฮธ (set-shr{s} ฮธ sโˆˆ (SharedVar.new) (shr-vals{s} ฮธ sโˆˆ + ฮด e')) โ‰ก numstepsฮธ ฮธ ฮธsame rewrite ShrMap.change-nothing-count-stays-same (shr ฮธ) is-notreadyp s sโˆˆ (SharedVar.new , shr-vals{s} ฮธ sโˆˆ + ฮด e') snotready = refl ans : suc โˆฅ (ฯโŸจ (set-shr{s} ฮธ sโˆˆ (SharedVar.new) (shr-vals{s} ฮธ sโˆˆ + ฮด e')) , GO โŸฉยท E โŸฆ nothin โŸงe) โˆฅs โ‰คโ€ฒ โˆฅ ฯโŸจ ฮธ , GO โŸฉยท E โŸฆ s โ‡ e โŸงe โˆฅs ans rewrite ฮธsame = arith1 (numstepsฮธ ฮธ) โˆฅ E โŸฆ nothin โŸงe โˆฅs โˆฅ E โŸฆ s โ‡ e โŸงe โˆฅs (eplug< nothin (s โ‡ e) E โ‰คโ€ฒ-refl) noetherianโ‚ (rraise-var{ฮธ}{r}{x}{p}{e}{E} e' xโ‚) with unplug xโ‚ ... | refl = arith1 (numstepsฮธ ฮธ) โˆฅ E โŸฆ ฯโŸจ [x,ฮดe]-env x (ฮด e') , WAIT โŸฉยท p โŸงe โˆฅs โˆฅ E โŸฆ var x โ‰” e in: p โŸงe โˆฅs (eplug< (ฯโŸจ [x,ฮดe]-env x (ฮด e') , WAIT โŸฉยท p) (var x โ‰” e in: p) E โ‰คโ€ฒ-refl) noetherianโ‚ (rset-var{ฮธ}{_}{x}{e}{E} xโˆˆ e' xโ‚) with unplug xโ‚ ... | refl = arith1 (numstepsฮธ ฮธ) โˆฅ E โŸฆ nothin โŸงe โˆฅs โˆฅ E โŸฆ x โ‰” e โŸงe โˆฅs (eplug< nothin (x โ‰” e) E โ‰คโ€ฒ-refl) noetherianโ‚ (rif-false{ฮธ}{p = p}{q = q}{x = x}{E = E} xโˆˆ xโ‚ xโ‚‚) with unplug xโ‚‚ ... | refl = arith1 (numstepsฮธ ฮธ) โˆฅ E โŸฆ q โŸงe โˆฅs โˆฅ E โŸฆ if x โˆฃโ‡’ p โˆฃโ‡’ q โŸงe โˆฅs (eplug< q (if x โˆฃโ‡’ p โˆฃโ‡’ q) E (sโ‰คโ€ฒs (nโ‰คโ€ฒm+n โˆฅ p โˆฅs โˆฅ q โˆฅs))) noetherianโ‚ (rif-true{ฮธ}{p = p}{q = q}{x = x}{E = E} xโˆˆ xโ‚ xโ‚‚) with unplug xโ‚‚ ... | refl = arith1 (numstepsฮธ ฮธ) โˆฅ E โŸฆ p โŸงe โˆฅs โˆฅ E โŸฆ if x โˆฃโ‡’ p โˆฃโ‡’ q โŸงe โˆฅs (eplug< p (if x โˆฃโ‡’ p โˆฃโ‡’ q) E (sโ‰คโ€ฒs (mโ‰คโ€ฒm+n โˆฅ p โˆฅs โˆฅ q โˆฅs))) noetherianโ‚ (rabsence{ฮธ = ฮธ}{S = S} Sโˆˆ ฮธ[S]โ‰กunk SฬธSโˆ‰Canฮธ) with is-unknownp (SigMap.lookup{k = S} (sig ฮธ) Sโˆˆ) | inspect is-unknownp (SigMap.lookup{k = S} (sig ฮธ) Sโˆˆ) ... | false | Reveal_ยท_is_.[ eq ] rewrite ฮธ[S]โ‰กunk = โŠฅ-elim (absurd eq) where absurd : true โ‰ก false -> โŠฅ absurd () ... | true | Reveal_ยท_is_.[ eq ] with SigMap.change-one-count-goes-down (sig ฮธ) is-unknownp S Sโˆˆ eq Signal.absent refl ... | thing rewrite thing = โ‰คโ€ฒ-refl noetherianโ‚ (rreadyness {ฮธ}{p}{s} sโˆˆ (injโ‚ ฮธs=old) sโˆ‰Canฮธ) with is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโˆˆ) | inspect is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโˆˆ) ... | false | Reveal_ยท_is_.[ eq ] rewrite hunch (ShrMap.lookup{k = s} (shr ฮธ) sโˆˆ) | ฮธs=old = โŠฅ-elim (absurd eq) where absurd : true โ‰ก false -> โŠฅ absurd () ... | true | Reveal_ยท_is_.[ eq ] rewrite ฮธs=old with ShrMap.change-one-count-goes-down (shr ฮธ) is-notreadyp s sโˆˆ eq (SharedVar.ready ,โ€ฒ shr-vals{s} ฮธ sโˆˆ) refl ... | thing rewrite thing = arith4 (numstepsSig (sig ฮธ)) (numstepsShr (shr (set-shr{s} ฮธ sโˆˆ (SharedVar.ready) (shr-vals{s} ฮธ sโˆˆ)))) (โˆฅ p โˆฅs) noetherianโ‚ (rreadyness {ฮธ}{p}{s} sโˆˆ (injโ‚‚ ฮธs=new) sโˆ‰Canฮธ) with is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโˆˆ) | inspect is-notreadyp (ShrMap.lookup{k = s} (shr ฮธ) sโˆˆ) ... | false | Reveal_ยท_is_.[ eq ] rewrite hunch (ShrMap.lookup{k = s} (shr ฮธ) sโˆˆ) | ฮธs=new = โŠฅ-elim (absurd eq) where absurd : true โ‰ก false -> โŠฅ absurd () ... | true | Reveal_ยท_is_.[ eq ] rewrite ฮธs=new with ShrMap.change-one-count-goes-down (shr ฮธ) is-notreadyp s sโˆˆ eq (SharedVar.ready ,โ€ฒ shr-vals{s} ฮธ sโˆˆ) refl ... | thing rewrite thing = arith4 (numstepsSig (sig ฮธ)) (numstepsShr (shr (set-shr{s} ฮธ sโˆˆ (SharedVar.ready) (shr-vals{s} ฮธ sโˆˆ)))) (โˆฅ p โˆฅs) noetherianโ‚ (rmerge{ฮธโ‚}{ฮธโ‚‚}{_}{p}{E}{Aโ‚}{Aโ‚‚} x) with unplug x ... | refl rewrite decomposeโˆฅโˆฅs E (ฯโŸจ ฮธโ‚‚ , Aโ‚‚ โŸฉยท p) | decomposeโˆฅโˆฅs E p = sโ‰คโ€ฒs (rearrange-things (numstepsSig (SigMap.union (sig ฮธโ‚) (sig ฮธโ‚‚))) (numstepsShr (ShrMap.union (shr ฮธโ‚) (shr ฮธโ‚‚))) โˆฅ E โŸฆ nothin โŸงe โˆฅs โˆฅ p โˆฅs (numstepsSig (sig ฮธโ‚)) (numstepsShr (shr ฮธโ‚)) (numstepsSig (sig ฮธโ‚‚)) (numstepsShr (shr ฮธโ‚‚)) (โ‰คโ€ฒ+b (numstepsSig (SigMap.union (sig ฮธโ‚) (sig ฮธโ‚‚))) (numstepsShr (ShrMap.union (shr ฮธโ‚) (shr ฮธโ‚‚))) (numstepsSig (sig ฮธโ‚) + numstepsSig (sig ฮธโ‚‚)) (numstepsShr (shr ฮธโ‚) + numstepsShr (shr ฮธโ‚‚)) (SigMap.count-mergeโ‰คโ€ฒsum-count (sig ฮธโ‚) (sig ฮธโ‚‚) is-unknownp) (ShrMap.count-mergeโ‰คโ€ฒsum-count (shr ฮธโ‚) (shr ฮธโ‚‚) is-notreadyp))) where rearrange-more : โˆ€ ab cd a b c d -> ab + cd โ‰คโ€ฒ a + b + (c + d) -> ab + cd โ‰คโ€ฒ a + c + (b + d) rearrange-more ab cd a b c d simple rewrite sym (+-assoc (a + c) b d) | +-assoc a c b | +-comm c b | sym (+-assoc a b c) | +-assoc (a + b) c d = simple rearrange-things : โˆ€ ab cd n p a c b d -> ab + cd โ‰คโ€ฒ (a + b) + (c + d) -> suc (ab + cd + (n + p)) โ‰คโ€ฒ a + c + (n + (suc (b + d + p))) rearrange-things ab cd n p a c b d simple rewrite +-suc n (b + d + p) | +-suc (a + c) (n + (b + d + p)) | +-comm (b + d) p | sym (+-assoc n p (b + d)) | +-comm (n + p) (b + d) | sym (+-assoc (a + c) (b + d) (n + p)) = sโ‰คโ€ฒs (โ‰คโ€ฒ+l {z = n + p} (rearrange-more ab cd a b c d simple)) csteps : โˆ€ {p q C CโŸฆpโŸง CโŸฆqโŸง} -> (suc (โˆฅ q โˆฅs)) โ‰คโ€ฒ (โˆฅ p โˆฅs) -> CโŸฆpโŸง โ‰ C โŸฆ p โŸงc -> CโŸฆqโŸง โ‰ C โŸฆ q โŸงc -> (suc โˆฅ CโŸฆqโŸง โˆฅs) โ‰คโ€ฒ โˆฅ CโŸฆpโŸง โˆฅs csteps sqโ‰คp dchole dchole = sqโ‰คp csteps sqโ‰คp (dcparโ‚{pp}{pr}{pq} CโŸฆpโŸง=CโŸฆpโŸงc) (dcparโ‚{qp}{qr}{qq} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith2 โˆฅ qp โˆฅs โˆฅ pp โˆฅs โˆฅ pq โˆฅs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcparโ‚‚{pp}{pr}{pq} CโŸฆpโŸง=CโŸฆpโŸงc) (dcparโ‚‚{qp}{qr}{qq} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith1 โˆฅ qp โˆฅs โˆฅ qq โˆฅs โˆฅ pq โˆฅs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcseqโ‚{pp}{pr}{pq} CโŸฆpโŸง=CโŸฆpโŸงc) (dcseqโ‚{qp}{qr}{qq} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith2 โˆฅ qp โˆฅs โˆฅ pp โˆฅs โˆฅ pq โˆฅs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcseqโ‚‚{pp}{pr}{pq} CโŸฆpโŸง=CโŸฆpโŸงc) (dcseqโ‚‚{qp}{qr}{qq} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith1 โˆฅ pp โˆฅs โˆฅ qq โˆฅs โˆฅ pq โˆฅs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcsuspend{p} CโŸฆpโŸง=CโŸฆpโŸงc) (dcsuspend{q} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = sโ‰คโ€ฒs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dctrap{p} CโŸฆpโŸง=CโŸฆpโŸงc) (dctrap{q} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = sโ‰คโ€ฒs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcsignl{p} CโŸฆpโŸง=CโŸฆpโŸงc) (dcsignl{q} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = sโ‰คโ€ฒs (sโ‰คโ€ฒs (sโ‰คโ€ฒs sucnspโ‰ฐspโ‚)) csteps sqโ‰คp (dcpresentโ‚{pp}{pr}{pq} CโŸฆpโŸง=CโŸฆpโŸงc) (dcpresentโ‚{qp}{qr}{qq} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith2 โˆฅ qp โˆฅs โˆฅ pp โˆฅs โˆฅ pq โˆฅs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcpresentโ‚‚{pp}{pr}{pq} CโŸฆpโŸง=CโŸฆpโŸงc) (dcpresentโ‚‚{qp}{qr}{qq} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith1 โˆฅ pp โˆฅs โˆฅ qq โˆฅs โˆฅ pq โˆฅs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcloop{p} CโŸฆpโŸง=CโŸฆpโŸงc) (dcloop{q} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith5 โˆฅ q โˆฅs โˆฅ p โˆฅs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcloopหขโ‚{pp}{pq} CโŸฆpโŸง=CโŸฆpโŸงc) (dcloopหขโ‚{qp}{qq} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith2 โˆฅ qp โˆฅs โˆฅ pp โˆฅs โˆฅ pq โˆฅs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcloopหขโ‚‚{pp}{pq} CโŸฆpโŸง=CโŸฆpโŸงc) (dcloopหขโ‚‚{qp}{qq} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith1 โˆฅ pp โˆฅs โˆฅ qq โˆฅs โˆฅ pq โˆฅs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcshared{p} CโŸฆpโŸง=CโŸฆpโŸงc) (dcshared{q} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = sโ‰คโ€ฒs (sโ‰คโ€ฒs (sโ‰คโ€ฒs sucnspโ‰ฐspโ‚)) csteps sqโ‰คp (dcvar{p} CโŸฆpโŸง=CโŸฆpโŸงc) (dcvar{q} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = sโ‰คโ€ฒs (sโ‰คโ€ฒs sucnspโ‰ฐspโ‚) csteps sqโ‰คp (dcifโ‚{pp}{pr}{pq} CโŸฆpโŸง=CโŸฆpโŸงc) (dcifโ‚{qp}{qr}{qq} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith2 โˆฅ qp โˆฅs โˆฅ pp โˆฅs โˆฅ pq โˆฅs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcifโ‚‚{pp}{pr}{pq} CโŸฆpโŸง=CโŸฆpโŸงc) (dcifโ‚‚{qp}{qr}{qq} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith1 โˆฅ pp โˆฅs โˆฅ qq โˆฅs โˆฅ pq โˆฅs sucnspโ‰ฐspโ‚ csteps sqโ‰คp (dcenv{p = p1}{ฮธ = ฮธ} CโŸฆpโŸง=CโŸฆpโŸงc) (dcenv{p = p2} CโŸฆqโŸง=CโŸฆqโŸงc) with csteps sqโ‰คp CโŸฆpโŸง=CโŸฆpโŸงc CโŸฆqโŸง=CโŸฆqโŸงc ... | sucnspโ‰ฐspโ‚ = arith3 โˆฅ p2 โˆฅs โˆฅ p1 โˆฅs (numstepsฮธ ฮธ) sucnspโ‰ฐspโ‚ noetherian : โˆ€ {p q} -> p snโŸถ q -> (suc (โˆฅ q โˆฅs)) โ‰คโ€ฒ (โˆฅ p โˆฅs) noetherian (rcontext C dc pinsnโŸถโ‚qin) = csteps (noetherianโ‚ pinsnโŸถโ‚qin) dc Crefl
{ "alphanum_fraction": 0.5417946982, "avg_line_length": 39.1059063136, "ext": "agda", "hexsha": "5a2d6a971e29507882045970c1a8ba741ebfa84d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_forks_event_min_datetime": "2020-04-15T20:02:49.000Z", "max_forks_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "florence/esterel-calculus", "max_forks_repo_path": "agda/noetherian.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "florence/esterel-calculus", "max_issues_repo_path": "agda/noetherian.agda", "max_line_length": 85, "max_stars_count": 3, "max_stars_repo_head_hexsha": "4340bef3f8df42ab8167735d35a4cf56243a45cd", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "florence/esterel-calculus", "max_stars_repo_path": "agda/noetherian.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-01T03:59:31.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-16T10:58:53.000Z", "num_tokens": 9688, "size": 19201 }
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2020, 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} -- This is a selection of useful functions and definitions -- from the standard library that we tend to use a lot. module LibraBFT.Prelude where open import Level renaming (suc to โ„“+1; zero to โ„“0; _โŠ”_ to _โ„“โŠ”_) public 1โ„“ : Level 1โ„“ = โ„“+1 0โ„“ open import Agda.Builtin.Unit public open import Function using (_โˆ˜_; _โˆ˜โ€ฒ_; id; case_of_; _on_; typeOf; flip; const; _โˆ‹_; _$_) public identity = id infixl 1 _&_ _&_ = Function._|>_ open import Data.Unit.NonEta public open import Data.Empty public -- NOTE: This function is defined to give extra documentation when discharging -- absurd cases where Agda can tell by pattern matching that `A` is not -- inhabited. For example: -- > absurd (just v โ‰ก nothing) case impossibleProof of ฮป () infix 0 absurd_case_of_ absurd_case_of_ : โˆ€ {โ„“โ‚ โ„“โ‚‚} (A : Set โ„“โ‚) {B : Set โ„“โ‚‚} โ†’ A โ†’ (A โ†’ โŠฅ) โ†’ B absurd A case x of f = โŠฅ-elim (f x) open import Data.Nat renaming (_โ‰Ÿ_ to _โ‰Ÿโ„•_; _โ‰ค?_ to _โ‰ค?โ„•_; _โ‰ฅ?_ to _โ‰ฅ?โ„•_; compare to compareโ„•; Ordering to Orderingโ„•) public max = _โŠ”_ min = _โŠ“_ open import Data.Nat.DivMod using (_/_) div = _/_ open import Data.Nat.Properties hiding (โ‰ก-irrelevant ; _โ‰Ÿ_) public open import Data.List renaming (map to List-map ; filter to List-filter ; lookup to List-lookup; tabulate to List-tabulate; foldl to List-foldl) hiding (fromMaybe; [_]) public foldl' = List-foldl open import Data.List.Properties renaming (โ‰ก-dec to List-โ‰ก-dec; length-map to List-length-map; map-compose to List-map-compose; filter-++ to List-filter-++; length-filter to List-length-filter) using (โˆท-injective; length-++; map-++-commute; sum-++-commute; map-tabulate; tabulate-lookup; ++-identityสณ; ++-identityหก) public open import Data.List.Relation.Binary.Subset.Propositional renaming (_โІ_ to _โІList_) public open import Data.List.Relation.Unary.Any using (Any; here; there) renaming (lookup to Any-lookup; map to Any-map; satisfied to Any-satisfied ;index to Any-index; any to Any-any) public open import Data.List.Relation.Unary.Any.Properties using (ยฌAny[]) renaming ( mapโบ to Any-mapโบ ; mapโป to Any-mapโป ; concatโบ to Any-concatโบ ; concatโป to Any-concatโป ; ++โป to Any-++โป ; ++โบสณ to Any-++สณ ; ++โบหก to Any-++หก ; singletonโป to Any-singletonโป ; tabulateโบ to Any-tabulateโบ ; filterโป to Any-filterโป ) public open import Data.List.Relation.Unary.All using (All; []; _โˆท_) renaming (head to All-head; tail to All-tail; lookup to All-lookup; tabulate to All-tabulate; reduce to All-reduce; map to All-map) public open import Data.List.Relation.Unary.All.Properties hiding (All-map) renaming ( tabulateโป to All-tabulateโป ; tabulateโบ to All-tabulateโบ ; mapโบ to All-mapโบ ; mapโป to All-mapโป ; ++โบ to All-++ ) public open import Data.List.Membership.Propositional using (_โˆˆ_; _โˆ‰_) public open import Data.List.Membership.Propositional.Properties renaming (โˆˆ-filterโบ to List-โˆˆ-filterโบ; โˆˆ-filterโป to List-โˆˆ-filterโป) public open import Data.Vec using (Vec; []; _โˆท_) renaming (replicate to Vec-replicate; lookup to Vec-lookup ;map to Vec-map; head to Vec-head; tail to Vec-tail ;updateAt to Vec-updateAt; tabulate to Vec-tabulate ;allFin to Vec-allFin; toList to Vec-toList; fromList to Vec-fromList ;_++_ to _Vec-++_) public open import Data.Vec.Relation.Unary.All using ([]; _โˆท_) renaming (All to Vec-All; lookup to Vec-All-lookup) public open import Data.Vec.Properties using () renaming (updateAt-minimal to Vec-updateAt-minimal ;[]=โ‡’lookup to Vec-[]=โ‡’lookup ;lookupโ‡’[]= to Vec-lookupโ‡’[]= ;lookupโˆ˜tabulate to Vec-lookupโˆ˜tabulate ;โ‰ก-dec to Vec-โ‰ก-dec) public open import Data.List.Relation.Binary.Pointwise using (decidable-โ‰ก) public open import Data.Bool renaming (_โ‰Ÿ_ to _โ‰ŸBool_) hiding (_โ‰ค?_; _<_; _<?_; _โ‰ค_; not) public open import Data.Maybe renaming (map to Maybe-map; zip to Maybe-zip ; _>>=_ to _Maybe->>=_) hiding (align; alignWith; zipWith) public -- a non-dependent eliminator maybeS : โˆ€ {a b} {A : Set a} {B : Set b} โ†’ (x : Maybe A) โ†’ B โ†’ ((x : A) โ†’ B) โ†’ B maybeS {B = B} x f t = maybe {B = const B} t f x maybeHsk : โˆ€ {A B : Set} โ†’ B โ†’ (A โ†’ B) โ†’ Maybe A โ†’ B maybeHsk b aโ†’b = ฮป where nothing โ†’ b (just a) โ†’ aโ†’b a open import Data.Maybe.Relation.Unary.Any renaming (Any to Maybe-Any; dec to Maybe-Any-dec) hiding (map; zip; zipWith; unzip ; unzipWith) public maybe-any-โŠฅ : โˆ€{a}{A : Set a} โ†’ Maybe-Any {A = A} (ฮป _ โ†’ โŠค) nothing โ†’ โŠฅ maybe-any-โŠฅ () headMay : โˆ€ {A : Set} โ†’ List A โ†’ Maybe A headMay [] = nothing headMay (x โˆท _) = just x lastMay : โˆ€ {A : Set} โ†’ List A โ†’ Maybe A lastMay [] = nothing lastMay (x โˆท []) = just x lastMay (_ โˆท x โˆท xs) = lastMay (x โˆท xs) open import Data.Maybe.Properties using (just-injective) renaming (โ‰ก-dec to Maybe-โ‰ก-dec) public open import Data.Fin using (Fin; suc; zero; fromโ„•; fromโ„•< ; toโ„• ; cast) renaming (_โ‰Ÿ_ to _โ‰ŸFin_; _โ‰ค?_ to _โ‰ค?Fin_; _โ‰ค_ to _โ‰คFin_ ; _<_ to _<Fin_; injectโ‚ to Fin-injectโ‚; inject+ to Fin-inject+; injectโ‰ค to Fin-injectโ‰ค) public fins : (n : โ„•) โ†’ List (Fin n) fins n = Vec-toList (Vec-allFin n) open import Data.Fin.Properties using (toโ„•-injective; toโ„•<n) renaming (<-cmp to Fin-<-cmp; <โ‡’โ‰ข to <โ‡’โ‰ขFin; suc-injective to Fin-suc-injective) public open import Relation.Binary.PropositionalEquality hiding (decSetoid) public open import Relation.Binary.HeterogeneousEquality using (_โ‰…_) renaming (cong to โ‰…-cong; congโ‚‚ to โ‰…-congโ‚‚) public open import Relation.Binary public data Ordering : Set where LT EQ GT : Ordering compare : โ„• โ†’ โ„• โ†’ Ordering compare m n with <-cmp m n ... | tri< a ยฌb ยฌc = LT ... | triโ‰ˆ ยฌa b ยฌc = EQ ... | tri> ยฌa ยฌb c = GT โ‰ก-irrelevant : โˆ€{a}{A : Set a} โ†’ Irrelevant {a} {A} _โ‰ก_ โ‰ก-irrelevant refl refl = refl to-witness-lemma : โˆ€{โ„“}{A : Set โ„“}{a : A}{f : Maybe A}(x : Is-just f) โ†’ to-witness x โ‰ก a โ†’ f โ‰ก just a to-witness-lemma (just x) refl = refl open import Relation.Nullary hiding (Irrelevant; proof) public open import Relation.Nullary.Decidable hiding (map) public open import Data.Sum renaming ([_,_] to either; map to โŠŽ-map; mapโ‚ to โŠŽ-mapโ‚; mapโ‚‚ to โŠŽ-mapโ‚‚) public open import Data.Sum.Properties using (injโ‚-injective ; injโ‚‚-injective) public โŠŽ-elimหก : โˆ€ {โ„“โ‚€ โ„“โ‚}{Aโ‚€ : Set โ„“โ‚€}{Aโ‚ : Set โ„“โ‚} โ†’ ยฌ Aโ‚€ โ†’ Aโ‚€ โŠŽ Aโ‚ โ†’ Aโ‚ โŠŽ-elimหก ยฌa = either (โŠฅ-elim โˆ˜ ยฌa) id โŠŽ-elimสณ : โˆ€ {โ„“โ‚€ โ„“โ‚}{Aโ‚€ : Set โ„“โ‚€}{Aโ‚ : Set โ„“โ‚} โ†’ ยฌ Aโ‚ โ†’ Aโ‚€ โŠŽ Aโ‚ โ†’ Aโ‚€ โŠŽ-elimสณ ยฌa = either id (โŠฅ-elim โˆ˜ ยฌa) open import Data.Product renaming (map to ร—-map; mapโ‚‚ to ร—-mapโ‚‚; mapโ‚ to ร—-mapโ‚; <_,_> to split; swap to ร—-swap) hiding (zip) public fst = projโ‚ open import Data.Product.Properties public module _ {โ„“A} {A : Set โ„“A} where NoneOfKind : โˆ€ {โ„“} {P : A โ†’ Set โ„“} โ†’ List A โ†’ (p : (a : A) โ†’ Dec (P a)) โ†’ Set โ„“A NoneOfKind xs p = List-filter p xs โ‰ก [] postulate -- TODO-1: Replace with or prove using library properties? Move to Lemmas? NoneOfKindโ‡’ : โˆ€ {โ„“} {P : A โ†’ Set โ„“} {Q : A โ†’ Set โ„“} {xs : List A} โ†’ (p : (a : A) โ†’ Dec (P a)) โ†’ {q : (a : A) โ†’ Dec (Q a)} โ†’ (โˆ€ {a} โ†’ P a โ†’ Q a) -- TODO-1: Use proper notation (Relation.Unary?) โ†’ NoneOfKind xs q โ†’ NoneOfKind xs p infix 4 _<?โ„•_ _<?โ„•_ : Decidable _<_ m <?โ„• n = suc m โ‰ค?โ„• n infix 0 if-yes_then_else_ infix 0 if-dec_then_else_ if-yes_then_else_ : โˆ€ {โ„“A โ„“B} {A : Set โ„“A} {B : Set โ„“B} โ†’ Dec A โ†’ (A โ†’ B) โ†’ (ยฌ A โ†’ B) โ†’ B if-yes (yes prf) then f else _ = f prf if-yes (no prf) then _ else g = g prf if-dec_then_else_ : โˆ€ {โ„“A โ„“B} {A : Set โ„“A} {B : Set โ„“B} โ†’ Dec A โ†’ B โ†’ B โ†’ B if-dec x then f else g = if-yes x then const f else const g open import Relation.Nullary.Negation using (contradiction; contraposition) public open import Relation.Binary using (Setoid; IsPreorder) public open import Relation.Unary using (_โˆช_) public open import Relation.Unary.Properties using (_โˆช?_) public -- Injectivity for a function of two potentially different types (A and B) via functions to a -- common type (C). Injective' : โˆ€ {b c d e}{B : Set b}{C : Set c}{D : Set d} โ†’ (hB : B โ†’ D) โ†’ (hC : C โ†’ D) โ†’ (_โ‰ˆ_ : B โ†’ C โ†’ Set e) โ†’ Set _ Injective' {C = C} hB hC _โ‰ˆ_ = โˆ€ {b c} โ†’ hB b โ‰ก hC c โ†’ b โ‰ˆ c Injective : โˆ€ {c d e}{C : Set c}{D : Set d} โ†’ (h : C โ†’ D) โ†’ (_โ‰ˆ_ : Rel C e) โ†’ Set _ Injective h _โ‰ˆ_ = Injective' h h _โ‰ˆ_ Injective-โ‰ก : โˆ€ {c d}{C : Set c}{D : Set d} โ†’ (h : C โ†’ D) โ†’ Set _ Injective-โ‰ก h = Injective h _โ‰ก_ Injective-int : โˆ€{a b c d e}{A : Set a}{B : Set b}{C : Set c}{D : Set d} โ†’ (_โ‰ˆ_ : A โ†’ B โ†’ Set e) โ†’ (h : C โ†’ D) โ†’ (fโ‚ : A โ†’ C) โ†’ (fโ‚‚ : B โ†’ C) โ†’ Set (a โ„“โŠ” b โ„“โŠ” d โ„“โŠ” e) Injective-int _โ‰ˆ_ h fโ‚ fโ‚‚ = โˆ€ {aโ‚} {bโ‚} โ†’ h (fโ‚ aโ‚) โ‰ก h (fโ‚‚ bโ‚) โ†’ aโ‚ โ‰ˆ bโ‚ NonInjective : โˆ€{a b c}{A : Set a}{B : Set b} โ†’ (_โ‰ˆ_ : Rel A c) โ†’ (A โ†’ B) โ†’ Set (a โ„“โŠ” b โ„“โŠ” c) NonInjective {A = A} _โ‰ˆ_ f = ฮฃ (A ร— A) (ฮป { (xโ‚ , xโ‚‚) โ†’ ยฌ (xโ‚ โ‰ˆ xโ‚‚) ร— f xโ‚ โ‰ก f xโ‚‚ }) NonInjective-โ‰ก : โˆ€{a b}{A : Set a}{B : Set b} โ†’ (A โ†’ B) โ†’ Set (a โ„“โŠ” b) NonInjective-โ‰ก = NonInjective _โ‰ก_ NonInjective-โ‰ก-preds : โˆ€{a b}{A : Set a}{B : Set b}{โ„“โ‚ โ„“โ‚‚ : Level} โ†’ (A โ†’ Set โ„“โ‚) โ†’ (A โ†’ Set โ„“โ‚‚) โ†’ (A โ†’ B) โ†’ Set (a โ„“โŠ” b โ„“โŠ” โ„“โ‚ โ„“โŠ” โ„“โ‚‚) NonInjective-โ‰ก-preds Pred1 Pred2 f = ฮฃ (NonInjective _โ‰ก_ f) ฮป { ((aโ‚€ , aโ‚) , _ , _) โ†’ Pred1 aโ‚€ ร— Pred2 aโ‚ } NonInjective-โ‰ก-pred : โˆ€{a b}{A : Set a}{B : Set b}{โ„“ : Level} โ†’ (P : A โ†’ Set โ„“) โ†’ (A โ†’ B) โ†’ Set (a โ„“โŠ” b โ„“โŠ” โ„“) NonInjective-โ‰ก-pred Pred = NonInjective-โ‰ก-preds Pred Pred NonInjective-โˆ˜ : โˆ€{a b c}{A : Set a}{B : Set b}{C : Set c} โ†’ {f : A โ†’ B}(g : B โ†’ C) โ†’ NonInjective-โ‰ก f โ†’ NonInjective-โ‰ก (g โˆ˜ f) NonInjective-โˆ˜ g ((x0 , x1) , (x0โ‰ขx1 , fx0โ‰กfx1)) = ((x0 , x1) , x0โ‰ขx1 , (cong g fx0โ‰กfx1)) -------------------------------------------- -- Handy fmap and bind for specific types -- _<M$>_ : โˆ€{a b}{A : Set a}{B : Set b} โ†’ (f : A โ†’ B) โ†’ Maybe A โ†’ Maybe B _<M$>_ = Maybe-map <M$>-univ : โˆ€{a b}{A : Set a}{B : Set b} โ†’ (f : A โ†’ B)(x : Maybe A) โ†’ {y : B} โ†’ f <M$> x โ‰ก just y โ†’ โˆƒ[ x' ] (x โ‰ก just x' ร— f x' โ‰ก y) <M$>-univ f (just x) refl = x , (refl , refl) maybe-lift : {A : Set} โ†’ {mx : Maybe A}{x : A} โ†’ (P : A โ†’ Set) โ†’ P x โ†’ mx โ‰ก just x โ†’ maybe {B = const Set} P โŠฅ mx maybe-lift {mx = just .x} {x} P px refl = px <M$>-nothing : โˆ€ {a b}{A : Set a}{B : Set b}(f : A โ†’ B) โ†’ f <M$> nothing โ‰ก nothing <M$>-nothing _ = refl _<โŠŽ$>_ : โˆ€{a b c}{A : Set a}{B : Set b}{C : Set c} โ†’ (A โ†’ B) โ†’ C โŠŽ A โ†’ C โŠŽ B f <โŠŽ$> (injโ‚ hb) = injโ‚ hb f <โŠŽ$> (injโ‚‚ x) = injโ‚‚ (f x) _โŠŽโŸซ=_ : โˆ€{a b c}{A : Set a}{B : Set b}{C : Set c} โ†’ C โŠŽ A โ†’ (A โ†’ C โŠŽ B) โ†’ C โŠŽ B (injโ‚ x) โŠŽโŸซ= _ = injโ‚ x (injโ‚‚ a) โŠŽโŸซ= f = f a -- Syntactic support for more faithful model of Haskell code Either : โˆ€ {a b} โ†’ Set a โ†’ Set b โ†’ Set (a โ„“โŠ” b) Either A B = A โŠŽ B pattern Left x = injโ‚ x pattern Right x = injโ‚‚ x isLeft : โˆ€ {a b} {A : Set a} {B : Set b} โ†’ Either A B โ†’ Bool isLeft (Left _) = true isLeft (Right _) = false isRight : โˆ€ {a b} {A : Set a} {B : Set b} โ†’ Either A B โ†’ Bool isRight = Data.Bool.not โˆ˜ isLeft -- a non-dependent eliminator eitherS : โˆ€ {a b c} {A : Set a} {B : Set b} {C : Set c} (x : Either A B) โ†’ ((x : A) โ†’ C) โ†’ ((x : B) โ†’ C) โ†’ C eitherS eab fa fb = case eab of ฮป where (Left a) โ†’ fa a (Right b) โ†’ fb b module _ {โ„“โ‚€ โ„“โ‚ โ„“โ‚‚ : Level} where EL-type = Set โ„“โ‚ โ†’ Set โ„“โ‚‚ โ†’ Set โ„“โ‚€ EL-level = โ„“โ‚ โ„“โŠ” โ„“โ‚‚ โ„“โŠ” โ„“โ‚€ -- Utility to make passing between `Either` and `EitherD` more convenient record EitherLike (E : EL-type) : Set (โ„“+1 EL-level) where field fromEither : โˆ€ {A : Set โ„“โ‚} {B : Set โ„“โ‚‚} โ†’ Either A B โ†’ E A B toEither : โˆ€ {A : Set โ„“โ‚} {B : Set โ„“โ‚‚} โ†’ E A B โ†’ Either A B open EitherLike โฆƒ ... โฆ„ public EL-func : EL-type โ†’ Set (โ„“+1 EL-level) EL-func EL = โฆƒ mel : EitherLike EL โฆ„ โ†’ Set EL-level instance EitherLike-Either : โˆ€ {โ„“โ‚ โ„“โ‚‚} โ†’ EitherLike{โ„“โ‚ โ„“โŠ” โ„“โ‚‚}{โ„“โ‚}{โ„“โ‚‚} Either EitherLike.fromEither EitherLike-Either = id EitherLike.toEither EitherLike-Either = id -- an approximation of Haskell's backtick notation for making infix operators; in Agda, must have -- spaces between f and backticks flip' : _ -- Avoids warning about definition and syntax declaration being in different scopes flip' = flip syntax flip' f = ` f ` open import Data.String as String hiding (_==_ ; _โ‰Ÿ_ ; concat) check : Bool โ†’ List String โ†’ Either String Unit check b t = if b then injโ‚‚ unit else injโ‚ (String.intersperse "; " t) -- TODO-1: Maybe this belongs somewhere else? It's in a similar -- category as Optics, so maybe should similarly be in a module that -- is separate from the main project? ------------------ -- Guard Syntax -- -- -- Example Usage: -- -- > f : โ„• โ†’ โ„• -- > f x = grdโ€– x โ‰Ÿโ„• 10 โ‰” 12 -- > โ€– otherwiseโ‰” 40 + 2 -- -- -- > g : โ„• โŠŽ โ„• โ†’ โ„• -- > g x = case x of ฮป -- > { (injโ‚ x) โ†’ grdโ€– x โ‰ค? 10 โ‰” 2 * x -- > โ€– otherwiseโ‰” 42 -- > ; (injโ‚‚ y) โ†’ y -- > } -- -- To type: โ€– --> \Vert -- โ‰” --> \:= record ToBool {a}(A : Set a) : Set a where field toBool : A โ†’ Bool open ToBool {{ ... }} public not : โˆ€ {b} {B : Set b} โฆƒ _ : ToBool B โฆ„ โ†’ B โ†’ Bool not b = Data.Bool.not (toBool b) instance ToBool-Bool : ToBool Bool ToBool-Bool = record { toBool = id } ToBool-Dec : โˆ€{a}{A : Set a} โ†’ ToBool (Dec A) ToBool-Dec = record { toBool = โŒŠ_โŒ‹ } toWitnessT : โˆ€{โ„“}{P : Set โ„“}{d : Dec P} โ†’ โŒŠ d โŒ‹ โ‰ก true โ†’ P toWitnessT {d = yes proof} _ = proof toWitnessF : โˆ€{โ„“}{P : Set โ„“}{d : Dec P} โ†’ โŒŠ d โŒ‹ โ‰ก false โ†’ ยฌ P toWitnessF{d = no proof} _ = proof infix 3 _โ‰”_ data GuardClause {a}{b}(A : Set a) : Set (a โ„“โŠ” โ„“+1 b) where _โ‰”_ : {B : Set b}{{ bb : ToBool B }} โ†’ B โ†’ A โ†’ GuardClause A infix 3 otherwiseโ‰”_ data Guards {a}{b}(A : Set a) : Set (a โ„“โŠ” โ„“+1 b) where otherwiseโ‰”_ : A โ†’ Guards A clause : GuardClause{a}{b} A โ†’ Guards{a}{b} A โ†’ Guards A infixr 2 _โ€–_ _โ€–_ : โˆ€{a}{b}{A : Set a} โ†’ GuardClause{a}{b} A โ†’ Guards A โ†’ Guards A _โ€–_ = clause infix 1 grdโ€–_ grdโ€–_ : โˆ€{a}{b}{A : Set a} โ†’ Guards{a}{b} A โ†’ A grdโ€–_ (otherwiseโ‰” a) = a grdโ€–_ (clause (b โ‰” a) g) = if toBool b then a else (grdโ€– g) Any-satisfied-โˆˆ : โˆ€{a โ„“}{A : Set a}{P : A โ†’ Set โ„“}{xs : List A} โ†’ Any P xs โ†’ ฮฃ A (ฮป x โ†’ P x ร— x โˆˆ xs) Any-satisfied-โˆˆ (here px) = _ , (px , here refl) Any-satisfied-โˆˆ (there p) = let (a , px , prf) = Any-satisfied-โˆˆ p in (a , px , there prf) f-sum : โˆ€{a}{A : Set a} โ†’ (A โ†’ โ„•) โ†’ List A โ†’ โ„• f-sum f = sum โˆ˜ List-map f record Functor {โ„“โ‚ โ„“โ‚‚ : Level} (F : Set โ„“โ‚ โ†’ Set โ„“โ‚‚) : Set (โ„“โ‚‚ โ„“โŠ” โ„“+1 โ„“โ‚) where infixl 4 _<$>_ field _<$>_ : โˆ€ {A B : Set โ„“โ‚} โ†’ (A โ†’ B) โ†’ F A โ†’ F B fmap = _<$>_ open Functor โฆƒ ... โฆ„ public record Applicative {โ„“โ‚ โ„“โ‚‚ : Level} (F : Set โ„“โ‚ โ†’ Set โ„“โ‚‚) : Set (โ„“โ‚‚ โ„“โŠ” โ„“+1 โ„“โ‚) where infixl 4 _<*>_ field pure : โˆ€ {A : Set โ„“โ‚} โ†’ A โ†’ F A _<*>_ : โˆ€ {A B : Set โ„“โ‚} โ†’ F (A โ†’ B) โ†’ F A โ†’ F B open Applicative โฆƒ ... โฆ„ public instance ApplicativeFunctor : โˆ€ {โ„“โ‚ โ„“โ‚‚} {F : Set โ„“โ‚ โ†’ Set โ„“โ‚‚} โฆƒ _ : Applicative F โฆ„ โ†’ Functor F Functor._<$>_ ApplicativeFunctor f xs = pure f <*> xs record Monad {โ„“โ‚ โ„“โ‚‚ : Level} (M : Set โ„“โ‚ โ†’ Set โ„“โ‚‚) : Set (โ„“โ‚‚ โ„“โŠ” โ„“+1 โ„“โ‚) where infixl 1 _>>=_ _>>_ field return : โˆ€ {A : Set โ„“โ‚} โ†’ A โ†’ M A _>>=_ : โˆ€ {A B : Set โ„“โ‚} โ†’ M A โ†’ (A โ†’ M B) โ†’ M B _>>_ : โˆ€ {A B : Set โ„“โ‚} โ†’ M A โ†’ M B โ†’ M B mโ‚ >> mโ‚‚ = mโ‚ >>= ฮป _ โ†’ mโ‚‚ open Monad โฆƒ ... โฆ„ public instance MonadApplicative : โˆ€ {โ„“โ‚ โ„“โ‚‚} {M : Set โ„“โ‚ โ†’ Set โ„“โ‚‚} โฆƒ _ : Monad M โฆ„ โ†’ Applicative M Applicative.pure MonadApplicative = return Applicative._<*>_ MonadApplicative fs xs = do f โ† fs x โ† xs return (f x) instance Monad-Either : โˆ€ {โ„“}{C : Set โ„“} โ†’ Monad{โ„“}{โ„“} (Either C) Monad.return (Monad-Either{โ„“}{C}) = injโ‚‚ Monad._>>=_ (Monad-Either{โ„“}{C}) = either (const โˆ˜ injโ‚) _&_ Monad-Maybe : โˆ€ {โ„“} โ†’ Monad {โ„“} {โ„“} Maybe Monad.return (Monad-Maybe{โ„“}) = just Monad._>>=_ (Monad-Maybe{โ„“}) = _Maybe->>=_ Monad-List : โˆ€ {โ„“} โ†’ Monad {โ„“}{โ„“} List Monad.return Monad-List x = x โˆท [] Monad._>>=_ Monad-List x f = concat (List-map f x) maybeSMP : โˆ€ {โ„“} {A B : Set} {m : Set โ†’ Set โ„“} โฆƒ _ : Monad m โฆ„ โ†’ m (Maybe A) โ†’ B โ†’ (A โ†’ m B) โ†’ m B maybeSMP ma b f = do x โ† ma case x of ฮป where nothing โ†’ pure b (just j) โ†’ f j fromMaybeM : โˆ€ {โ„“} {A : Set} {m : Set โ†’ Set โ„“} โฆƒ _ : Monad m โฆ„ โ†’ m A โ†’ m (Maybe A) โ†’ m A fromMaybeM ma mma = do mma >>= ฮป where nothing โ†’ ma (just a) โ†’ pure a forM_ : โˆ€ {โ„“} {A B : Set} {M : Set โ†’ Set โ„“} โฆƒ _ : Monad M โฆ„ โ†’ List A โ†’ (A โ†’ M B) โ†’ M Unit forM_ [] _ = return unit forM_ (x โˆท xs) f = f x >> forM_ xs f -- NOTE: because 'forM_' is defined above, it is necessary to -- call 'forM' with parenthesis (e.g., recursive call in definition) -- to disambiguate it for the Agda parser. forM : โˆ€ {โ„“} {A B : Set} {M : Set โ†’ Set โ„“} โฆƒ _ : Monad M โฆ„ โ†’ List A โ†’ (A โ†’ M B) โ†’ M (List B) forM [] _ = return [] forM (x โˆท xs) f = do fx โ† f x fxs โ† (forM) xs f return (fx โˆท fxs) foldrM : โˆ€ {โ„“โ‚ โ„“โ‚‚} {A B : Set โ„“โ‚} {M : Set โ„“โ‚ โ†’ Set โ„“โ‚‚} โฆƒ _ : Monad M โฆ„ โ†’ (A โ†’ B โ†’ M B) โ†’ B โ†’ List A โ†’ M B foldrM _ b [] = return b foldrM f b (a โˆท as) = foldrM f b as >>= f a foldlM : โˆ€ {โ„“โ‚ โ„“โ‚‚} {A B : Set โ„“โ‚} {M : Set โ„“โ‚ โ†’ Set โ„“โ‚‚} โฆƒ _ : Monad M โฆ„ โ†’ (B โ†’ A โ†’ M B) โ†’ B โ†’ List A โ†’ M B foldlM _ z [] = pure z foldlM f z (x โˆท xs) = do z' โ† f z x foldlM f z' xs foldM = foldlM foldM_ : {A B : Set} {M : Set โ†’ Set} โฆƒ _ : Monad M โฆ„ โ†’ (B โ†’ A โ†’ M B) โ†’ B โ†’ List A โ†’ M Unit foldM_ f a xs = foldlM f a xs >> pure unit open import LibraBFT.Base.Util public record Eq {a} (A : Set a) : Set a where infix 4 _โ‰Ÿ_ _==_ _/=_ field _โ‰Ÿ_ : (a b : A) โ†’ Dec (a โ‰ก b) _==_ : A โ†’ A โ†’ Bool a == b = toBool $ a โ‰Ÿ b _/=_ : A โ†’ A โ†’ Bool a /= b = not (a == b) open Eq โฆƒ ... โฆ„ public elem : โˆ€ {โ„“} {A : Set โ„“} โฆƒ _ : Eq A โฆ„ โ†’ A โ†’ List A โ†’ Bool elem x = toBool โˆ˜ Any-any (x โ‰Ÿ_) instance Eq-Nat : Eq โ„• Eq._โ‰Ÿ_ Eq-Nat = _โ‰Ÿโ„•_ Eq-Maybe : โˆ€ {a} {A : Set a} โฆƒ _ : Eq A โฆ„ โ†’ Eq (Maybe A) Eq._โ‰Ÿ_ Eq-Maybe nothing nothing = yes refl Eq._โ‰Ÿ_ Eq-Maybe (just _) nothing = no ฮป () Eq._โ‰Ÿ_ Eq-Maybe nothing (just _) = no ฮป () Eq._โ‰Ÿ_ Eq-Maybe (just a) (just b) with a โ‰Ÿ b ... | no proof = no ฮป where refl โ†’ proof refl ... | yes refl = yes refl infixl 9 _!?_ _!?_ : {A : Set} โ†’ List A โ†’ โ„• โ†’ Maybe A [] !? _ = nothing (x โˆท _ ) !? 0 = just x (_ โˆท xs) !? (suc n) = xs !? n -- Like a Haskell list-comprehension for โ„• : [ n | n <- [from .. to] ] fromToList : โ„• โ†’ โ„• โ†’ List โ„• fromToList from to with from โ‰คโ€ฒ? to ... | no ยฌpr = [] ... | yes pr = fromToList-le from to pr [] where fromToList-le : โˆ€ (from to : โ„•) (klel : from โ‰คโ€ฒ to) (acc : List โ„•) โ†’ List โ„• fromToList-le from ._ โ‰คโ€ฒ-refl acc = from โˆท acc fromToList-le from (suc to) (โ‰คโ€ฒ-step klel) acc = fromToList-le from to klel (suc to โˆท acc) _ : fromToList 1 1 โ‰ก 1 โˆท [] _ = refl _ : fromToList 1 2 โ‰ก 1 โˆท 2 โˆท [] _ = refl _ : fromToList 2 1 โ‰ก [] _ = refl
{ "alphanum_fraction": 0.5291064325, "avg_line_length": 31.3282674772, "ext": "agda", "hexsha": "fb92dc3d7356f043997b28ce0697485d9d6dd972", "lang": "Agda", "max_forks_count": 6, "max_forks_repo_forks_event_max_datetime": "2022-02-18T01:04:32.000Z", "max_forks_repo_forks_event_min_datetime": "2020-12-16T19:43:52.000Z", "max_forks_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "oracle/bft-consensus-agda", "max_forks_repo_path": "LibraBFT/Prelude.agda", "max_issues_count": 72, "max_issues_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_issues_repo_issues_event_max_datetime": "2022-03-25T05:36:11.000Z", "max_issues_repo_issues_event_min_datetime": "2021-02-04T05:04:33.000Z", "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "oracle/bft-consensus-agda", "max_issues_repo_path": "LibraBFT/Prelude.agda", "max_line_length": 164, "max_stars_count": 4, "max_stars_repo_head_hexsha": "49f8b1b70823be805d84ffc3157c3b880edb1e92", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "oracle/bft-consensus-agda", "max_stars_repo_path": "LibraBFT/Prelude.agda", "max_stars_repo_stars_event_max_datetime": "2021-12-18T19:24:05.000Z", "max_stars_repo_stars_event_min_datetime": "2020-12-16T19:43:41.000Z", "num_tokens": 8019, "size": 20614 }
{- Please do not move this file. Changes should only be made if necessary. This file contains pointers to the code examples and main results from the paper: Synthetic Cohomology Theory in Cubical Agda -} -- The "--safe" flag ensures that there are no postulates or -- unfinished goals {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Papers.ZCohomology where -- Misc. open import Cubical.Data.Int hiding (_+_) open import Cubical.Data.Nat open import Cubical.Foundations.Everything open import Cubical.HITs.S1 open import Cubical.Data.Sum open import Cubical.Data.Sigma -- II import Cubical.Foundations.Prelude as Prelude import Cubical.Foundations.GroupoidLaws as GroupoidLaws import Cubical.Foundations.Path as Path open import Cubical.HITs.S1 as S1 open import Cubical.HITs.Susp as Suspension open import Cubical.HITs.Sn as Sn open import Cubical.Homotopy.Loopspace as Loop open import Cubical.Foundations.HLevels as n-types open import Cubical.HITs.Truncation as Trunc open import Cubical.Homotopy.Connected as Connected import Cubical.HITs.Pushout as Push import Cubical.HITs.Wedge as โ‹ import Cubical.Foundations.Univalence as Unival import Cubical.Foundations.SIP as StructIdPrinc import Cubical.Algebra.Group as Gr -- III import Cubical.ZCohomology.Base as coHom renaming (coHomK to K) import Cubical.HITs.Sn.Properties as S import Cubical.ZCohomology.GroupStructure as GroupStructure import Cubical.ZCohomology.Properties as Properties renaming (Knโ†’ฮฉKn+1 to ฯƒ ; ฮฉKn+1โ†’Kn to ฯƒโปยน) import Cubical.Experiments.ZCohomologyOld.Properties as oldCohom -- IV import Cubical.Homotopy.EilenbergSteenrod as ES-axioms import Cubical.ZCohomology.EilenbergSteenrodZ as satisfies-ES-axioms renaming (coHomFunctor to H^~ ; coHomFunctor' to Hฬ‚) import Cubical.ZCohomology.MayerVietorisUnreduced as MayerVietoris -- V import Cubical.ZCohomology.Groups.Sn as HโฟSโฟ renaming (Hโฟ-Sแตโ‰…0 to Hโฟ-Sแตโ‰…1) import Cubical.ZCohomology.Groups.Torus as HโฟTยฒ import Cubical.ZCohomology.Groups.Wedge as Hโฟ-wedge import Cubical.ZCohomology.Groups.KleinBottle as Hโฟ๐•‚ยฒ import Cubical.ZCohomology.Groups.RP2 as Hโฟโ„Pยฒ renaming (Hยน-RPยฒโ‰…0 to Hยน-RPยฒโ‰…1) ----- II. HOMOTOPY TYPE THEORY IN CUBICAL AGDA ----- -- II.A Important notions in Cubical Agda open Prelude using ( PathP ; _โ‰ก_ ; refl ; cong ; funExt) open GroupoidLaws using (_โปยน) open Prelude using ( transport ; subst ; hcomp) --- II.B Important concepts from HoTT/UF in Cubical Agda -- The circle, ๐•Šยน open S1 using (Sยน) -- Suspensions open Suspension using (Susp) -- n-spheres, ๐•Šโฟ open Sn using (Sโ‚Š) -- Loop spaces open Loop using (ฮฉ^_) -- Eckmann-Hilton argument open Loop using (Eckmann-Hilton) -- n-types Note that we start indexing from 0 in the Cubical Library -- (so (-2)-types as referred to as 0-types, (-1) as 1-types, and so -- on) open n-types using (isOfHLevel) -- truncations open Trunc using (hLevelTrunc) -- elimination principle open Trunc using (elim) -- elimination principle for paths truncPathElim : โˆ€ {โ„“ โ„“'} {A : Type โ„“} {x y : A} (n : โ„•) โ†’ {B : Path (hLevelTrunc (suc n) A) โˆฃ x โˆฃ โˆฃ y โˆฃ โ†’ Type โ„“'} โ†’ ((q : _) โ†’ isOfHLevel n (B q)) โ†’ ((p : x โ‰ก y) โ†’ B (cong โˆฃ_โˆฃ p)) โ†’ (q : _) โ†’ B q truncPathElim zero hlev ind q = hlev q .fst truncPathElim (suc n) {B = B} hlev ind q = subst B (Iso.leftInv (Trunc.PathIdTruncIso _) q) (help (ฮฉTrunc.encode-fun โˆฃ _ โˆฃ โˆฃ _ โˆฃ q)) where help : (q : _) โ†’ B (ฮฉTrunc.decode-fun โˆฃ _ โˆฃ โˆฃ _ โˆฃ q) help = Trunc.elim (ฮป _ โ†’ hlev _) ind -- Connectedness open Connected using (isConnected) -- Pushouts open Push using (Pushout) -- Wedge sum open โ‹ using (_โ‹_) -- III.C Univalence -- Univalence and the ua function respectively open Unival using (univalence ; ua) -- The structure identity principle and the sip function -- respectively open StructIdPrinc using (SIP ; sip) -- Groups open Gr using (Group) ----- III. โ„ค-COHOMOLOGY IN CUBICAL AGDA ----- -- III.A Eilenberg-MacLane spaces -- Eilenberg-MacLane spaces Kโ‚™ open coHom using (K) -- Proposition 1 open S using (sphereConnected) -- Lemma 1 open S using (wedgeConSn) -- restated to match the formulation in the paper wedgeConSn' : โˆ€ {โ„“} (n m : โ„•) {A : (Sโ‚Š (suc n)) โ†’ (Sโ‚Š (suc m)) โ†’ Type โ„“} โ†’ ((x : Sโ‚Š (suc n)) (y : Sโ‚Š (suc m)) โ†’ isOfHLevel ((suc n) + (suc m)) (A x y)) โ†’ (fโ‚— : (x : _) โ†’ A x (ptSn (suc m))) โ†’ (fแตฃ : (x : _) โ†’ A (ptSn (suc n)) x) โ†’ (p : fโ‚— (ptSn (suc n)) โ‰ก fแตฃ (ptSn (suc m))) โ†’ ฮฃ[ F โˆˆ ((x : Sโ‚Š (suc n)) (y : Sโ‚Š (suc m)) โ†’ A x y) ] (ฮฃ[ (left , right) โˆˆ ((x : Sโ‚Š (suc n)) โ†’ fโ‚— x โ‰ก F x (ptSn (suc m))) ร— ((x : Sโ‚Š (suc m)) โ†’ fแตฃ x โ‰ก F (ptSn (suc n)) x) ] p โ‰ก left (ptSn (suc n)) โˆ™ (right (ptSn (suc m))) โปยน) wedgeConSn' zero zero hlev fโ‚— fแตฃ p = (wedgeConSn 0 0 hlev fแตฃ fโ‚— p .fst) , ((ฮป x โ†’ sym (wedgeConSn 0 0 hlev fแตฃ fโ‚— p .snd .snd x)) , ฮป _ โ†’ refl) -- right holds by refl , rUnit _ wedgeConSn' zero (suc m) hlev fโ‚— fแตฃ p = (wedgeConSn 0 (suc m) hlev fแตฃ fโ‚— p .fst) , ((ฮป _ โ†’ refl) -- left holds by refl , (ฮป x โ†’ sym (wedgeConSn 0 (suc m) hlev fแตฃ fโ‚— p .snd .fst x))) , lUnit _ wedgeConSn' (suc n) m hlev fโ‚— fแตฃ p = (wedgeConSn (suc n) m hlev fแตฃ fโ‚— p .fst) , ((ฮป x โ†’ sym (wedgeConSn (suc n) m hlev fแตฃ fโ‚— p .snd .snd x)) , ฮป _ โ†’ refl) -- right holds by refl , rUnit _ -- +โ‚– (addition), -โ‚– and 0โ‚– open GroupStructure using (_+โ‚–_ ; -โ‚–_ ; 0โ‚–) -- Group laws for +โ‚– open GroupStructure using ( rUnitโ‚– ; lUnitโ‚– ; rCancelโ‚– ; lCancelโ‚– ; commโ‚– ; assocโ‚–) -- All group laws are equal to refl at 0โ‚– -- rUnitโ‚– (definitional) 0-rUnitโ‰กrefl : rUnitโ‚– 0 (0โ‚– 0) โ‰ก refl 1-rUnitโ‰กrefl : rUnitโ‚– 1 (0โ‚– 1) โ‰ก refl 0-rUnitโ‰กrefl = refl 1-rUnitโ‰กrefl = refl nโ‰ฅ2-rUnitโ‰กrefl : {n : โ„•} โ†’ rUnitโ‚– (2 + n) (0โ‚– (2 + n)) โ‰ก refl nโ‰ฅ2-rUnitโ‰กrefl = refl -- rUnitโ‚– (definitional) 0-lUnitโ‰กrefl : lUnitโ‚– 0 (0โ‚– 0) โ‰ก refl 1-lUnitโ‰กrefl : lUnitโ‚– 1 (0โ‚– 1) โ‰ก refl nโ‰ฅ2-lUnitโ‰กrefl : {n : โ„•} โ†’ lUnitโ‚– (2 + n) (0โ‚– (2 + n)) โ‰ก refl 0-lUnitโ‰กrefl = refl 1-lUnitโ‰กrefl = refl nโ‰ฅ2-lUnitโ‰กrefl = refl -- assocโ‚– (definitional) 0-assocโ‰กrefl : assocโ‚– 0 (0โ‚– 0) (0โ‚– 0) (0โ‚– 0) โ‰ก refl 1-assocโ‰กrefl : assocโ‚– 1 (0โ‚– 1) (0โ‚– 1) (0โ‚– 1) โ‰ก refl nโ‰ฅ2-assocโ‰กrefl : {n : โ„•} โ†’ assocโ‚– (2 + n) (0โ‚– (2 + n)) (0โ‚– (2 + n)) (0โ‚– (2 + n)) โ‰ก refl 0-assocโ‰กrefl = refl 1-assocโ‰กrefl = refl nโ‰ฅ2-assocโ‰กrefl = refl -- commโ‚– (โ‰ก refl โˆ™ refl for n โ‰ฅ 2) 0-commโ‰กrefl : commโ‚– 0 (0โ‚– 0) (0โ‚– 0) โ‰ก refl 1-commโ‰กrefl : commโ‚– 1 (0โ‚– 1) (0โ‚– 1) โ‰ก refl nโ‰ฅ2-commโ‰กrefl : {n : โ„•} โ†’ commโ‚– (2 + n) (0โ‚– (2 + n)) (0โ‚– (2 + n)) โ‰ก refl 0-commโ‰กrefl = refl 1-commโ‰กrefl = refl nโ‰ฅ2-commโ‰กrefl = sym (rUnit refl) -- lCancelโ‚– (โ‰ก refl โˆ™ transport refl refl for n = 1 -- and transport refl refl โˆ™ transport refl refl for n โ‰ฅ 2) 0-lCancelโ‰กrefl : lCancelโ‚– 0 (0โ‚– 0) โ‰ก refl 1-lCancelโ‰กrefl : lCancelโ‚– 1 (0โ‚– 1) โ‰ก refl nโ‰ฅ2-lCancelโ‰กrefl : {n : โ„•} โ†’ lCancelโ‚– (2 + n) (0โ‚– (2 + n)) โ‰ก refl 0-lCancelโ‰กrefl = refl 1-lCancelโ‰กrefl = sym (lUnit _) โˆ™ transportRefl refl nโ‰ฅ2-lCancelโ‰กrefl = rCancel _ -- rCancelโ‚– (โ‰ก transport refl refl for n โ‰ฅ 1) 0-rCancelโ‰กrefl : rCancelโ‚– 0 (0โ‚– 0) โ‰ก refl 1-rCancelโ‰กrefl : rCancelโ‚– 1 (0โ‚– 1) โ‰ก refl nโ‰ฅ2-rCancelโ‰กrefl : {n : โ„•} โ†’ rCancelโ‚– (2 + n) (0โ‚– (2 + n)) โ‰ก refl 0-rCancelโ‰กrefl = refl 1-rCancelโ‰กrefl = transportRefl refl nโ‰ฅ2-rCancelโ‰กrefl = transportRefl refl -- Proof that there is a unique h-structure on Kโ‚™ -- +โ‚– defines an h-Structure on Kโ‚™ open GroupStructure using (_+โ‚–_ ; 0โ‚– ; rUnitโ‚– ; lUnitโ‚– ; lUnitโ‚–โ‰กrUnitโ‚–) -- and so does Brunerie's addition open oldCohom using (_+โ‚–_ ; 0โ‚– ; rUnitโ‚– ; lUnitโ‚– ; rUnitlUnit0) -- consequently both additions agree open GroupStructure using (+โ‚–-unique) open oldCohom using (addLemma) additionsAgree : (n : โ„•) โ†’ GroupStructure._+โ‚–_ {n = n} โ‰ก oldCohom._+โ‚–_ {n = n} additionsAgree zero i x y = oldCohom.addLemma x y (~ i) additionsAgree (suc n) i x y = +โ‚–-unique n (GroupStructure._+โ‚–_) (oldCohom._+โ‚–_) (GroupStructure.rUnitโ‚– (suc n)) (GroupStructure.lUnitโ‚– (suc n)) (oldCohom.rUnitโ‚– (suc n)) (oldCohom.lUnitโ‚– (suc n)) (sym (lUnitโ‚–โ‰กrUnitโ‚– (suc n))) (rUnitlUnit0 (suc n)) x y i -- The function ฯƒ : Kโ‚™ โ†’ ฮฉKโ‚™โ‚Šโ‚ open Properties using (ฯƒ) -- Theorem 1 (Kโ‚™ โ‰ƒ ฮฉKโ‚™โ‚Šโ‚) open Properties using (Knโ‰ƒฮฉKn+1) -- ฯƒ and ฯƒโปยน are morphisms -- (for ฯƒโปยน this is proved directly without using the fact that ฯƒ is a morphism) open Properties using (Knโ†’ฮฉKn+1-hom ; ฮฉKn+1โ†’Kn-hom) -- Lemma 2 (p โˆ™ q โ‰ก congยฒโ‚Š(p,q)) for n = 1 and n โ‰ฅ 2 respectively open GroupStructure using (โˆ™โ‰ก+โ‚ ; โˆ™โ‰ก+โ‚‚) -- Lemma 3 (congยฒโ‚Š is commutative) and Theorem 2 respectively open GroupStructure using (cong+โ‚–-comm ; isCommฮฉK) -- III.B Group structure on Hโฟ(A) -- +โ‚• (addition), -โ‚• and 0โ‚• open GroupStructure using (_+โ‚•_ ; -โ‚•_ ; 0โ‚•) -- Cohomology group structure open GroupStructure using ( rUnitโ‚• ; lUnitโ‚• ; rCancelโ‚• ; lCancelโ‚• ; commโ‚• ; assocโ‚•) -- Reduced cohomology, group structure open GroupStructure using (coHomRedGroupDir) -- Equality of unreduced and reduced cohmology open Properties using (coHomGroupโ‰กcoHomRedGroup) ----- IV. THE EILENBERG-STEENROD AXIOMS ----- -- IV.A The axioms in HoTT/UF -- The axioms are defined as a record type open ES-axioms.coHomTheory -- Proof of the claim that the alternative reduced cohomology functor -- Hฬ‚ is the same as the usual reduced cohomology functor _ : โˆ€ {โ„“} โ†’ satisfies-ES-axioms.H^~ {โ„“} โ‰ก satisfies-ES-axioms.Hฬ‚ _ = satisfies-ES-axioms.coHomFunctorโ‰กcoHomFunctor' -- IV.B Verifying the axioms -- Propositions 2 and 3. _ : โˆ€ {โ„“} โ†’ ES-axioms.coHomTheory {โ„“} satisfies-ES-axioms.H^~ _ = satisfies-ES-axioms.isCohomTheoryZ -- III.C Characterizing Z-cohomology groups using the axioms -- Theorem 3 open MayerVietoris.MV using ( Ker-iโŠ‚Im-d ; Im-dโŠ‚Ker-i ; Ker-ฮ”โŠ‚Im-i ; Im-iโŠ‚Ker-ฮ” ; Ker-dโŠ‚Im-ฮ” ; Im-ฮ”โŠ‚Ker-d) ----- V. CHARACTERIZING COHOMOLOGY GROUPS DIRECTLY ----- -- V.A -- Proposition 4 and 5 respectively open HโฟSโฟ using (Hโฟ-Sโฟโ‰…โ„ค ; Hโฟ-Sแตโ‰…1) -- V.B -- Proposition 6 and 7 respectively open HโฟTยฒ using (Hยน-Tยฒโ‰…โ„คร—โ„ค ; Hยฒ-Tยฒโ‰…โ„ค) -- V.C -- Proposition 8 and 9 respectively (Hโฟ(๐•‚ยฒ)) -- โ„ค/2โ„ค is represented by Bool with the unique group structure open Hโฟ๐•‚ยฒ using (Hยน-๐•‚ยฒโ‰…โ„ค ; Hยฒ-๐•‚ยฒโ‰…Bool) -- First and second cohomology groups of โ„Pยฒ respectively open Hโฟโ„Pยฒ using (Hยน-RPยฒโ‰…1 ; Hยฒ-RPยฒโ‰…Bool) ----- VI. COMPUTING WITH THE COHOMOLOGY GROUPS ----- import Cubical.Experiments.ZCohomology.Benchmarks
{ "alphanum_fraction": 0.6200234721, "avg_line_length": 31.6485714286, "ext": "agda", "hexsha": "d86632ba48302c5c2828bd46154f73ed0de2fc40", "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/Papers/ZCohomology.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Papers/ZCohomology.agda", "max_line_length": 90, "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/Papers/ZCohomology.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 4177, "size": 11077 }
{-# OPTIONS --cubical --safe #-} module Data.List.Mapping.StringMap where open import Data.String using (String; stringOrd) open import Data.List.Mapping stringOrd public open import Prelude open import Data.Maybe -- example : Record (โˆ… [ "name" ]๏ธ“ String [ "age" ]๏ธ“ โ„• [ "occ" ]๏ธ“ Bool) -- example = -- โˆ… [ "age" ]โ‰” 30 -- [ "occ" ]โ‰” true -- [ "name" ]โ‰” "Jo"
{ "alphanum_fraction": 0.6129032258, "avg_line_length": 24.8, "ext": "agda", "hexsha": "9e4aca304afc9dcad5264b583ffde4b97c14989f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z", "max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "oisdk/agda-playground", "max_forks_repo_path": "Data/List/Mapping/StringMap.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "oisdk/agda-playground", "max_issues_repo_path": "Data/List/Mapping/StringMap.agda", "max_line_length": 71, "max_stars_count": 6, "max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "oisdk/agda-playground", "max_stars_repo_path": "Data/List/Mapping/StringMap.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": 119, "size": 372 }
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Data.NatMinusOne.Base where open import Cubical.Core.Primitives open import Cubical.Data.Nat open import Cubical.Data.Empty open import Cubical.Data.Int.Base using (โ„ค; pos; negsuc; -_) record โ„•โ‚‹โ‚ : Typeโ‚€ where constructor -1+_ field n : โ„• pattern neg1 = -1+ zero pattern โ„•โ†’โ„•โ‚‹โ‚ n = -1+ (suc n) 1+_ : โ„•โ‚‹โ‚ โ†’ โ„• 1+_ (-1+ n) = n sucโ‚‹โ‚ : โ„•โ‚‹โ‚ โ†’ โ„•โ‚‹โ‚ sucโ‚‹โ‚ (-1+ n) = -1+ (suc n) -- Natural number and negative integer literals for โ„•โ‚‹โ‚ open import Cubical.Data.Nat.Literals public instance fromNatโ„•โ‚‹โ‚ : FromNat โ„•โ‚‹โ‚ fromNatโ„•โ‚‹โ‚ = record { Constraint = ฮป _ โ†’ โŠค ; fromNat = โ„•โ†’โ„•โ‚‹โ‚ } instance negativeโ„•โ‚‹โ‚ : Negative โ„•โ‚‹โ‚ negativeโ„•โ‚‹โ‚ = record { Constraint = ฮป { (suc (suc _)) โ†’ โŠฅ ; _ โ†’ โŠค } ; fromNeg = ฮป { zero โ†’ 0 ; (suc zero) โ†’ neg1 } }
{ "alphanum_fraction": 0.6305882353, "avg_line_length": 24.2857142857, "ext": "agda", "hexsha": "be040de923ad0fa61bdb654584d061a74db93c4a", "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/Data/NatMinusOne/Base.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Data/NatMinusOne/Base.agda", "max_line_length": 70, "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/Data/NatMinusOne/Base.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 321, "size": 850 }
module Luau.Syntax where open import Agda.Builtin.Equality using (_โ‰ก_) open import Agda.Builtin.Float using (Float) open import Properties.Dec using (โŠฅ) open import Luau.Var using (Var) open import Luau.Addr using (Addr) open import Luau.Type using (Type) infixr 5 _โˆ™_ data Annotated : Set where maybe : Annotated yes : Annotated data VarDec : Annotated โ†’ Set where var : Var โ†’ VarDec maybe var_โˆˆ_ : โˆ€ {a} โ†’ Var โ†’ Type โ†’ VarDec a name : โˆ€ {a} โ†’ VarDec a โ†’ Var name (var x) = x name (var x โˆˆ T) = x data FunDec : Annotated โ†’ Set where _โŸจ_โŸฉโˆˆ_ : โˆ€ {a} โ†’ Var โ†’ VarDec a โ†’ Type โ†’ FunDec a _โŸจ_โŸฉ : Var โ†’ VarDec maybe โ†’ FunDec maybe fun : โˆ€ {a} โ†’ FunDec a โ†’ Var fun (f โŸจ x โŸฉโˆˆ T) = f fun (f โŸจ x โŸฉ) = f arg : โˆ€ {a} โ†’ FunDec a โ†’ VarDec a arg (f โŸจ x โŸฉโˆˆ T) = x arg (f โŸจ x โŸฉ) = x data BinaryOperator : Set where + : BinaryOperator - : BinaryOperator * : BinaryOperator / : BinaryOperator data Block (a : Annotated) : Set data Stat (a : Annotated) : Set data Expr (a : Annotated) : Set data Block a where _โˆ™_ : Stat a โ†’ Block a โ†’ Block a done : Block a data Stat a where function_is_end : FunDec a โ†’ Block a โ†’ Stat a local_โ†_ : VarDec a โ†’ Expr a โ†’ Stat a return : Expr a โ†’ Stat a data Expr a where nil : Expr a var : Var โ†’ Expr a addr : Addr โ†’ Expr a _$_ : Expr a โ†’ Expr a โ†’ Expr a function_is_end : FunDec a โ†’ Block a โ†’ Expr a block_is_end : Var โ†’ Block a โ†’ Expr a number : Float โ†’ Expr a binexp : Expr a โ†’ BinaryOperator โ†’ Expr a โ†’ Expr a
{ "alphanum_fraction": 0.6336700337, "avg_line_length": 23.203125, "ext": "agda", "hexsha": "c1c31e4241a6e757edd7234607abfdcbdded61e6", "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": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_path": "prototyping/Luau/Syntax.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "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": "Tr4shh/Roblox-Luau", "max_issues_repo_path": "prototyping/Luau/Syntax.agda", "max_line_length": 52, "max_stars_count": null, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/Luau/Syntax.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 524, "size": 1485 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Component functions of permutations found in `Data.Fin.Permutation` ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Fin.Permutation.Components where open import Data.Fin open import Data.Fin.Properties open import Data.Nat as โ„• using (zero; suc; _โˆธ_) import Data.Nat.Properties as โ„•โ‚š open import Data.Product using (projโ‚‚) open import Relation.Nullary using (yes; no) open import Relation.Binary.PropositionalEquality open import Algebra.FunctionProperties using (Involutive) open โ‰ก-Reasoning -------------------------------------------------------------------------------- -- Functions -------------------------------------------------------------------------------- -- 'tranpose i j' swaps the places of 'i' and 'j'. transpose : โˆ€ {n} โ†’ Fin n โ†’ Fin n โ†’ Fin n โ†’ Fin n transpose i j k with k โ‰Ÿ i ... | yes _ = j ... | no _ with k โ‰Ÿ j ... | yes _ = i ... | no _ = k -- reverse i = n โˆธ 1 โˆธ i reverse : โˆ€ {n} โ†’ Fin n โ†’ Fin n reverse {zero} () reverse {suc n} i = injectโ‰ค (n โ„•- i) (โ„•โ‚š.nโˆธmโ‰คn (toโ„• i) (suc n)) -------------------------------------------------------------------------------- -- Properties -------------------------------------------------------------------------------- transpose-inverse : โˆ€ {n} (i j : Fin n) {k} โ†’ transpose i j (transpose j i k) โ‰ก k transpose-inverse i j {k} with k โ‰Ÿ j ... | yes p rewrite โ‰ก-โ‰Ÿ-identity _โ‰Ÿ_ {a = i} refl = sym p ... | no ยฌp with k โ‰Ÿ i transpose-inverse i j {k} | no ยฌp | yes q with j โ‰Ÿ i ... | yes r = trans r (sym q) ... | no ยฌr rewrite โ‰ก-โ‰Ÿ-identity _โ‰Ÿ_ {a = j} refl = sym q transpose-inverse i j {k} | no ยฌp | no ยฌq rewrite projโ‚‚ (โ‰ข-โ‰Ÿ-identity _โ‰Ÿ_ ยฌq) | projโ‚‚ (โ‰ข-โ‰Ÿ-identity _โ‰Ÿ_ ยฌp) = refl reverse-prop : โˆ€ {n} โ†’ (i : Fin n) โ†’ toโ„• (reverse i) โ‰ก n โˆธ suc (toโ„• i) reverse-prop {zero} () reverse-prop {suc n} i = begin toโ„• (injectโ‰ค (n โ„•- i) _) โ‰กโŸจ toโ„•-injectโ‰ค _ _ โŸฉ toโ„• (n โ„•- i) โ‰กโŸจ toโ„•โ€ฟโ„•- n i โŸฉ n โˆธ toโ„• i โˆŽ reverse-involutive : โˆ€ {n} โ†’ Involutive _โ‰ก_ (reverse {n}) reverse-involutive {zero} () reverse-involutive {suc n} i = toโ„•-injective (begin toโ„• (reverse (reverse i)) โ‰กโŸจ reverse-prop (reverse i) โŸฉ n โˆธ (toโ„• (reverse i)) โ‰กโŸจ cong (n โˆธ_) (reverse-prop i) โŸฉ n โˆธ (n โˆธ (toโ„• i)) โ‰กโŸจ โ„•โ‚š.mโˆธ[mโˆธn]โ‰กn (โ„•โ‚š.โ‰ค-pred (toโ„•<n i)) โŸฉ toโ„• i โˆŽ) reverse-suc : โˆ€ {n}{i : Fin n} โ†’ toโ„• (reverse (suc i)) โ‰ก toโ„• (reverse i) reverse-suc {n} {i} = begin toโ„• (reverse (suc i)) โ‰กโŸจ reverse-prop (suc i) โŸฉ suc n โˆธ suc (toโ„• (suc i)) โ‰กโŸจโŸฉ n โˆธ toโ„• (suc i) โ‰กโŸจโŸฉ n โˆธ suc (toโ„• i) โ‰กโŸจ sym (reverse-prop i) โŸฉ toโ„• (reverse i) โˆŽ
{ "alphanum_fraction": 0.470545977, "avg_line_length": 35.6923076923, "ext": "agda", "hexsha": "f6bfb50e81fd02a2e7bece4ec122831cf1c60775", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Fin/Permutation/Components.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Fin/Permutation/Components.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Fin/Permutation/Components.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 940, "size": 2784 }
{-# OPTIONS --cubical --safe #-} module Cubical.Foundations.Embedding where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Transport open import Cubical.Foundations.Isomorphism private variable โ„“ : Level A B : Type โ„“ f : A โ†’ B w x : A y z : B -- Embeddings are generalizations of injections. The usual -- definition of injection as: -- -- f x โ‰ก f y โ†’ x โ‰ก y -- -- is not well-behaved with higher h-levels, while embeddings -- are. isEmbedding : (A โ†’ B) โ†’ Type _ isEmbedding f = โˆ€ w x โ†’ isEquiv {A = w โ‰ก x} (cong f) isEmbeddingIsProp : isProp (isEmbedding f) isEmbeddingIsProp {f = f} = propPi ฮป w โ†’ propPi ฮป x โ†’ isPropIsEquiv (cong f) -- If A and B are h-sets, then injective functions between -- them are embeddings. -- -- Note: It doesn't appear to be possible to omit either of -- the `isSet` hypotheses. injEmbedding : {f : A โ†’ B} โ†’ isSet A โ†’ isSet B โ†’ (โˆ€{w x} โ†’ f w โ‰ก f x โ†’ w โ‰ก x) โ†’ isEmbedding f injEmbedding {f = f} iSA iSB inj w x = isoToIsEquiv (iso (cong f) inj sect retr) where sect : section (cong f) inj sect p = iSB (f w) (f x) _ p retr : retract (cong f) inj retr p = iSA w x _ p private lemmaโ‚€ : (p : y โ‰ก z) โ†’ fiber f y โ‰ก fiber f z lemmaโ‚€ {f = f} p = ฮป i โ†’ fiber f (p i) lemmaโ‚ : isEmbedding f โ†’ โˆ€ x โ†’ isContr (fiber f (f x)) lemmaโ‚ {f = f} iE x = value , path where value : fiber f (f x) value = (x , refl) path : โˆ€(fi : fiber f (f x)) โ†’ value โ‰ก fi path (w , p) i = case equiv-proof (iE w x) p of ฮป { ((q , sq) , _) โ†’ hfill (ฮป j โ†’ ฮป { (i = i0) โ†’ (x , refl) ; (i = i1) โ†’ (w , sq j) }) (inS (q (~ i) , ฮป j โ†’ f (q (~ i โˆจ j)))) i1 } -- If `f` is an embedding, we'd expect the fibers of `f` to be -- propositions, like an injective function. hasPropFibers : (A โ†’ B) โ†’ Type _ hasPropFibers f = โˆ€ y โ†’ isProp (fiber f y) hasPropFibersIsProp : isProp (hasPropFibers f) hasPropFibersIsProp = propPi (ฮป _ โ†’ isPropIsProp) isEmbeddingโ†’hasPropFibers : isEmbedding f โ†’ hasPropFibers f isEmbeddingโ†’hasPropFibers iE y (x , p) = subst (ฮป f โ†’ isProp f) (lemmaโ‚€ p) (isContrโ†’isProp (lemmaโ‚ iE x)) (x , p) private fibCongโ†’PathP : {f : A โ†’ B} โ†’ (p : f w โ‰ก f x) โ†’ (fi : fiber (cong f) p) โ†’ PathP (ฮป i โ†’ fiber f (p i)) (w , refl) (x , refl) fibCongโ†’PathP p (q , r) i = q i , ฮป j โ†’ r j i PathPโ†’fibCong : {f : A โ†’ B} โ†’ (p : f w โ‰ก f x) โ†’ (pp : PathP (ฮป i โ†’ fiber f (p i)) (w , refl) (x , refl)) โ†’ fiber (cong f) p PathPโ†’fibCong p pp = (ฮป i โ†’ fst (pp i)) , (ฮป j i โ†’ snd (pp i) j) PathPโ‰กfibCong : {f : A โ†’ B} โ†’ (p : f w โ‰ก f x) โ†’ PathP (ฮป i โ†’ fiber f (p i)) (w , refl) (x , refl) โ‰ก fiber (cong f) p PathPโ‰กfibCong p = isoToPath (iso (PathPโ†’fibCong p) (fibCongโ†’PathP p) (ฮป _ โ†’ refl) (ฮป _ โ†’ refl)) hasPropFibersโ†’isEmbedding : hasPropFibers f โ†’ isEmbedding f hasPropFibersโ†’isEmbedding {f = f} iP w x .equiv-proof p = subst isContr (PathPโ‰กfibCong p) (isPropโ†’isContrPathP iP p fw fx) where fw : fiber f (f w) fw = (w , refl) fx : fiber f (f x) fx = (x , refl) isEmbeddingโ‰กhasPropFibers : isEmbedding f โ‰ก hasPropFibers f isEmbeddingโ‰กhasPropFibers = isoToPath (iso isEmbeddingโ†’hasPropFibers hasPropFibersโ†’isEmbedding (ฮป _ โ†’ hasPropFibersIsProp _ _) (ฮป _ โ†’ isEmbeddingIsProp _ _))
{ "alphanum_fraction": 0.5960828839, "avg_line_length": 27.7401574803, "ext": "agda", "hexsha": "a89627c264d41f0d320627e8bc6e4e54b604f560", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cj-xu/cubical", "max_forks_repo_path": "Cubical/Foundations/Embedding.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cj-xu/cubical", "max_issues_repo_path": "Cubical/Foundations/Embedding.agda", "max_line_length": 81, "max_stars_count": null, "max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cj-xu/cubical", "max_stars_repo_path": "Cubical/Foundations/Embedding.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1330, "size": 3523 }
module ModuleDoesntExport where module A where postulate C : Set open A using (B; module P) renaming (D to C)
{ "alphanum_fraction": 0.7304347826, "avg_line_length": 14.375, "ext": "agda", "hexsha": "0cc3aa5118fa01f6e1cecc78bd4ad00102d9af39", "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/ModuleDoesntExport.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/ModuleDoesntExport.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/Succeed/ModuleDoesntExport.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": 33, "size": 115 }
{-# OPTIONS --without-K --safe #-} open import Level using (Level) open import Relation.Binary.PropositionalEquality hiding (Extensionality) open โ‰ก-Reasoning open import Data.Nat using (โ„•; suc; zero; _+_) open import Data.Nat.Properties open import Data.Product using (_,_) open import Data.Vec using (Vec; foldr; zipWith; map; []; _โˆท_; _++_; take; drop; splitAt; replicate) open import Data.Vec.Properties module FLA.Data.Vec.Properties where private variable โ„“ : Level A B C : Set โ„“ m n : โ„• ++-identityโ‚— : (v : Vec A n) โ†’ [] ++ v โ‰ก v ++-identityโ‚— _ = refl
{ "alphanum_fraction": 0.6844827586, "avg_line_length": 23.2, "ext": "agda", "hexsha": "716a6ee4768984736d8a6c6e5646421153220434", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2021-09-07T19:55:59.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-12T20:34:17.000Z", "max_forks_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "turion/functional-linear-algebra", "max_forks_repo_path": "src/FLA/Data/Vec/Properties.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_issues_repo_issues_event_max_datetime": "2022-01-07T05:27:53.000Z", "max_issues_repo_issues_event_min_datetime": "2020-09-01T01:42:12.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "turion/functional-linear-algebra", "max_issues_repo_path": "src/FLA/Data/Vec/Properties.agda", "max_line_length": 100, "max_stars_count": 21, "max_stars_repo_head_hexsha": "375475a2daa57b5995ceb78b4bffcbfcbb5d8898", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "turion/functional-linear-algebra", "max_stars_repo_path": "src/FLA/Data/Vec/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-07T05:28:00.000Z", "max_stars_repo_stars_event_min_datetime": "2020-09-22T20:49:34.000Z", "num_tokens": 174, "size": 580 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Indexed M-types (the dual of indexed W-types aka Petersson-Synek -- trees). ------------------------------------------------------------------------ module Data.M.Indexed where open import Level open import Coinduction open import Data.Product open import Data.Container.Indexed.Core open import Function open import Relation.Unary -- The family of indexed M-types. module _ {โ„“ c r} {O : Set โ„“} (C : Container O O c r) where data M (o : O) : Set (โ„“ โŠ” c โŠ” r) where inf : โŸฆ C โŸง (โˆž โˆ˜ M) o โ†’ M o open Container C -- Projections. head : M โІ Command head (inf (c , _)) = c tail : โˆ€ {o} (m : M o) (r : Response (head m)) โ†’ M (next (head m) r) tail (inf (_ , k)) r = โ™ญ (k r) force : M โІ โŸฆ C โŸง M force (inf (c , k)) = c , ฮป r โ†’ โ™ญ (k r) -- Coiteration. coit : โˆ€ {โ„“} {X : Pred O โ„“} โ†’ X โІ โŸฆ C โŸง X โ†’ X โІ M coit ฯˆ x = inf (projโ‚ cs , ฮป r โ†’ โ™ฏ coit ฯˆ (projโ‚‚ cs r)) where cs = ฯˆ x
{ "alphanum_fraction": 0.4911764706, "avg_line_length": 23.7209302326, "ext": "agda", "hexsha": "efd87f9d0899f521e5a92c35deec456278a95c34", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/M/Indexed.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/M/Indexed.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/M/Indexed.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 335, "size": 1020 }
{-# OPTIONS --without-K #-} module function.isomorphism.two-out-of-six where open import sum open import equality open import function.core open import function.isomorphism.core open import function.overloading open import hott.equivalence.core open import hott.equivalence.biinvertible module two-out-of-six {i j k l}{X : Set i}{Y : Set j}{Z : Set k}{W : Set l} (f : X โ†’ Y)(g : Y โ†’ Z)(h : Z โ†’ W) (gf-equiv : weak-equiv (g โˆ˜ f)) (hg-equiv : weak-equiv (h โˆ˜ g)) where private r : X โ‰… Z r = โ‰ˆโ‡’โ‰… (g โˆ˜ f , gf-equiv) s : Y โ‰… W s = โ‰ˆโ‡’โ‰… (h โˆ˜ g , hg-equiv) gl : Z โ†’ Y gl = invert s โˆ˜ h gr : Z โ†’ Y gr = f โˆ˜ invert r g-iso : Y โ‰… Z g-iso = bโ‡’โ‰… (g , (gl , _โ‰…_.isoโ‚ s) , (gr , _โ‰…_.isoโ‚‚ r)) f-iso : X โ‰… Y f-iso = record { to = f ; from = ฮป y โ†’ invert r (g y) ; isoโ‚ = _โ‰…_.isoโ‚ r ; isoโ‚‚ = ฮป y โ†’ sym (_โ‰…_.isoโ‚ g-iso (f (invert r (g y)))) ยท ap (invert g-iso) (_โ‰…_.isoโ‚‚ r (g y)) ยท _โ‰…_.isoโ‚ g-iso y } h-iso : Z โ‰… W h-iso = record { to = h ; from = ฮป w โ†’ g (invert s w) ; isoโ‚ = ฮป z โ†’ sym (ap (ฮป z โ†’ g (invert s (h z))) (_โ‰…_.isoโ‚‚ g-iso z)) ยท ap g (_โ‰…_.isoโ‚ s (invert g-iso z)) ยท _โ‰…_.isoโ‚‚ g-iso z ; isoโ‚‚ = _โ‰…_.isoโ‚‚ s }
{ "alphanum_fraction": 0.4937888199, "avg_line_length": 25.76, "ext": "agda", "hexsha": "6ffefed050c26399766c28dc1e294f987844bba5", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/function/isomorphism/two-out-of-six.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/function/isomorphism/two-out-of-six.agda", "max_line_length": 73, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/function/isomorphism/two-out-of-six.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 500, "size": 1288 }
module _ {I : Set} where postulate f : โˆ€ {T : I โ†’ Set} {i} โ†’ T i โ†’ Set variable i : I T : I โ†’ Set v : T i t : f v t = {!!}
{ "alphanum_fraction": 0.437037037, "avg_line_length": 9.6428571429, "ext": "agda", "hexsha": "4fc1774492e4623f77b0f550c13b8e659ea66e21", "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/Issue3401.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/Issue3401.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/Fail/Issue3401.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": 62, "size": 135 }
{- Definition of finite sets A set is finite if it is merely equivalent to `Fin n` for some `n`. We can translate this to code in two ways: a truncated sigma of a nat and an equivalence, or a sigma of a nat and a truncated equivalence. We prove that both formulations are equivalent. -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.FinSet where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Logic open import Cubical.Foundations.Function open import Cubical.Foundations.Structure open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Equiv open import Cubical.HITs.PropositionalTruncation open import Cubical.Data.Unit open import Cubical.Data.Nat open import Cubical.Data.Fin open import Cubical.Data.Sigma private variable โ„“ : Level A : Type โ„“ isFinSet : Type โ„“ โ†’ Type โ„“ isFinSet A = โˆƒ[ n โˆˆ โ„• ] A โ‰ƒ Fin n isProp-isFinSet : isProp (isFinSet A) isProp-isFinSet = propTruncIsProp FinSet : Type (โ„“-suc โ„“) FinSet = TypeWithStr _ isFinSet isFinSetFin : โˆ€ {n} โ†’ isFinSet (Fin n) isFinSetFin = โˆฃ _ , pathToEquiv refl โˆฃ isFinSetUnit : isFinSet Unit isFinSetUnit = โˆฃ 1 , Unitโ‰ƒFin1 โˆฃ isFinSetฮฃ : Type โ„“ โ†’ Type โ„“ isFinSetฮฃ A = ฮฃ[ n โˆˆ โ„• ] โˆฅ A โ‰ƒ Fin n โˆฅ FinSetฮฃ : Type (โ„“-suc โ„“) FinSetฮฃ = TypeWithStr _ isFinSetฮฃ isProp-isFinSetฮฃ : isProp (isFinSetฮฃ A) isProp-isFinSetฮฃ {A = A} (n , equivn) (m , equivm) = ฮฃโ‰กProp (ฮป _ โ†’ propTruncIsProp) nโ‰กm where Fin-nโ‰ƒFin-m : โˆฅ Fin n โ‰ƒ Fin m โˆฅ Fin-nโ‰ƒFin-m = rec propTruncIsProp (rec (isPropฮ  ฮป _ โ†’ propTruncIsProp) (ฮป hm hn โ†’ โˆฃ Fin n โ‰ƒโŸจ invEquiv hn โŸฉ A โ‰ƒโŸจ hm โŸฉ Fin m โ–  โˆฃ) equivm ) equivn Fin-nโ‰กFin-m : โˆฅ Fin n โ‰ก Fin m โˆฅ Fin-nโ‰กFin-m = rec propTruncIsProp (โˆฃ_โˆฃ โˆ˜ ua) Fin-nโ‰ƒFin-m โˆฅnโ‰กmโˆฅ : โˆฅ n โ‰ก m โˆฅ โˆฅnโ‰กmโˆฅ = rec propTruncIsProp (โˆฃ_โˆฃ โˆ˜ Fin-inj n m) Fin-nโ‰กFin-m nโ‰กm : n โ‰ก m nโ‰กm = rec (isSetโ„• n m) (ฮป p โ†’ p) โˆฅnโ‰กmโˆฅ isFinSetโ‰กisFinSetฮฃ : isFinSet A โ‰ก isFinSetฮฃ A isFinSetโ‰กisFinSetฮฃ {A = A} = hPropExt isProp-isFinSet isProp-isFinSetฮฃ to from where to : isFinSet A โ†’ isFinSetฮฃ A to โˆฃ n , equiv โˆฃ = n , โˆฃ equiv โˆฃ to (squash p q i) = isProp-isFinSetฮฃ (to p) (to q) i from : isFinSetฮฃ A โ†’ isFinSet A from (n , โˆฃ isFinSet-A โˆฃ) = โˆฃ n , isFinSet-A โˆฃ from (n , squash p q i) = isProp-isFinSet (from (n , p)) (from (n , q)) i FinSetโ‰กFinSetฮฃ : FinSet {โ„“} โ‰ก FinSetฮฃ FinSetโ‰กFinSetฮฃ = ua (isoToEquiv (iso to from to-from from-to)) where to : FinSet โ†’ FinSetฮฃ to (A , isFinSetA) = A , transport isFinSetโ‰กisFinSetฮฃ isFinSetA from : FinSetฮฃ โ†’ FinSet from (A , isFinSetฮฃA) = A , transport (sym isFinSetโ‰กisFinSetฮฃ) isFinSetฮฃA to-from : โˆ€ A โ†’ to (from A) โ‰ก A to-from A = ฮฃโ‰กProp (ฮป _ โ†’ isProp-isFinSetฮฃ) refl from-to : โˆ€ A โ†’ from (to A) โ‰ก A from-to A = ฮฃโ‰กProp (ฮป _ โ†’ isProp-isFinSet) refl card : FinSet {โ„“} โ†’ โ„• card = fst โˆ˜ snd โˆ˜ transport FinSetโ‰กFinSetฮฃ
{ "alphanum_fraction": 0.6568127761, "avg_line_length": 27.7641509434, "ext": "agda", "hexsha": "791a2cc10ebf0337972f6f334602feab6cc108c1", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_path": "Cubical/Data/FinSet.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "knrafto/cubical", "max_issues_repo_path": "Cubical/Data/FinSet.agda", "max_line_length": 78, "max_stars_count": null, "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_path": "Cubical/Data/FinSet.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1181, "size": 2943 }
module Data.Collection.Core where open import Data.List public using (List; []; _โˆท_) open import Data.String public using (String; _โ‰Ÿ_) open import Level using (zero) open import Function using (flip) open import Relation.Nullary open import Relation.Nullary.Negation open import Relation.Nullary.Decidable renaming (map to mapDec; mapโ€ฒ to mapDecโ€ฒ) open import Relation.Unary open import Relation.Binary open import Relation.Binary.PropositionalEquality -------------------------------------------------------------------------------- -- Types -------------------------------------------------------------------------------- Element : Set Element = String Collection : Set Collection = List Element Membership : Set _ Membership = Pred Element zero -------------------------------------------------------------------------------- -- Membership -------------------------------------------------------------------------------- infix 4 _โˆˆc_ _โˆ‰c_ data _โˆˆc_ : REL Element Collection zero where here : โˆ€ { x A} โ†’ x โˆˆc x โˆท A there : โˆ€ {a x A} โ†’ x โˆˆc A โ†’ x โˆˆc a โˆท A _โˆ‰c_ : REL Element Collection _ x โˆ‰c A = ยฌ x โˆˆc A infixr 6 _โŠˆ_ -- I know this notation is a bit confusing _โŠˆ_ : โˆ€ {a โ„“โ‚ โ„“โ‚‚} {A : Set a} โ†’ Pred A โ„“โ‚ โ†’ Pred A โ„“โ‚‚ โ†’ Set _ P โŠˆ Q = โˆ€ {x} โ†’ x โˆ‰ P โ†’ x โˆ‰ Q c[_] : REL Collection Element zero c[_] = flip _โˆˆc_ infix 4 _โˆˆ?_ _โˆˆ?_ : (x : Element) โ†’ (A : Collection) โ†’ Dec (x โˆˆ c[ A ]) x โˆˆ? [] = no (ฮป ()) x โˆˆ? ( a โˆท A) with x โ‰Ÿ a x โˆˆ? (.x โˆท A) | yes refl = yes here x โˆˆ? ( a โˆท A) | no ยฌp = mapDecโ€ฒ there (there-if-not-here ยฌp) (x โˆˆ? A) where there-if-not-here : โˆ€ {x a A} โ†’ x โ‰ข a โ†’ x โˆˆ c[ a โˆท A ] โ†’ x โˆˆ c[ A ] there-if-not-here xโ‰ขa here = contradiction refl xโ‰ขa there-if-not-here xโ‰ขa (there xโˆˆaโˆทA) = xโˆˆaโˆทA -------------------------------------------------------------------------------- -- Miscs -------------------------------------------------------------------------------- -- -- โˆท-โІ-monotone : โˆ€ {a A B} โ†’ c[ A ] โІ c[ B ] โ†’ c[ a โˆท A ] โІ c[ a โˆท B ] -- โˆท-โІ-monotone f here = here -- โˆท-โІ-monotone f (there โˆˆA) = there (f โˆˆA)
{ "alphanum_fraction": 0.4503061705, "avg_line_length": 30.768115942, "ext": "agda", "hexsha": "0af8dee271db875cf28ab8e084757cf5e3a42091", "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": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "banacorn/lambda-calculus", "max_forks_repo_path": "Data/Collection/Core.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a", "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/lambda-calculus", "max_issues_repo_path": "Data/Collection/Core.agda", "max_line_length": 80, "max_stars_count": null, "max_stars_repo_head_hexsha": "f81b116473582ab7956adc4bf1d7ebf1ae2a213a", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "banacorn/lambda-calculus", "max_stars_repo_path": "Data/Collection/Core.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 628, "size": 2123 }
------------------------------------------------------------------------ -- Parser monad ------------------------------------------------------------------------ open import Relation.Binary open import Relation.Binary.OrderMorphism open import Relation.Binary.PropositionalEquality hiding (poset) import Relation.Binary.Properties.StrictTotalOrder as STOProps open import Data.Product open import Level module MonadPostulates where postulate -- Input string positions. Position : Set _<P_ : Rel Position zero posOrdered : IsStrictTotalOrder _โ‰ก_ _<P_ -- Input strings. Input : Position -> Set -- In order to be able to store results in a memo table (and avoid -- having to lift the table code to Set1) the result types have to -- come from the following universe: Result : Set โŸฆ_โŸง : Result -> Set -- Memoisation keys. These keys must uniquely identify the -- computation that they are associated with, when paired up with -- the current input string position. Key : let PosPoset = STOProps.poset (record { Carrier = _ ; _โ‰ˆ_ = _; _<_ = _ ; isStrictTotalOrder = posOrdered }) MonoFun = PosPoset โ‡’-Poset PosPoset in MonoFun -> Result -> Set _โ‰ˆ'_ _<_ : Rel (โˆƒโ‚‚ Key) zero keyOrdered : IsStrictTotalOrder _โ‰ˆ'_ _<_ -- Furthermore the underlying equality needs to be strong enough. funsEqual : _โ‰ˆ'_ =[ projโ‚ ]โ‡’ _โ‰ก_ resultsEqual : _โ‰ˆ'_ =[ (\rfk -> projโ‚ (projโ‚‚ rfk)) ]โ‡’ _โ‰ก_ -- where open _โ‡’-Poset_ open STOProps (record { Carrier = _ ; _โ‰ˆ_ = _; _<_ = _ ; isStrictTotalOrder = posOrdered }) import IndexedMap as Map -- renaming (Map to MemoTable) open import Effect.Monad open import Effect.Monad.State import Data.List as List; open List using (List) open import Data.Unit open import Function open import Data.Maybe open import Data.Product.Relation.Binary.Lex.Strict open import Data.Product.Relation.Binary.Pointwise.NonDependent import Relation.Binary.Construct.On as On ------------------------------------------------------------------------ -- Monotone functions MonoFun : Set MonoFun = poset โ‡’-Poset poset ------------------------------------------------------------------------ -- Memo tables -- Indices and keys used by the memo table. Index : Set Index = Position ร— MonoFun ร— Result data MemoTableKey : Index -> Set where key : forall {f r} (key : Key f r) pos -> MemoTableKey (pos , f , r) -- Input strings of a certain maximum length. Inputโ‰ค : Position -> Set Inputโ‰ค pos = โˆƒ \posโ€ฒ -> posโ€ฒ โ‰ค pos ร— Input posโ€ฒ -- Memo table values. Value : Index -> Set Value (pos , f , r) = List (โŸฆ r โŸง ร— Inputโ‰ค (fun f pos)) -- Shuffles the elements to simplify defining equality and order -- relations for the keys. shuffle : โˆƒ MemoTableKey -> Position ร— โˆƒโ‚‚ Key shuffle ((pos , f , r) , key k .pos) = (pos , f , r , k) -- Equality and order. Eq : Rel (โˆƒ MemoTableKey) _ Eq = Pointwise _โ‰ก_ _โ‰ˆ'_ on shuffle Lt : Rel (โˆƒ MemoTableKey) _ Lt = ร—-Lex _โ‰ก_ _<P_ _<_ on shuffle isOrdered : IsStrictTotalOrder Eq Lt isOrdered = On.isStrictTotalOrder shuffle (ร—-isStrictTotalOrder posOrdered keyOrdered) indicesEqualโ€ฒ : Eq =[ projโ‚ ]โ‡’ _โ‰ก_ indicesEqualโ€ฒ {((_ , _ , _) , key _ ._)} {((_ , _ , _) , key _ ._)} (eqโ‚ , eqโ‚‚) = congโ‚‚ _,_ eqโ‚ (congโ‚‚ _,_ (funsEqual eqโ‚‚) (resultsEqual eqโ‚‚)) open Map isOrdered (\{kโ‚} {kโ‚‚} -> indicesEqualโ€ฒ {kโ‚} {kโ‚‚}) Value {- ------------------------------------------------------------------------ -- Parser monad -- The parser monad is built upon a list monad, for backtracking, and -- two state monads. One of the state monads stores a memo table, and -- is unaffected by backtracking. The other state monad, which /is/ -- affected by backtracking, stores the remaining input string. -- The memo table state monad. module MemoState = RawMonadState (StateMonadState MemoTable) -- The list monad. module List = RawMonadPlus List.ListMonadPlus -- The inner monad (memo table plus list). module IM where Inner : Set -> Set Inner R = State MemoTable (List R) InnerMonadPlus : RawMonadPlus Inner InnerMonadPlus = record { monadZero = record { monad = record { return = \x -> return (List.return x) ; _>>=_ = \m f -> List.concat <$> (List.mapM monad f =<< m) } ; โˆ… = return List.โˆ… } ; _โˆฃ_ = \mโ‚ mโ‚‚ -> List._โˆฃ_ <$> mโ‚ โŠ› mโ‚‚ } where open MemoState InnerMonadState : RawMonadState MemoTable Inner InnerMonadState = record { monad = RawMonadPlus.monad InnerMonadPlus ; get = List.return <$> get ; put = \s -> List.return <$> put s } where open MemoState open RawMonadPlus InnerMonadPlus public open RawMonadState InnerMonadState public using (get; put; modify) -- The complete parser monad. module PM where P : MonoFun -> Set -> Set P f A = forall {n} -> Input n -> IM.Inner (A ร— Inputโ‰ค (fun f n)) -- Memoises the computation, assuming that the key is sufficiently -- unique. memoise : forall {f r} -> Key f r -> P f โŸฆ r โŸง -> P f โŸฆ r โŸง memoise k p {pos} xs = let open IM in helper =<< lookup kโ€ฒ <$> get where i = (pos , _) kโ€ฒ : MemoTableKey i kโ€ฒ = key k pos helper : Maybe (Value i) -> State MemoTable (Value i) helper (just ris) = return ris where open MemoState helper nothing = p xs >>= \ris -> modify (insert kโ€ฒ ris) >> return ris where open MemoState -- Other monadic operations. return : forall {A} -> A -> P idM A return a = \xs -> IM.return (a , _ , refl , xs) _>>=_ : forall {A B f g} -> P f A -> (A -> P g B) -> P (g โˆ˜M f) B _>>=_ {g = g} mโ‚ mโ‚‚ xs = mโ‚ xs โŸจ IM._>>=_ โŸฉ \ays -> let a = projโ‚ ays le = projโ‚ $ projโ‚‚ $ projโ‚‚ ays ys = projโ‚‚ $ projโ‚‚ $ projโ‚‚ ays in fix le โŸจ IM._<$>_ โŸฉ mโ‚‚ a ys where lemma : forall {i j k} -> j โ‰ค k -> i โ‰ค fun g j -> i โ‰ค fun g k lemma jโ‰คk iโ‰คgj = trans iโ‰คgj (monotone g jโ‰คk) fix : forall {A i j} -> i โ‰ค j -> A ร— Inputโ‰ค (fun g i) -> A ร— Inputโ‰ค (fun g j) fix le = map-ร— id (map-ฮฃ id (map-ร— (lemma le) id)) โˆ… : forall {A} -> P idM A โˆ… = const IM.โˆ… _โˆฃ_ : forall {A f} -> P f A -> P f A -> P f A mโ‚ โˆฃ mโ‚‚ = \xs -> IM._โˆฃ_ (mโ‚ xs) (mโ‚‚ xs) put : forall {n} -> Input n -> P (constM n) โŠค put xs = \_ -> IM.return (_ , _ , refl , xs) modify : forall {A f} -> (forall {n} -> Input n -> A ร— Input (fun f n)) -> P f A modify g xs = IM.return (projโ‚ gxs , _ , refl , projโ‚‚ gxs) where gxs = g xs -}
{ "alphanum_fraction": 0.5777272727, "avg_line_length": 28.6956521739, "ext": "agda", "hexsha": "ebe16f2e27a97e320bdb2786a165aa3e8dc9f76d", "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": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "KDr2/agda", "max_forks_repo_path": "benchmark/monad/MonadPostulates.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "KDr2/agda", "max_issues_repo_path": "benchmark/monad/MonadPostulates.agda", "max_line_length": 72, "max_stars_count": null, "max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "KDr2/agda", "max_stars_repo_path": "benchmark/monad/MonadPostulates.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1943, "size": 6600 }
module Prelude where infixr 50 _,_ infixl 40 _โ—„_ infix 30 _โˆˆ_ data _ร—_ (A B : Set) : Set where _,_ : A -> B -> A ร— B data List (A : Set) : Set where ฮต : List A _โ—„_ : List A -> A -> List A data _โˆˆ_ {A : Set}(x : A) : List A -> Set where hd : forall {xs} -> x โˆˆ xs โ—„ x tl : forall {y xs} -> x โˆˆ xs -> x โˆˆ xs โ—„ y data Box {A : Set}(P : A -> Set) : List A -> Set where โŸจโŸฉ : Box P ฮต _โ—ƒ_ : forall {xs x} -> Box P xs -> P x -> Box P (xs โ—„ x) _!_ : {A : Set}{P : A -> Set}{xs : List A}{x : A} -> Box P xs -> x โˆˆ xs -> P x โŸจโŸฉ ! () (_ โ—ƒ v) ! hd = v (ฯ โ—ƒ _) ! tl x = ฯ ! x
{ "alphanum_fraction": 0.4413680782, "avg_line_length": 21.1724137931, "ext": "agda", "hexsha": "344b77163f73c18e4a32fcbc49822240e82fa685", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/sinatra/Prelude.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/sinatra/Prelude.agda", "max_line_length": 58, "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/sinatra/Prelude.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": 270, "size": 614 }
-- This module introduces the basic structure of an Agda program. {- Every Agda file contains a single top-level module. To make it possible to find the file corresponding to a particular module, the name of the file should correspond to the name of the module. In this case the module 'Introduction.Basics' is defined in the file 'Introduction/Basics.agda'. -} module Basics where {- The top-level module contains a sequence of declarations, such as datatype declarations and function definitions. The most common forms of declarations are introduced below. A module can also contain sub-modules, see 'Introduction.Modules.SubModules' for more information. -} -- Agda can be used as a pure logical framework. The 'postulate' declaration -- introduces new constants : postulate N : Set -- Set is the first universe z : N s : N -> N -- The independent function space is written A -> B -- Using 'postulate' it is not possible to introduce new computation rules. A -- better way is to introduce a datatype and define functions by pattern -- matching on elements of the datatype. -- A datatype is introduced with the 'data' keyword. All constructors of the -- datatype are given with their types after the 'where'. Datatypes can be -- parameterised (see 'Introduction.Data.Parameterised'). data Bool : Set where false : Bool true : Bool data Nat : Set where zero : Nat suc : Nat -> Nat -- Functions over datatypes can be defined by pattern matching. plus : Nat -> Nat -> Nat plus zero m = m plus (suc n) m = suc (plus n m) -- With this definition plus (suc zero) (suc zero) will reduce to suc (suc -- zero). -- When defining mutually recursive functions you have to declare functions -- before they can be called. odd : Nat -> Bool even : Nat -> Bool even (suc n) = odd n even zero = true odd zero = false odd (suc n) = even n -- Agda is a monomorphic, but dependently typed, language. This means that -- polymorphism is simulated by having functions take type arguments. For -- instance, the polymorphic identity function can be represented as follows : id : (A : Set) -> A -> A -- the dependent function space is written (x : A) -> B id A x = x one : Nat one = id Nat (suc zero) -- a silly use of the identity function -- To faithfully simulate a polymorphic function we would like to omit the type -- argument when using the function. See 'Introduction.Implicit' for -- information on how to do this. -- Agda is both a programming language and a formal proof language, so we -- expect to be able to prove theorems about our programs. As an example we -- prove the very simple theorem n + 0 == n. -- First we introduce datatypes for truth (a singleton type) and falsity (an -- empty type). data True : Set where -- Here it would make sense to declare True to be a tt : True -- Prop (the universe of propositions) rather than a -- Set. See 'Introduction.Universes' for more -- information. data False : Set where -- see 'Introduction.Data.Empty' for more information -- on empty types. -- Second, we define what it means for two natural numbers to be equal. Infix -- operators are declared by enclosing the operator in _. See -- 'Introduction.Operators' for more information. _==_ : Nat -> Nat -> Set zero == zero = True zero == suc m = False suc n == zero = False suc n == suc m = n == m -- Now we are ready to state and prove our theorem. The proof is by induction -- (i.e. recursion) on 'n'. thmPlusZero : (n : Nat) -> plus n zero == n -- A function from a number n to -- P n can be seen as the -- proposition โˆ€ n. P n. thmPlusZero zero = tt thmPlusZero (suc n) = thmPlusZero n thmPlusZero' : (n : Nat) -> plus zero n == n thmPlusZero' zero = tt thmPlusZero' (suc n) = thmPlusZero' n {- In both branches the reduction makes the proof very simple. In the first case the goal is plus zero zero == zero which reduces to zero == zero and True In the second case we have plus (suc n) zero == suc n suc (plus n zero) == suc n plus n zero == n so the induction hypothesis (the recursive call) is directly applicable. -}
{ "alphanum_fraction": 0.6731920774, "avg_line_length": 33.1450381679, "ext": "agda", "hexsha": "75f5723f471d5967d094d40abed113f62ff0b9c8", "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": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_path": "tests/covered/Basics.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "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": "andrejtokarcik/agda-semantics", "max_issues_repo_path": "tests/covered/Basics.agda", "max_line_length": 87, "max_stars_count": 3, "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_path": "tests/covered/Basics.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "num_tokens": 1080, "size": 4342 }
module nat-division where open import bool open import bool-thms open import eq open import neq open import nat open import nat-thms open import product open import product-thms open import sum {- a div-result for dividend x and divisor d consists of the quotient q, remainder r, and a proof that q * d + r = x -} div-result : โ„• โ†’ โ„• โ†’ Set div-result x d = ฮฃ โ„• (ฮป q โ†’ ฮฃ โ„• (ฮป r โ†’ q * d + r โ‰ก x โˆง r < d โ‰ก tt)) -- we use an upper bound n on the dividend x. For an alternative approach, see nat-division-wf.agda. divh : (n : โ„•) โ†’ (x : โ„•) โ†’ (y : โ„•) โ†’ x โ‰ค n โ‰ก tt โ†’ y =โ„• 0 โ‰ก ff โ†’ div-result x y divh 0 0 0 p1 () divh 0 0 (suc y) p1 p2 = 0 , 0 , refl , refl divh 0 (suc x) y () p2 divh (suc n) x y p1 p2 with keep (x < y) divh (suc n) x y p1 p2 | tt , pl = 0 , x , refl , pl divh (suc n) x y p1 p2 | ff , pl with divh n (x โˆธ y) y (โˆธโ‰ค2 n x y p1 p2) p2 divh (suc n) x y p1 p2 | ff , pl | q , r , pa , pb = suc q , r , lem{q}{r} pa , pb where lem : โˆ€{q r} โ†’ q * y + r โ‰ก x โˆธ y โ†’ y + q * y + r โ‰ก x lem{q}{r} p rewrite sym (+assoc y (q * y) r) | p | +comm y (x โˆธ y) = โˆธ+2{x}{y} (<ff{x}{y} pl) -- the div-result contains the quotient, remainder, and proof relating them to the inputs _รท_!_ : (x : โ„•) โ†’ (y : โ„•) โ†’ y =โ„• 0 โ‰ก ff โ†’ div-result x y x รท y ! p = divh x x y (โ‰ค-refl x) p -- return a pair of the quotient and remainder _รท_!!_ : โ„• โ†’ (y : โ„•) โ†’ y =โ„• 0 โ‰ก ff โ†’ โ„• ร— โ„• x รท y !! p with x รท y ! p ... | q , r , p' = q , r -- return the quotient only _รท_div_ : โ„• โ†’ (y : โ„•) โ†’ y =โ„• 0 โ‰ก ff โ†’ โ„• x รท y div p with x รท y ! p ... | q , r , p' = q -- return the remainder only _รท_mod_ : โ„• โ†’ (y : โ„•) โ†’ y =โ„• 0 โ‰ก ff โ†’ โ„• x รท y mod p with x รท y ! p ... | q , r , p' = r
{ "alphanum_fraction": 0.5448524985, "avg_line_length": 33.8979591837, "ext": "agda", "hexsha": "e118b1fe99add50335936bf66d854f7ffe9bd739", "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-division.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-division.agda", "max_line_length": 119, "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-division.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 716, "size": 1661 }
-- You can't use the same name more than once in the same scope. module ClashingDefinition where postulate X : Set X : Set Y = X
{ "alphanum_fraction": 0.6985294118, "avg_line_length": 13.6, "ext": "agda", "hexsha": "8f1d256e8e59eaef85a47b1ab5535369bfa3075e", "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/ClashingDefinition.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/ClashingDefinition.agda", "max_line_length": 64, "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/ClashingDefinition.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": 39, "size": 136 }
------------------------------------------------------------------------ -- An LTS from Sectionย 6.2.5 of "Enhancements of the bisimulation -- proof method" by Pous and Sangiorgi ------------------------------------------------------------------------ {-# OPTIONS --safe #-} open import Prelude module Labelled-transition-system.6-2-5 (Name : Type) where open import Labelled-transition-system infixr 12 _ยท_ infix 5 _[_] infix 4 _[_]โŸถ_ -- Processes. data Proc : Type where op : Proc โ†’ Proc _ยท_ : Name โ†’ Proc โ†’ Proc โˆ… : Proc -- Transitions. data _[_]โŸถ_ : Proc โ†’ Name โ†’ Proc โ†’ Type where action : โˆ€ {a P} โ†’ a ยท P [ a ]โŸถ P op : โˆ€ {a P Pโ€ฒ Pโ€ณ} โ†’ P [ a ]โŸถ Pโ€ฒ โ†’ Pโ€ฒ [ a ]โŸถ Pโ€ณ โ†’ op P [ a ]โŸถ Pโ€ณ -- The LTS. 6-2-5 : LTS lzero 6-2-5 = record { Proc = Proc ; Label = Name ; _[_]โŸถ_ = _[_]โŸถ_ ; is-silent = ฮป _ โ†’ false } open LTS 6-2-5 public hiding (Proc; _[_]โŸถ_) -- Polyadic contexts. data Context (n : โ„•) : Type where hole : (x : Fin n) โ†’ Context n op : Context n โ†’ Context n _ยท_ : (a : Name) โ†’ Context n โ†’ Context n โˆ… : Context n -- Hole filling. _[_] : โˆ€ {n} โ†’ Context n โ†’ (Fin n โ†’ Proc) โ†’ Proc hole x [ ps ] = ps x op C [ ps ] = op (C [ ps ]) a ยท C [ ps ] = a ยท (C [ ps ]) โˆ… [ ps ] = โˆ…
{ "alphanum_fraction": 0.4753184713, "avg_line_length": 21.6551724138, "ext": "agda", "hexsha": "3bc7178d6b667ea8f1fcbfab538a3e30f7e0a867", "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/Labelled-transition-system/6-2-5.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/Labelled-transition-system/6-2-5.agda", "max_line_length": 72, "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/Labelled-transition-system/6-2-5.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 437, "size": 1256 }
-- Tests unreachable clause detection module Unreachable where data C : Set where cโ‚ : C cโ‚‚ : C -> C data Bool : Set where t : Bool f : Bool maj : Bool -> Bool -> Bool -> Bool maj f f f = f maj t f x = x maj f x t = x maj x t f = x maj t t t = t unreachable : C -> C unreachable (cโ‚‚ x) = cโ‚ unreachable (cโ‚‚ (cโ‚‚ y)) = cโ‚‚ cโ‚ unreachable cโ‚ = cโ‚ unreachable _ = cโ‚
{ "alphanum_fraction": 0.5968992248, "avg_line_length": 16.8260869565, "ext": "agda", "hexsha": "6c0944e72fd15784df0389c5668d4057cfbae143", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/fail/Unreachable.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/fail/Unreachable.agda", "max_line_length": 37, "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/Unreachable.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": 142, "size": 387 }
{-# OPTIONS --guardedness #-} record _โ‰ˆ_ {A : Set} (xs : Stream A) (ys : Stream A) : Set where coinductive field hd-โ‰ˆ : hd xs โ‰ก hd ys tl-โ‰ˆ : tl xs โ‰ˆ tl ys even : โˆ€ {A} โ†’ Stream A โ†’ Stream A hd (even x) = hd x tl (even x) = even (tl (tl x)) odd : โˆ€ {A} โ†’ Stream A โ†’ Stream A odd x = even (tl x) split : โˆ€ {A} โ†’ Stream A โ†’ Stream A ร— Stream A split xs = even xs , odd xs merge : โˆ€ {A} โ†’ Stream A ร— Stream A โ†’ Stream A hd (merge (fst , snd)) = hd fst tl (merge (fst , snd)) = merge (snd , tl fst) merge-split-id : โˆ€ {A} (xs : Stream A) โ†’ merge (split xs) โ‰ˆ xs hd-โ‰ˆ (merge-split-id _) = refl tl-โ‰ˆ (merge-split-id xs) = merge-split-id (tl xs)
{ "alphanum_fraction": 0.5616438356, "avg_line_length": 25.2692307692, "ext": "agda", "hexsha": "cad1b63ab301b12085191353102b8441c1f1fa31", "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": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_forks_repo_licenses": [ "CC0-1.0" ], "max_forks_repo_name": "seanwestfall/agda_explorations", "max_forks_repo_path": "src/coinduction.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "CC0-1.0" ], "max_issues_repo_name": "seanwestfall/agda_explorations", "max_issues_repo_path": "src/coinduction.agda", "max_line_length": 64, "max_stars_count": null, "max_stars_repo_head_hexsha": "9fd9fbf9f265bf526a2ec83e9442dedc7106b80c", "max_stars_repo_licenses": [ "CC0-1.0" ], "max_stars_repo_name": "seanwestfall/agda_explorations", "max_stars_repo_path": "src/coinduction.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 246, "size": 657 }
module exampleTypeAbbreviations where postulate A : Set A2 : Set A2 = A -> A A3 : Set A3 = A2 -> A2 a2 : A2 a2 = \x -> x a3 : A3 a3 = \x -> x
{ "alphanum_fraction": 0.5793103448, "avg_line_length": 10.3571428571, "ext": "agda", "hexsha": "f6ff17d7f867f76c9e8218ccfce55d79c36219dc", "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": "dc333ed142584cf52cc885644eed34b356967d8b", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejtokarcik/agda-semantics", "max_forks_repo_path": "tests/covered/exampleTypeAbbreviations.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "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": "andrejtokarcik/agda-semantics", "max_issues_repo_path": "tests/covered/exampleTypeAbbreviations.agda", "max_line_length": 37, "max_stars_count": 3, "max_stars_repo_head_hexsha": "dc333ed142584cf52cc885644eed34b356967d8b", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "andrejtokarcik/agda-semantics", "max_stars_repo_path": "tests/covered/exampleTypeAbbreviations.agda", "max_stars_repo_stars_event_max_datetime": "2018-12-06T17:24:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-08-10T15:33:56.000Z", "num_tokens": 67, "size": 145 }
------------------------------------------------------------------------ -- Theorems relating the coinductive definition of the delay -- monad to the alternative one and to another type ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --sized-types #-} open import Prelude hiding (โ†‘) module Delay-monad.Alternative.Equivalence {a} {A : Type a} where open import Equality.Propositional.Cubical open import Logical-equivalence using (_โ‡”_) open import Prelude.Size open import Bijection equality-with-J using (_โ†”_) open import Equality.Decision-procedures equality-with-J open import Function-universe equality-with-J hiding (_โˆ˜_) open import H-level equality-with-J open import Surjection equality-with-J using (_โ† _) open import Delay-monad as D hiding (Delay) open import Delay-monad.Alternative open import Delay-monad.Alternative.Properties open import Delay-monad.Bisimilarity as Bisimilarity using ([_]_โˆผ_; now; later; force) private variable i : Size -- Building blocks used in the theorems below. module Delayโ‡”Delay where -- The function toโ‚ is basically ฯ€ from Section 7.1 of -- "Quotienting the Delay Monad by Weak Bisimilarity" by Chapman, -- Uustalu and Veltri, but the function projโ‚ย โˆ˜ย from is different -- from their function ฮต, which is defined so that (with the -- terminology used here) ฮตย (nowย x)ย (sucย n)ย =ย nothing. toโ‚ : (โ„• โ†’ Maybe A) โ†’ D.Delay A i toโ‚ f = toโ€ฒ (f 0) module To where toโ€ฒ : Maybe A โ†’ D.Delay A i toโ€ฒ (just x) = now x toโ€ฒ nothing = later ฮป { .force โ†’ toโ‚ (f โˆ˜ suc) } to : Delay A โ†’ D.Delay A i to = toโ‚ โˆ˜ projโ‚ from : D.Delay A โˆž โ†’ Delay A from = ฮป x โ†’ fromโ‚ x , fromโ‚‚ x where fromโ‚ : D.Delay A โˆž โ†’ โ„• โ†’ Maybe A fromโ‚ (now x) _ = just x fromโ‚ (later x) zero = nothing fromโ‚ (later x) (suc n) = fromโ‚ (force x) n fromโ‚‚ : โˆ€ x โ†’ Increasing (fromโ‚ x) fromโ‚‚ (now x) _ = injโ‚ refl fromโ‚‚ (later x) zero = projโ‚ LE-nothing-contractible fromโ‚‚ (later x) (suc n) = fromโ‚‚ (force x) n -- The two definitions of the delay monad are logically equivalent. Delayโ‡”Delay : Delay A โ‡” D.Delay A โˆž Delayโ‡”Delay = record { to = Delayโ‡”Delay.to; from = Delayโ‡”Delay.from } -- There is a split surjection from D.Delayย Aย โˆž to Delayย A. Delayโ† Delay : D.Delay A โˆž โ†  Delay A Delayโ† Delay = record { logical-equivalence = inverse Delayโ‡”Delay ; right-inverse-of = fromโˆ˜to } where open Delayโ‡”Delay fromโˆ˜to : โˆ€ x โ†’ from (to x) โ‰ก x fromโˆ˜to x = ฮฃ-โ‰ก,โ‰กโ†’โ‰ก (โŸจextโŸฉ (projโ‚โˆ˜fromโˆ˜to x)) (โŸจextโŸฉ ฮป n โ†’ subst Increasing (โŸจextโŸฉ (projโ‚โˆ˜fromโˆ˜to x)) (projโ‚‚ (from (to x))) n โ‰กโŸจ sym $ push-subst-application (โŸจextโŸฉ (projโ‚โˆ˜fromโˆ˜to x)) (flip Increasing-at) โŸฉ subst (Increasing-at n) (โŸจextโŸฉ (projโ‚โˆ˜fromโˆ˜to x)) (projโ‚‚ (from (to x)) n) โ‰กโŸจ uncurry projโ‚‚โˆ˜fromโˆ˜to x n _ refl โŸฉโˆŽ projโ‚‚ x n โˆŽ) where projโ‚โˆ˜fromโˆ˜toโ€ฒ : (g : โ„• โ†’ Maybe A) โ†’ Increasing g โ†’ โˆ€ x โ†’ g 0 โ‰ก x โ†’ โˆ€ n โ†’ projโ‚ (from (To.toโ€ฒ g x)) n โ‰ก g n projโ‚โˆ˜fromโˆ˜toโ€ฒ g g-inc (just x) g0โ†“x n = sym $ โ†“-upwards-closedโ‚€ g-inc g0โ†“x n projโ‚โˆ˜fromโˆ˜toโ€ฒ g g-inc nothing g0โ†‘ zero = sym g0โ†‘ projโ‚โˆ˜fromโˆ˜toโ€ฒ g g-inc nothing g0โ†‘ (suc n) = projโ‚โˆ˜fromโˆ˜toโ€ฒ (g โˆ˜ suc) (g-inc โˆ˜ suc) _ refl n projโ‚โˆ˜fromโˆ˜to : (x : Delay A) โ†’ โˆ€ n โ†’ projโ‚ (from (to x)) n โ‰ก projโ‚ x n projโ‚โˆ˜fromโˆ˜to (g , g-inc) = projโ‚โˆ˜fromโˆ˜toโ€ฒ g g-inc (g 0) refl โ†“-lemma : (g : โ„• โ†’ Maybe A) โ†’ (g-increasing : Increasing g) โ†’ โˆ€ n x (g0โ†“x : g 0 โ†“ x) p โ†’ p โ‰ก g-increasing 0 โ†’ subst (Increasing-at n) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ g-increasing g0โ†“x)) (injโ‚ refl) โ‰ก g-increasing n โ†“-lemma g _ _ x g0โ†“x (injโ‚‚ (g0โ†‘ , _)) _ = โŠฅ-elim $ โŠŽ.injโ‚โ‰ขinjโ‚‚ ( nothing โ‰กโŸจ sym g0โ†‘ โŸฉ g 0 โ‰กโŸจ g0โ†“x โŸฉโˆŽ just x โˆŽ) โ†“-lemma g g-inc zero x g0โ†“x (injโ‚ g0โ‰กg1) โ‰กg-inc0 = subst (Increasing-at zero) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ g-inc g0โ†“x)) (injโ‚ refl) โ‰กโŸจ push-subst-injโ‚ {yโ‰กz = โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ g-inc g0โ†“x)} (ฮป f โ†’ f 0 โ‰ก f 1) (ฮป f โ†’ f 0 โ†‘ ร— ยฌ f 1 โ†‘) โŸฉ injโ‚ (subst (ฮป f โ†’ f 0 โ‰ก f 1) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ g-inc g0โ†“x)) refl) โ‰กโŸจ cong injโ‚ lemma โŸฉ injโ‚ g0โ‰กg1 โ‰กโŸจ โ‰กg-inc0 โŸฉโˆŽ g-inc zero โˆŽ where eq = โ†“-upwards-closedโ‚€ g-inc g0โ†“x lemma = subst (ฮป f โ†’ f 0 โ‰ก f 1) (โŸจextโŸฉ (sym โˆ˜ eq)) refl โ‰กโŸจ subst-in-terms-of-trans-and-cong {xโ‰กy = โŸจextโŸฉ (sym โˆ˜ eq)} โŸฉ trans (sym (cong (_$ 0) (โŸจextโŸฉ (sym โˆ˜ eq)))) (trans refl (cong (_$ 1) (โŸจextโŸฉ (sym โˆ˜ eq)))) โ‰กโŸจ cong (trans (sym (cong (_$ 0) (โŸจextโŸฉ (sym โˆ˜ eq))))) $ trans-reflหก (cong (_$ 1) (โŸจextโŸฉ (sym โˆ˜ eq))) โŸฉ trans (sym (cong (_$ 0) (โŸจextโŸฉ (sym โˆ˜ eq)))) (cong (_$ 1) (โŸจextโŸฉ (sym โˆ˜ eq))) โ‰กโŸจ congโ‚‚ (ฮป p q โ†’ trans (sym p) q) (cong-ext (sym โˆ˜ eq)) (cong-ext (sym โˆ˜ eq)) โŸฉ trans (sym $ sym $ eq 0) (sym $ eq 1) โ‰กโŸจ cong (ฮป eqโ€ฒ โ†’ trans eqโ€ฒ (sym $ eq 1)) $ sym-sym _ โŸฉ trans (eq 0) (sym $ eq 1) โ‰กโŸจโŸฉ trans g0โ†“x (sym $ โ†“.step g-inc g0โ†“x (g-inc 0)) โ‰กโŸจ cong (ฮป eqโ€ฒ โ†’ trans g0โ†“x (sym $ โ†“.step g-inc g0โ†“x eqโ€ฒ)) $ sym $ โ‰กg-inc0 โŸฉ trans g0โ†“x (sym $ โ†“.step g-inc g0โ†“x (injโ‚ g0โ‰กg1)) โ‰กโŸจโŸฉ trans g0โ†“x (sym $ trans (sym g0โ‰กg1) g0โ†“x) โ‰กโŸจ cong (trans g0โ†“x) $ sym-trans (sym g0โ‰กg1) g0โ†“x โŸฉ trans g0โ†“x (trans (sym g0โ†“x) (sym (sym g0โ‰กg1))) โ‰กโŸจ trans--[trans-sym] _ _ โŸฉ sym (sym g0โ‰กg1) โ‰กโŸจ sym-sym _ โŸฉโˆŽ g0โ‰กg1 โˆŽ โ†“-lemma g g-inc (suc n) x g0โ†“x (injโ‚ g0โ‰กg1) โ‰กg-inc0 = subst (Increasing-at (suc n)) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ g-inc g0โ†“x)) (injโ‚ refl) โ‰กโŸจโŸฉ subst (Increasing-at n โˆ˜ (_โˆ˜ suc)) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ g-inc g0โ†“x)) (injโ‚ refl) โ‰กโŸจ subst-โˆ˜ (Increasing-at n) (_โˆ˜ suc) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ g-inc g0โ†“x)) โŸฉ subst (Increasing-at n) (cong (_โˆ˜ suc) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ g-inc g0โ†“x))) (injโ‚ refl) โ‰กโŸจ cong (ฮป eq โ†’ subst (Increasing-at n) eq _) $ cong-pre-โˆ˜-ext (sym โˆ˜ โ†“-upwards-closedโ‚€ g-inc g0โ†“x) โŸฉ subst (Increasing-at n) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ g-inc g0โ†“x โˆ˜ suc)) (injโ‚ refl) โ‰กโŸจโŸฉ subst (Increasing-at n) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ (g-inc โˆ˜ suc) (โ†“.step g-inc g0โ†“x (g-inc 0)))) (injโ‚ refl) โ‰กโŸจ cong (ฮป p โ†’ subst (Increasing-at n) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ (g-inc โˆ˜ suc) (โ†“.step g-inc g0โ†“x p))) (injโ‚ refl)) (sym โ‰กg-inc0) โŸฉ subst (Increasing-at n) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ (g-inc โˆ˜ suc) (โ†“.step g-inc g0โ†“x (injโ‚ g0โ‰กg1)))) (injโ‚ refl) โ‰กโŸจโŸฉ subst (Increasing-at n) (โŸจextโŸฉ (sym โˆ˜ โ†“-upwards-closedโ‚€ (g-inc โˆ˜ suc) (trans (sym g0โ‰กg1) g0โ†“x))) (injโ‚ refl) โ‰กโŸจ โ†“-lemma (g โˆ˜ suc) (g-inc โˆ˜ suc) n _ _ _ refl โŸฉโˆŽ g-inc (suc n) โˆŽ projโ‚‚โˆ˜fromโˆ˜to : (g : โ„• โ†’ Maybe A) โ†’ (g-increasing : Increasing g) โ†’ โˆ€ n y (g0โ‰กy : g 0 โ‰ก y) โ†’ subst (Increasing-at n) (โŸจextโŸฉ (projโ‚โˆ˜fromโˆ˜toโ€ฒ g g-increasing y g0โ‰กy)) (projโ‚‚ (from (To.toโ€ฒ g y)) n) โ‰ก g-increasing n projโ‚‚โˆ˜fromโˆ˜to g g-inc n (just y) g0โ†“y = โ†“-lemma g g-inc n y g0โ†“y _ refl projโ‚‚โˆ˜fromโˆ˜to g g-inc zero nothing g0โ†‘ = ( $โŸจ monoโ‚ 0 LE-nothing-contractible โŸฉ Is-proposition (LE nothing (g 1)) โ†โŸจ subst (ฮป x โ†’ Is-proposition (LE x (g 1))) (sym g0โ†‘) โŸฉโ–ก Is-proposition (LE (g 0) (g 1)) โ–ก) _ _ projโ‚‚โˆ˜fromโˆ˜to g g-inc (suc n) nothing g0โ†‘ = subst (Increasing-at (suc n)) (โŸจextโŸฉ (projโ‚โˆ˜fromโˆ˜toโ€ฒ g g-inc nothing g0โ†‘)) (projโ‚‚ (from (to (g โˆ˜ suc , g-inc โˆ˜ suc))) n) โ‰กโŸจโŸฉ subst (Increasing-at n โˆ˜ (_โˆ˜ suc)) (โŸจextโŸฉ (projโ‚โˆ˜fromโˆ˜toโ€ฒ g g-inc nothing g0โ†‘)) (projโ‚‚ (from (to (g โˆ˜ suc , g-inc โˆ˜ suc))) n) โ‰กโŸจ subst-โˆ˜ (Increasing-at n) (_โˆ˜ suc) (โŸจextโŸฉ (projโ‚โˆ˜fromโˆ˜toโ€ฒ g g-inc nothing g0โ†‘)) โŸฉ subst (Increasing-at n) (cong (_โˆ˜ suc) (โŸจextโŸฉ (projโ‚โˆ˜fromโˆ˜toโ€ฒ g g-inc nothing g0โ†‘))) (projโ‚‚ (from (to (g โˆ˜ suc , g-inc โˆ˜ suc))) n) โ‰กโŸจ cong (ฮป eq โ†’ subst (Increasing-at n) eq (projโ‚‚ (from (to (g โˆ˜ suc , g-inc โˆ˜ suc))) n)) $ cong-pre-โˆ˜-ext (projโ‚โˆ˜fromโˆ˜toโ€ฒ g g-inc nothing g0โ†‘) โŸฉ subst (Increasing-at n) (โŸจextโŸฉ (projโ‚โˆ˜fromโˆ˜toโ€ฒ g g-inc nothing g0โ†‘ โˆ˜ suc)) (projโ‚‚ (from (to (g โˆ˜ suc , g-inc โˆ˜ suc))) n) โ‰กโŸจโŸฉ subst (Increasing-at n) (โŸจextโŸฉ (projโ‚โˆ˜fromโˆ˜toโ€ฒ (g โˆ˜ suc) (g-inc โˆ˜ suc) _ refl)) (projโ‚‚ (from (to (g โˆ˜ suc , g-inc โˆ˜ suc))) n) โ‰กโŸจ projโ‚‚โˆ˜fromโˆ˜to (g โˆ˜ suc) (g-inc โˆ˜ suc) n _ refl โŸฉโˆŽ g-inc (suc n) โˆŽ -- The two definitions of the delay monad are isomorphic (assuming -- extensionality). Delayโ†”Delay : Bisimilarity.Extensionality a โ†’ Delay A โ†” D.Delay A โˆž Delayโ†”Delay delay-ext = record { surjection = record { logical-equivalence = Delayโ‡”Delay ; right-inverse-of = delay-ext โˆ˜ toโˆ˜from } ; left-inverse-of = _โ† _.right-inverse-of Delayโ† Delay } where open Delayโ‡”Delay toโˆ˜from : โˆ€ x โ†’ [ i ] to (from x) โˆผ x toโˆ˜from (now x) = now toโˆ˜from (later x) = later ฮป { .force โ†’ toโˆ˜from (force x) } -- There is a split surjection from โ„•ย โ†’ย Maybeย A (without any -- requirement that the sequences are increasing) to D.Delayย Aย โˆž -- (assuming extensionality). -- -- Chapman, Uustalu and Veltri prove this result in "Quotienting the -- Delay Monad by Weak Bisimilarity". โ†’โ† Delay-coinductive : Bisimilarity.Extensionality a โ†’ (โ„• โ†’ Maybe A) โ†  D.Delay A โˆž โ†’โ† Delay-coinductive delay-ext = record { logical-equivalence = record { to = Delayโ‡”Delay.toโ‚ ; from = projโ‚ โˆ˜ Delayโ‡”Delay.from } ; right-inverse-of = _โ†”_.right-inverse-of (Delayโ†”Delay delay-ext) } -- There is also a split surjection from โ„•ย โ†’ย Maybeย A to Delayย A. โ†’โ† Delay-function : (โ„• โ†’ Maybe A) โ†  Delay A โ†’โ† Delay-function = record { logical-equivalence = record { to = Delayโ‡”Delay.from โˆ˜ Delayโ‡”Delay.toโ‚ ; from = projโ‚ } ; right-inverse-of = _โ† _.right-inverse-of Delayโ† Delay }
{ "alphanum_fraction": 0.4513382991, "avg_line_length": 40.4536423841, "ext": "agda", "hexsha": "279fd5a58fe6f93a95aa48e5f2ed8c61523a2df6", "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": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/partiality-monad", "max_forks_repo_path": "src/Delay-monad/Alternative/Equivalence.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "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/partiality-monad", "max_issues_repo_path": "src/Delay-monad/Alternative/Equivalence.agda", "max_line_length": 144, "max_stars_count": 2, "max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/partiality-monad", "max_stars_repo_path": "src/Delay-monad/Alternative/Equivalence.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z", "num_tokens": 3994, "size": 12217 }
{-# OPTIONS --without-K --safe #-} module Categories.Object.NaturalNumber.Properties.F-Algebras where open import Level open import Function using (_$_) open import Categories.Category open import Categories.Category.Construction.F-Algebras open import Categories.Category.Cocartesian open import Categories.Functor open import Categories.Functor.Algebra open import Categories.Object.Terminal renaming (up-to-iso to โŠค-up-to-iso) open import Categories.Object.Initial import Categories.Morphism.Reasoning as MR import Categories.Object.NaturalNumber as NNO -- A NNO is an inital algebra for the 'X โ†ฆ โŠค + X' endofunctor. module _ {o โ„“ e} (๐’ž : Category o โ„“ e) (๐’ž-Terminal : Terminal ๐’ž) (๐’ž-Coproducts : BinaryCoproducts ๐’ž) where open Terminal ๐’ž-Terminal open BinaryCoproducts ๐’ž-Coproducts open Category ๐’ž open HomReasoning open Equiv open MR ๐’ž open NNO ๐’ž ๐’ž-Terminal Maybe : Functor ๐’ž ๐’ž Maybe = record { Fโ‚€ = ฮป X โ†’ โŠค + X ; Fโ‚ = ฮป f โ†’ [ iโ‚ , iโ‚‚ โˆ˜ f ] ; identity = []-congโ‚‚ refl identityสณ โ—‹ +-ฮท ; homomorphism = +-unique (pullสณ injectโ‚ โ—‹ injectโ‚) (pullสณ injectโ‚‚ โ—‹ pullหก injectโ‚‚ โ—‹ assoc) ; F-resp-โ‰ˆ = ฮป eq โ†’ []-congโ‚‚ refl (โˆ˜-resp-โ‰ˆสณ eq) } private module Maybe = Functor Maybe Initialโ‡’NNO : Initial (F-Algebras Maybe) โ†’ NaturalNumber Initialโ‡’NNO initial = record { N = โŠฅ.A ; isNaturalNumber = record { z = โŠฅ.ฮฑ โˆ˜ iโ‚ ; s = โŠฅ.ฮฑ โˆ˜ iโ‚‚ ; universal = ฮป {A} q f โ†’ F-Algebra-Morphism.f (initial.! {A = alg q f}) ; z-commute = ฮป {A} {q} {f} โ†’ begin q โ‰ˆโŸจ โŸบ injectโ‚ โŸฉ [ q , f ] โˆ˜ iโ‚ โ‰ˆโŸจ pushสณ (โŸบ injectโ‚) โŸฉ (([ q , f ] โˆ˜ [ iโ‚ , iโ‚‚ โˆ˜ F-Algebra-Morphism.f initial.! ]) โˆ˜ iโ‚) โ‰ˆโŸจ pushหก (โŸบ (F-Algebra-Morphism.commutes (initial.! {A = alg q f}))) โŸฉ F-Algebra-Morphism.f initial.! โˆ˜ โŠฅ.ฮฑ โˆ˜ iโ‚ โˆŽ ; s-commute = ฮป {A} {q} {f} โ†’ begin (f โˆ˜ F-Algebra-Morphism.f initial.!) โ‰ˆโŸจ pushหก (โŸบ injectโ‚‚) โŸฉ [ q , f ] โˆ˜ iโ‚‚ โˆ˜ F-Algebra-Morphism.f initial.! โ‰ˆโŸจ pushสณ (โŸบ injectโ‚‚) โŸฉ ([ q , f ] โˆ˜ [ iโ‚ , iโ‚‚ โˆ˜ F-Algebra-Morphism.f initial.! ]) โˆ˜ iโ‚‚ โ‰ˆโŸจ pushหก (โŸบ (F-Algebra-Morphism.commutes (initial.! {A = alg q f}))) โŸฉ F-Algebra-Morphism.f initial.! โˆ˜ โŠฅ.ฮฑ โˆ˜ iโ‚‚ โˆŽ ; unique = ฮป {A} {f} {q} {u} eqแถป eqหข โ†’ โŸบ $ initial.!-unique record { f = u ; commutes = begin u โˆ˜ โŠฅ.ฮฑ โ‰ˆโŸจ โŸบ +-g-ฮท โŸฉ [ (u โˆ˜ โŠฅ.ฮฑ) โˆ˜ iโ‚ , (u โˆ˜ โŠฅ.ฮฑ) โˆ˜ iโ‚‚ ] โ‰ˆโŸจ []-congโ‚‚ (assoc โ—‹ โŸบ eqแถป) (assoc โ—‹ โŸบ eqหข) โŸฉ [ f , q โˆ˜ u ] โ‰ˆโŸจ +-unique (pullสณ injectโ‚ โ—‹ injectโ‚) (pullสณ injectโ‚‚ โ—‹ pullหก injectโ‚‚) โŸฉ [ f , q ] โˆ˜ [ iโ‚ , iโ‚‚ โˆ˜ u ] โˆŽ } } } where module initial = Initial initial module โŠฅ = F-Algebra initial.โŠฅ alg : โˆ€ {A} โ†’ (q : โŠค โ‡’ A) โ†’ (f : A โ‡’ A) โ†’ F-Algebra Maybe alg {A} q f = record { A = A ; ฮฑ = [ q , f ] } NNOโ‡’Initial : NaturalNumber โ†’ Initial (F-Algebras Maybe) NNOโ‡’Initial NNO = record { โŠฅ = record { A = N ; ฮฑ = [ z , s ] } ; โŠฅ-is-initial = record { ! = ฮป {alg} โ†’ record { f = universal (F-Algebra.ฮฑ alg โˆ˜ iโ‚) (F-Algebra.ฮฑ alg โˆ˜ iโ‚‚) ; commutes = begin universal _ _ โˆ˜ [ z , s ] โ‰ˆโŸจ โˆ˜-distribหก-[] โŸฉ [ universal _ _ โˆ˜ z , universal _ _ โˆ˜ s ] โ‰ˆโŸจ []-congโ‚‚ (โŸบ z-commute) (โŸบ s-commute โ—‹ assoc) โŸฉ [ F-Algebra.ฮฑ alg โˆ˜ iโ‚ , F-Algebra.ฮฑ alg โˆ˜ (iโ‚‚ โˆ˜ universal _ _) ] โ‰ˆห˜โŸจ โˆ˜-distribหก-[] โŸฉ F-Algebra.ฮฑ alg โˆ˜ [ iโ‚ , iโ‚‚ โˆ˜ universal _ _ ] โˆŽ } ; !-unique = ฮป {A} f โ†’ let z-commutes = begin F-Algebra.ฮฑ A โˆ˜ iโ‚ โ‰ˆโŸจ pushสณ (โŸบ injectโ‚) โŸฉ (F-Algebra.ฮฑ A โˆ˜ [ iโ‚ , iโ‚‚ โˆ˜ F-Algebra-Morphism.f f ]) โˆ˜ iโ‚ โ‰ˆห˜โŸจ F-Algebra-Morphism.commutes f โŸฉโˆ˜โŸจrefl โŸฉ (F-Algebra-Morphism.f f โˆ˜ [ z , s ]) โˆ˜ iโ‚ โ‰ˆโŸจ pullสณ injectโ‚ โŸฉ F-Algebra-Morphism.f f โˆ˜ z โˆŽ s-commutes = begin (F-Algebra.ฮฑ A โˆ˜ iโ‚‚) โˆ˜ F-Algebra-Morphism.f f โ‰ˆโŸจ pullสณ (โŸบ injectโ‚‚) โ—‹ โŸบ assoc โŸฉ (F-Algebra.ฮฑ A โˆ˜ [ iโ‚ , iโ‚‚ โˆ˜ F-Algebra-Morphism.f f ]) โˆ˜ iโ‚‚ โ‰ˆห˜โŸจ F-Algebra-Morphism.commutes f โŸฉโˆ˜โŸจrefl โŸฉ (F-Algebra-Morphism.f f โˆ˜ [ z , s ]) โˆ˜ iโ‚‚ โ‰ˆโŸจ pullสณ injectโ‚‚ โŸฉ F-Algebra-Morphism.f f โˆ˜ s โˆŽ in โŸบ $ unique z-commutes s-commutes } } where open NaturalNumber NNO
{ "alphanum_fraction": 0.4836518047, "avg_line_length": 42.8181818182, "ext": "agda", "hexsha": "bffc3b9d67ce127b23a748ebba9ceb9e3310e49a", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Object/NaturalNumber/Properties/F-Algebras.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Object/NaturalNumber/Properties/F-Algebras.agda", "max_line_length": 144, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Object/NaturalNumber/Properties/F-Algebras.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 1702, "size": 4710 }
{- This file contains: - Properties of set truncations -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.SetTruncation.Properties where open import Cubical.HITs.SetTruncation.Base open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Univalence open import Cubical.Data.Sigma private variable โ„“ : Level A : Type โ„“ rec : {B : Type โ„“} โ†’ isSet B โ†’ (A โ†’ B) โ†’ โˆฅ A โˆฅโ‚‚ โ†’ B rec Bset f โˆฃ x โˆฃโ‚‚ = f x rec Bset f (squashโ‚‚ x y p q i j) = Bset _ _ (cong (rec Bset f) p) (cong (rec Bset f) q) i j -- lemma 6.9.1 in HoTT book elim : {B : โˆฅ A โˆฅโ‚‚ โ†’ Type โ„“} (Bset : (x : โˆฅ A โˆฅโ‚‚) โ†’ isSet (B x)) (g : (a : A) โ†’ B (โˆฃ a โˆฃโ‚‚)) (x : โˆฅ A โˆฅโ‚‚) โ†’ B x elim Bset g โˆฃ a โˆฃโ‚‚ = g a elim Bset g (squashโ‚‚ x y p q i j) = isOfHLevelโ†’isOfHLevelDep 2 Bset _ _ (cong (elim Bset g) p) (cong (elim Bset g) q) (squashโ‚‚ x y p q) i j setTruncUniversal : {B : Type โ„“} โ†’ isSet B โ†’ (โˆฅ A โˆฅโ‚‚ โ†’ B) โ‰ƒ (A โ†’ B) setTruncUniversal {B = B} Bset = isoToEquiv (iso (ฮป h x โ†’ h โˆฃ x โˆฃโ‚‚) (rec Bset) (ฮป _ โ†’ refl) rinv) where rinv : (f : โˆฅ A โˆฅโ‚‚ โ†’ B) โ†’ rec Bset (ฮป x โ†’ f โˆฃ x โˆฃโ‚‚) โ‰ก f rinv f i x = elim (ฮป x โ†’ isPropโ†’isSet (Bset (rec Bset (ฮป x โ†’ f โˆฃ x โˆฃโ‚‚) x) (f x))) (ฮป _ โ†’ refl) x i elim2 : {B : โˆฅ A โˆฅโ‚‚ โ†’ โˆฅ A โˆฅโ‚‚ โ†’ Type โ„“} (Bset : ((x y : โˆฅ A โˆฅโ‚‚) โ†’ isSet (B x y))) (g : (a b : A) โ†’ B โˆฃ a โˆฃโ‚‚ โˆฃ b โˆฃโ‚‚) (x y : โˆฅ A โˆฅโ‚‚) โ†’ B x y elim2 Bset g = elim (ฮป _ โ†’ isSetฮ  (ฮป _ โ†’ Bset _ _)) (ฮป a โ†’ elim (ฮป _ โ†’ Bset _ _) (g a)) elim3 : {B : (x y z : โˆฅ A โˆฅโ‚‚) โ†’ Type โ„“} (Bset : ((x y z : โˆฅ A โˆฅโ‚‚) โ†’ isSet (B x y z))) (g : (a b c : A) โ†’ B โˆฃ a โˆฃโ‚‚ โˆฃ b โˆฃโ‚‚ โˆฃ c โˆฃโ‚‚) (x y z : โˆฅ A โˆฅโ‚‚) โ†’ B x y z elim3 Bset g = elim2 (ฮป _ _ โ†’ isSetฮ  (ฮป _ โ†’ Bset _ _ _)) (ฮป a b โ†’ elim (ฮป _ โ†’ Bset _ _ _) (g a b)) setTruncIsSet : isSet โˆฅ A โˆฅโ‚‚ setTruncIsSet a b p q = squashโ‚‚ a b p q setTruncIdempotentโ‰ƒ : isSet A โ†’ โˆฅ A โˆฅโ‚‚ โ‰ƒ A setTruncIdempotentโ‰ƒ {A = A} hA = isoToEquiv f where f : Iso โˆฅ A โˆฅโ‚‚ A Iso.fun f = rec hA (idfun A) Iso.inv f x = โˆฃ x โˆฃโ‚‚ Iso.rightInv f _ = refl Iso.leftInv f = elim (ฮป _ โ†’ isSetโ†’isGroupoid setTruncIsSet _ _) (ฮป _ โ†’ refl) setTruncIdempotent : isSet A โ†’ โˆฅ A โˆฅโ‚‚ โ‰ก A setTruncIdempotent hA = ua (setTruncIdempotentโ‰ƒ hA) setSigmaIso : โˆ€ {โ„“} {B : A โ†’ Type โ„“} โ†’ Iso โˆฅ ฮฃ A B โˆฅโ‚‚ โˆฅ ฮฃ A (ฮป x โ†’ โˆฅ B x โˆฅโ‚‚) โˆฅโ‚‚ setSigmaIso {A = A} {B = B} = iso fun funinv sect retr where {- writing it out explicitly to avoid yellow highlighting -} fun : โˆฅ ฮฃ A B โˆฅโ‚‚ โ†’ โˆฅ ฮฃ A (ฮป x โ†’ โˆฅ B x โˆฅโ‚‚) โˆฅโ‚‚ fun = rec setTruncIsSet ฮป {(a , p) โ†’ โˆฃ a , โˆฃ p โˆฃโ‚‚ โˆฃโ‚‚} funinv : โˆฅ ฮฃ A (ฮป x โ†’ โˆฅ B x โˆฅโ‚‚) โˆฅโ‚‚ โ†’ โˆฅ ฮฃ A B โˆฅโ‚‚ funinv = rec setTruncIsSet (ฮป {(a , p) โ†’ rec setTruncIsSet (ฮป p โ†’ โˆฃ a , p โˆฃโ‚‚) p}) sect : section fun funinv sect = elim (ฮป _ โ†’ isOfHLevelPath 2 setTruncIsSet _ _) ฮป { (a , p) โ†’ elim {B = ฮป p โ†’ fun (funinv โˆฃ a , p โˆฃโ‚‚) โ‰ก โˆฃ a , p โˆฃโ‚‚} (ฮป p โ†’ isOfHLevelPath 2 setTruncIsSet _ _) (ฮป _ โ†’ refl) p } retr : retract fun funinv retr = elim (ฮป _ โ†’ isOfHLevelPath 2 setTruncIsSet _ _) ฮป { _ โ†’ refl }
{ "alphanum_fraction": 0.5459375, "avg_line_length": 33.6842105263, "ext": "agda", "hexsha": "e27d8e73c15d181faa1ab8d03cbba5cbfa94a39e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/HITs/SetTruncation/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/HITs/SetTruncation/Properties.agda", "max_line_length": 83, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/HITs/SetTruncation/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1407, "size": 3200 }