├── .github └── workflows │ └── main.yml ├── .gitignore ├── CODE-OF-CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── STATEMENT-OF-INCLUSION.md ├── admin-utilities ├── GenerateMakefile.hs ├── dependency_graph.dot ├── generate-makefile.sh ├── illiterate ├── illiterator.hs └── updatehtml ├── approximatefinddef ├── count-agda-files-and-lines ├── findexactdef ├── imports.sh ├── indexupdatecount ├── latex ├── CSB │ ├── PublicationAgreement.pdf │ ├── csb.bib │ └── csb.tex ├── EffectfulForcing │ ├── dialogue.lagda │ ├── dialogue.pdf │ ├── dialogue.tex │ ├── do │ ├── entcs.cls │ ├── entcsmacro.sty │ ├── prentcsmacro.sty │ └── readme ├── UnivalenceFromScratch │ ├── UnivalenceFromScratch.bib │ └── UnivalenceFromScratch.tex ├── compact-ordinals-abstract │ ├── compact-ordinals-Types-2019-abstract.pdf │ ├── compact-ordinals-Types-2019-abstract.tex │ └── easychair.cls └── injectives │ ├── revised-accepted │ ├── injective-types.tex │ └── references.bib │ ├── revised │ ├── injective-types.tex │ └── references.bib │ └── submitted │ ├── injective-types.tex │ └── references.bib ├── source ├── AllModulesIndex.lagda ├── Apartness │ ├── Definition.lagda │ ├── Morphisms.lagda │ ├── Negation.lagda │ ├── Properties.lagda │ ├── TightReflection.lagda │ └── index.lagda ├── BinarySystems │ ├── CubicalBinarySystem.lagda │ ├── InitialBinarySystem.lagda │ ├── InitialBinarySystem2.lagda │ └── index.lagda ├── CantorSchroederBernstein │ ├── CSB-TheoryLabLunch.lagda │ ├── CSB.lagda │ └── index.lagda ├── Cardinals │ ├── Preorder.lagda │ ├── Successor.lagda │ ├── Type.lagda │ └── index.lagda ├── Categories │ ├── Adjunction.lagda │ ├── Category.lagda │ ├── Functor.lagda │ ├── NaturalTransformation.lagda │ └── index.lagda ├── Circle │ ├── Construction.lagda │ ├── Induction.lagda │ ├── Integers-Properties.lagda │ ├── Integers-SymmetricInduction.lagda │ ├── Integers.lagda │ └── index.lagda ├── CoNaturals │ ├── Arithmetic.lagda │ ├── BothTypes.lagda │ ├── Equivalence.lagda │ ├── Exercise.lagda │ ├── GenericConvergentSequence.lagda │ ├── GenericConvergentSequence2.lagda │ ├── Sharp.lagda │ ├── Type.lagda │ ├── Type2.lagda │ ├── Type2Properties.lagda │ ├── UniversalProperty.lagda │ └── index.lagda ├── ContinuityAxiom │ ├── ExitingTruncations.lagda │ ├── False.lagda │ ├── FalseWithoutIdentityTypes.lagda │ ├── Preliminaries.lagda │ ├── UniformContinuity.lagda │ └── index.lagda ├── Coslice │ ├── Hom.lagda │ ├── Type.lagda │ └── index.lagda ├── CrossedModules │ ├── CrossedModules.lagda │ └── index.lagda ├── DedekindReals │ ├── Addition.lagda │ ├── Extension.lagda │ ├── Functions.lagda │ ├── Multiplication.lagda │ ├── Order.lagda │ ├── Properties.lagda │ ├── Type.lagda │ └── index.lagda ├── DiscreteGraphicMonoids │ ├── AffineMonad.lagda │ ├── Free.lagda │ ├── LWRDGM.lagda │ ├── ListsWithoutRepetitions.lagda │ ├── ListsWithoutRepetitionsMore.lagda │ ├── Monad.lagda │ ├── Type.lagda │ └── index.lagda ├── DomainTheory │ ├── BasesAndContinuity │ │ ├── Bases.lagda │ │ ├── CompactBasis.lagda │ │ ├── Continuity.lagda │ │ ├── ContinuityDiscussion.lagda │ │ ├── ContinuityImpredicative.lagda │ │ ├── IndCompletion.lagda │ │ ├── ScottDomain.lagda │ │ └── StepFunctions.lagda │ ├── Basics │ │ ├── Curry.lagda │ │ ├── Dcpo.lagda │ │ ├── Exponential.lagda │ │ ├── FunctionComposition.lagda │ │ ├── LeastFixedPoint.lagda │ │ ├── Miscelanea.lagda │ │ ├── Pointed.lagda │ │ ├── Products.lagda │ │ ├── ProductsContinuity.lagda │ │ ├── SupComplete.lagda │ │ └── WayBelow.lagda │ ├── Bilimits │ │ ├── Dinfinity.lagda │ │ ├── Directed.lagda │ │ └── Sequential.lagda │ ├── Continuous-and-algebraic-domains.lagda │ ├── Examples │ │ ├── IdlDyadics.lagda │ │ ├── LiftingLargeProposition.lagda │ │ ├── Omega.lagda │ │ ├── Ordinals.lagda │ │ └── Powerset.lagda │ ├── IdealCompletion │ │ ├── IdealCompletion.lagda │ │ ├── Properties.lagda │ │ └── Retracts.lagda │ ├── Lifting │ │ ├── LiftingDcpo.lagda │ │ ├── LiftingSet.lagda │ │ └── LiftingSetAlgebraic.lagda │ ├── Part-I.lagda │ ├── Part-II.lagda │ ├── ScottModelOfPCF │ │ ├── PCF.lagda │ │ ├── PCFCombinators.lagda │ │ └── ScottModelOfPCF.lagda │ ├── Taboos │ │ └── ClassicalLiftingOfNaturalNumbers.lagda │ ├── Topology │ │ ├── ScottTopology.lagda │ │ └── ScottTopologyProperties.lagda │ └── index.lagda ├── Dominance │ ├── Decidable.lagda │ ├── Definition.lagda │ ├── Initial.lagda │ ├── Lifting.lagda │ └── index.lagda ├── Duploids │ ├── DeductiveSystem.lagda │ ├── Depolarization.lagda │ ├── Duploid.lagda │ ├── Preduploid.lagda │ └── index.lagda ├── Dyadics │ ├── Addition.lagda │ ├── Multiplication.lagda │ ├── Negation.lagda │ ├── Order.lagda │ ├── Type.lagda │ └── index.lagda ├── DyadicsInductive │ ├── DyadicOrder-PropTrunc.lagda │ ├── DyadicOrder.lagda │ ├── Dyadics.lagda │ └── index.lagda ├── EffectfulForcing │ ├── Internal │ │ ├── Correctness.lagda │ │ ├── Degrees.lagda │ │ ├── ExtensionalEquality.lagda │ │ ├── External.lagda │ │ ├── FurtherThoughts.lagda │ │ ├── Internal.lagda │ │ ├── InternalModCont.lagda │ │ ├── InternalModUniCont.lagda │ │ ├── PaperIndex.lagda │ │ ├── Subst.lagda │ │ ├── SystemT.lagda │ │ └── index.lagda │ ├── InternalWithoutOracle.lagda │ ├── MFPSAndVariations │ │ ├── Church.lagda │ │ ├── Combinators.lagda │ │ ├── CombinatoryT.lagda │ │ ├── Continuity.lagda │ │ ├── ContinuityProperties.lagda │ │ ├── Dialogue-to-Brouwer.lagda │ │ ├── Dialogue.lagda │ │ ├── Internal.lagda │ │ ├── LambdaCalculusVersionOfMFPS.lagda │ │ ├── MFPS-XXIX.lagda │ │ ├── SystemT.lagda │ │ ├── WithoutOracle.lagda │ │ └── index.lagda │ └── index.lagda ├── Factorial │ ├── Law.lagda │ ├── PlusOneLC.lagda │ ├── Swap.lagda │ └── index.lagda ├── Field │ ├── Axioms.lagda │ ├── DedekindReals.lagda │ ├── Rationals.lagda │ └── index.lagda ├── Fin │ ├── ArgMinMax.lagda │ ├── ArithmeticViaEquivalence.lagda │ ├── Bishop.lagda │ ├── Choice.lagda │ ├── Dedekind.lagda │ ├── Embeddings.lagda │ ├── Kuratowski.lagda │ ├── Omega.lagda │ ├── Order.lagda │ ├── Pigeonhole.lagda │ ├── Properties.lagda │ ├── Topology.lagda │ ├── Type.lagda │ ├── UniverseInvariance.lagda │ ├── Variation.lagda │ └── index.lagda ├── Games │ ├── Constructor.lagda │ ├── Discussion.lagda │ ├── Examples.lagda │ ├── FiniteHistoryDependent.lagda │ ├── FiniteHistoryDependentMonadic.lagda │ ├── Main.lagda │ ├── OptimalPlays.lagda │ ├── TicTacToe0.lagda │ ├── TicTacToe1.lagda │ ├── TicTacToe2.lagda │ ├── TypeTrees.lagda │ ├── alpha-beta.lagda │ └── index.lagda ├── GamesMGU │ ├── Constructor.lagda │ ├── Discussion.lagda │ ├── Examples.lagda │ ├── FiniteHistoryDependent.lagda │ ├── FiniteHistoryDependentMonadic.lagda │ ├── FiniteHistoryDependentRelativeMonadic.lagda │ ├── TicTacToe0.lagda │ ├── TicTacToe1.lagda │ ├── TicTacToe2.lagda │ ├── TypeTrees.lagda │ ├── alpha-beta-examples.lagda │ ├── alpha-beta.lagda │ └── index.lagda ├── Groups │ ├── Aut.lagda │ ├── Cokernel.lagda │ ├── Free.lagda │ ├── GroupActions.lagda │ ├── Homomorphisms.lagda │ ├── Image.lagda │ ├── Kernel.lagda │ ├── Large.lagda │ ├── Opposite.lagda │ ├── Quotient.lagda │ ├── Subgroups.lagda │ ├── Symmetric.lagda │ ├── Torsors.lagda │ ├── Triv.lagda │ ├── Type-Supplement.lagda │ ├── Type.lagda │ └── index.lagda ├── InfinitePigeon │ ├── Addition.agda │ ├── Cantor.agda │ ├── Choice.agda │ ├── DataStructures.agda │ ├── Equality.agda │ ├── Examples.agda │ ├── Finite-JK-Shifts.agda │ ├── Finite.agda │ ├── FinitePigeon.agda │ ├── InfinitePigeon.agda │ ├── InfinitePigeon2011-05-12.agda │ ├── InfinitePigeonLessEfficient.agda │ ├── InfinitePigeonOriginal.agda │ ├── J-AC-N.agda │ ├── J-DC.agda │ ├── J-Examples.agda │ ├── J-FinitePigeon.agda │ ├── J-InfinitePigeon.agda │ ├── J-PigeonProgram.agda │ ├── J-Shift-BBC.agda │ ├── J-Shift-Selection.agda │ ├── J-Shift.agda │ ├── JK-LogicalFacts.agda │ ├── JK-Monads.agda │ ├── K-AC-N.agda │ ├── K-DC.agda │ ├── K-Shift-BBC.agda │ ├── K-Shift-MBR.agda │ ├── K-Shift-Selection.agda │ ├── K-Shift-from-J-Shift.agda │ ├── K-Shift.agda │ ├── Logic.agda │ ├── LogicalFacts.agda │ ├── Naturals.agda │ ├── Order.agda │ ├── PigeonProgram.agda │ ├── ProgramsWithoutSpecification.agda │ ├── ProgramsWithoutSpecificationBis.agda │ ├── Two.agda │ └── index.agda ├── InjectiveTypes │ ├── Algebra.lagda │ ├── Article.lagda │ ├── Blackboard.lagda │ ├── CharacterizationViaLifting.lagda │ ├── CounterExamples.lagda │ ├── InhabitedTypesTaboo.lagda │ ├── MathematicalStructures.lagda │ ├── MathematicalStructuresMoreGeneral.lagda │ ├── OverSmallMaps.lagda │ ├── PointedDcpos.lagda │ ├── Resizing-working.lagda │ ├── Resizing.lagda │ ├── Sigma.lagda │ ├── Subtypes.lagda │ ├── WeakFactorizationSystem.lagda │ └── index.lagda ├── Integers │ ├── Abs.lagda │ ├── Addition.lagda │ ├── Division.lagda │ ├── Exponentiation.lagda │ ├── HCF.lagda │ ├── Multiplication.lagda │ ├── Negation.lagda │ ├── Order.lagda │ ├── Parity.lagda │ ├── Type.lagda │ └── index.lagda ├── Iterative │ ├── Finite.lagda │ ├── Multisets-Addendum.lagda │ ├── Multisets-HFLO.lagda │ ├── Multisets-IdentificationExample.lagda │ ├── Multisets.lagda │ ├── Ordinals-Addendum.lagda │ ├── Ordinals-working.lagda │ ├── Ordinals.lagda │ ├── Sets-Addendum.lagda │ ├── Sets.lagda │ └── index.lagda ├── Lifting │ ├── Algebras.lagda │ ├── Construction.lagda │ ├── EmbeddingDirectly.lagda │ ├── EmbeddingViaSIP.lagda │ ├── IdentityViaSIP.lagda │ ├── Miscelanea-PropExt-FunExt.lagda │ ├── Miscelanea.lagda │ ├── Monad.lagda │ ├── MonadVariation.lagda │ ├── Set.lagda │ ├── Size.lagda │ ├── UnivalentPrecategory.lagda │ └── index.lagda ├── Locales │ ├── AdjointFunctorTheoremForFrames.lagda │ ├── Adjunctions │ │ ├── Properties-DistributiveLattice.lagda │ │ └── Properties.lagda │ ├── BooleanAlgebra.lagda │ ├── CharacterisationOfContinuity.lagda │ ├── ClassificationOfScottOpens.lagda │ ├── Clopen.lagda │ ├── CompactRegular.lagda │ ├── Compactness │ │ ├── CharacterizationOfCompactLocales.lagda │ │ ├── Definition.lagda │ │ └── Properties.lagda │ ├── Complements.lagda │ ├── ContinuousMap │ │ ├── Definition.lagda │ │ ├── FrameHomomorphism-Definition.lagda │ │ ├── FrameHomomorphism-Properties.lagda │ │ ├── FrameIsomorphism-Definition.lagda │ │ ├── Homeomorphism-Definition.lagda │ │ ├── Homeomorphism-Properties.lagda │ │ └── Properties.lagda │ ├── DirectedFamily-Poset.lagda │ ├── DirectedFamily.lagda │ ├── DiscreteLocale │ │ ├── Basis.lagda │ │ ├── Definition.lagda │ │ ├── Two-Properties.lagda │ │ └── Two.lagda │ ├── DistributiveLattice │ │ ├── Definition-SigmaBased.lagda │ │ ├── Definition.lagda │ │ ├── Homomorphism.lagda │ │ ├── Ideal-Properties.lagda │ │ ├── Ideal.lagda │ │ ├── Isomorphism-Properties.lagda │ │ ├── Isomorphism.lagda │ │ ├── Properties.lagda │ │ ├── Resizing.lagda │ │ ├── Spectrum-Properties.lagda │ │ └── Spectrum.lagda │ ├── Frame.lagda │ ├── GaloisConnection.lagda │ ├── HeytingComplementation.lagda │ ├── HeytingImplication.lagda │ ├── InitialFrame.lagda │ ├── LawsonLocale │ │ ├── CompactElementsOfPoint.lagda │ │ ├── PointsOfPatch.lagda │ │ └── SharpElementsCoincideWithSpectralPoints.lagda │ ├── NotationalConventions.lagda │ ├── Nucleus.lagda │ ├── NucleusImage.lagda │ ├── PatchLocale.lagda │ ├── PatchOfOmega.lagda │ ├── PatchProperties.lagda │ ├── PerfectMaps.lagda │ ├── Point │ │ ├── Definition.lagda │ │ ├── Properties.lagda │ │ └── SpectralPoint-Definition.lagda │ ├── Regular.lagda │ ├── SIP │ │ ├── DistributiveLatticeSIP.lagda │ │ └── FrameSIP.lagda │ ├── ScottContinuity.lagda │ ├── ScottLocale │ │ ├── Definition.lagda │ │ ├── Properties.lagda │ │ ├── ScottLocalesOfAlgebraicDcpos.lagda │ │ └── ScottLocalesOfScottDomains.lagda │ ├── Sierpinski.lagda │ ├── Sierpinski │ │ ├── Definition.lagda │ │ ├── Patch.lagda │ │ ├── Properties.lagda │ │ └── UniversalProperty.lagda │ ├── SmallBasis.lagda │ ├── Spectrality │ │ ├── BasisDirectification.lagda │ │ ├── LatticeOfCompactOpens-Duality.lagda │ │ ├── LatticeOfCompactOpens.lagda │ │ ├── Properties.lagda │ │ ├── SpectralLocale.lagda │ │ ├── SpectralMap.lagda │ │ ├── SpectralMapToLatticeHomomorphism.lagda │ │ └── SpectralityOfOmega.lagda │ ├── Stone.lagda │ ├── StoneDuality │ │ └── ForSpectralLocales.lagda │ ├── StoneImpliesSpectral.lagda │ ├── TerminalLocale │ │ └── Properties.lagda │ ├── ThesisIndex.lagda │ ├── UniversalPropertyOfPatch.lagda │ ├── WayBelowRelation │ │ ├── Definition.lagda │ │ └── Properties.lagda │ ├── WellInside.lagda │ ├── ZeroDimensionality.lagda │ └── index.lagda ├── MGS │ ├── Basic-UF.lagda │ ├── Choice.lagda │ ├── Classifiers.lagda │ ├── Embeddings.lagda │ ├── Equivalence-Constructions.lagda │ ├── Equivalence-Induction.lagda │ ├── Equivalences.lagda │ ├── FunExt-from-Univalence.lagda │ ├── Function-Graphs.lagda │ ├── HAE.lagda │ ├── MLTT.lagda │ ├── Map-Classifiers.lagda │ ├── More-Exercise-Solutions.lagda │ ├── More-FunExt-Consequences.lagda │ ├── Partial-Functions.lagda │ ├── Powerset.lagda │ ├── Quotient.lagda │ ├── Retracts.lagda │ ├── SIP.lagda │ ├── Size.lagda │ ├── Solved-Exercises.lagda │ ├── Subsingleton-Theorems.lagda │ ├── Subsingleton-Truncation.lagda │ ├── TypeTopology-Interface.lagda │ ├── Unique-Existence.lagda │ ├── Univalence.lagda │ ├── Universe-Lifting.lagda │ ├── Yoneda.lagda │ ├── hlevels.lagda │ └── index.lagda ├── MLTT │ ├── AlternativePlus.lagda │ ├── Athenian.lagda │ ├── Bool.lagda │ ├── Empty-Type.lagda │ ├── Empty.lagda │ ├── Fin.lagda │ ├── Id.lagda │ ├── Identity-Type.lagda │ ├── List-Properties.lagda │ ├── List.lagda │ ├── Maybe.lagda │ ├── Natural-Numbers-Type.lagda │ ├── NaturalNumbers.lagda │ ├── Negation.lagda │ ├── Pi.lagda │ ├── Plus-Properties.lagda │ ├── Plus-Type.lagda │ ├── Plus.lagda │ ├── Sigma-Type.lagda │ ├── Sigma.lagda │ ├── Spartan.lagda │ ├── SpartanList.lagda │ ├── Two-Properties.lagda │ ├── Two.lagda │ ├── Unit-Properties.lagda │ ├── Unit-Type.lagda │ ├── Unit.lagda │ ├── Universes.lagda │ ├── Vector.lagda │ └── index.lagda ├── MetricSpaces │ ├── DedekindReals.lagda │ ├── Rationals.lagda │ ├── Type.lagda │ └── index.lagda ├── Modal │ ├── Homotopy.lagda │ ├── Open.lagda │ ├── ReflectiveSubuniverse.lagda │ ├── SigmaClosedReflectiveSubuniverse.lagda │ ├── Subuniverse.lagda │ └── index.lagda ├── MonadOnTypes │ ├── J-transf-variation.lagda │ ├── J-transf.lagda │ ├── J.lagda │ ├── JK.lagda │ ├── K.lagda │ ├── List.lagda │ ├── Monad.lagda │ ├── NonEmptyList.lagda │ ├── NonEmptyListOriginal.lagda │ ├── Reader.lagda │ └── index.lagda ├── MonadOnTypesMGU │ ├── J.lagda │ ├── JK.lagda │ ├── K.lagda │ ├── Monad.lagda │ ├── NonEmptyList.lagda │ ├── Reader.lagda │ └── index.lagda ├── Naturals │ ├── AbsoluteDifference.lagda │ ├── Addition.lagda │ ├── Binary.lagda │ ├── Division.lagda │ ├── ExitTruncation.lagda │ ├── Exponentiation.lagda │ ├── HCF.lagda │ ├── Multiplication.lagda │ ├── Order.lagda │ ├── Parity.lagda │ ├── Properties.lagda │ ├── RootsTruncation.lagda │ ├── Sequence.lagda │ ├── UniversalProperty.lagda │ └── index.lagda ├── Notation │ ├── CanonicalMap.lagda │ ├── Decimal.lagda │ ├── General.lagda │ ├── Order.lagda │ ├── UnderlyingType.lagda │ └── index.lagda ├── NotionsOfDecidability │ ├── Complemented.lagda │ ├── Decidable.lagda │ ├── DecidableClassifier.lagda │ ├── Digression.lagda │ ├── QuasiDecidable.lagda │ ├── SemiDecidable.lagda │ └── index.lagda ├── OrderedTypes │ ├── DeltaCompletePoset.lagda │ ├── Frame.lagda │ ├── FreeJoinSemiLattice.lagda │ ├── FreeSupLattice.lagda │ ├── JoinSemiLattices.lagda │ ├── Poset.lagda │ ├── PosetReflection.lagda │ ├── PredicativeLFP.lagda │ ├── SupLattice-SmallBasis.lagda │ ├── SupLattice.lagda │ ├── TwoElementPoset.lagda │ ├── ZornsLemma.lagda │ ├── index.lagda │ ├── sigma-frame.lagda │ └── sigma-sup-lattice.lagda ├── Ordinals │ ├── AdditionProperties.lagda │ ├── Arithmetic.lagda │ ├── Brouwer.lagda │ ├── BuraliForti.lagda │ ├── Closure.lagda │ ├── Codes.lagda │ ├── ConvergentSequence.lagda │ ├── CumulativeHierarchy-Addendum.lagda │ ├── CumulativeHierarchy.lagda │ ├── Equivalence.lagda │ ├── Exponentiation │ │ ├── DecreasingList.lagda │ │ ├── DecreasingListProperties-Concrete.lagda │ │ ├── Grayson.lagda │ │ ├── Paper.lagda │ │ ├── PropertiesViaTransport.lagda │ │ ├── RelatingConstructions.lagda │ │ ├── Specification.lagda │ │ ├── Supremum.lagda │ │ ├── Taboos.lagda │ │ ├── TrichotomousLeastElement.lagda │ │ └── index.lagda │ ├── Fin.lagda │ ├── Indecomposable.lagda │ ├── InfProperty.lagda │ ├── Injectivity.lagda │ ├── LexicographicCompactness.lagda │ ├── LexicographicOrder.lagda │ ├── Limit.lagda │ ├── Maps.lagda │ ├── MultiplicationProperties.lagda │ ├── NotationInterpretation.lagda │ ├── NotationInterpretation0.lagda │ ├── NotationInterpretation1.lagda │ ├── NotationInterpretation2.lagda │ ├── Notions.lagda │ ├── OrdinalOfOrdinals.lagda │ ├── OrdinalOfOrdinalsSuprema.lagda │ ├── OrdinalOfTruthValues.lagda │ ├── Propositions.lagda │ ├── ShulmanTaboo.lagda │ ├── SupSum.lagda │ ├── Taboos.lagda │ ├── ToppedArithmetic.lagda │ ├── ToppedType.lagda │ ├── TrichotomousArithmetic.lagda │ ├── TrichotomousType.lagda │ ├── Type.lagda │ ├── Underlying.lagda │ ├── WellOrderArithmetic.lagda │ ├── WellOrderTransport.lagda │ ├── WellOrderingPrinciple.lagda │ ├── WellOrderingTaboo.lagda │ └── index.lagda ├── PCF │ ├── Combinatory │ │ ├── PCF.lagda │ │ ├── PCFCombinators.lagda │ │ ├── ScottModelOfPCF.lagda │ │ └── index.lagda │ ├── Lambda │ │ ├── AbstractSyntax.lagda │ │ ├── Adequacy.lagda │ │ ├── ApplicativeApproximation.lagda │ │ ├── BigStep.lagda │ │ ├── Correctness.lagda │ │ ├── ScottModelOfContexts.lagda │ │ ├── ScottModelOfIfZero.lagda │ │ ├── ScottModelOfTerms.lagda │ │ ├── ScottModelOfTypes.lagda │ │ ├── Substitution.lagda │ │ ├── SubstitutionDenotational.lagda │ │ └── index.lagda │ └── index.lagda ├── PathSequences │ ├── Ap.lagda │ ├── Cancel.lagda │ ├── Concat.lagda │ ├── Inversion.lagda │ ├── Reasoning.lagda │ ├── Rotations.lagda │ ├── Split.lagda │ ├── Type.lagda │ └── index.lagda ├── Quotient │ ├── Effectivity.lagda │ ├── FromSetReplacement.lagda │ ├── GivesPropTrunc.lagda │ ├── GivesSetReplacement.lagda │ ├── Large-Variation.lagda │ ├── Large.lagda │ ├── Type.lagda │ └── index.lagda ├── Rationals │ ├── Abs.lagda │ ├── Addition.lagda │ ├── Extension.lagda │ ├── Fractions.lagda │ ├── FractionsOperations.lagda │ ├── FractionsOrder.lagda │ ├── Limits.lagda │ ├── MinMax.lagda │ ├── Multiplication.lagda │ ├── Negation.lagda │ ├── Order.lagda │ ├── Positive.lagda │ ├── Type.lagda │ └── index.lagda ├── Relations │ ├── ChurchRosser.lagda │ ├── SRTclosure.lagda │ └── index.lagda ├── RelativeMonadOnStructuredTypes │ ├── J-transf.lagda │ ├── Monad.lagda │ ├── NELWR.lagda │ ├── OneSigmaStructure.lagda │ └── index.lagda ├── Slice │ ├── Algebras.lagda │ ├── Construction.lagda │ ├── Embedding.lagda │ ├── Family.lagda │ ├── IdentityViaSIP.lagda │ ├── Monad.lagda │ └── index.lagda ├── TWA │ ├── BanachFixedPointTheorem.lagda │ ├── Closeness.lagda │ ├── Escardo-Simpson-LICS2001.lagda │ ├── SIP-IntervalObject.lagda │ ├── Thesis │ │ ├── AndrewSneap │ │ │ ├── DyadicRationals.lagda │ │ │ └── DyadicReals.lagda │ │ ├── Chapter2 │ │ │ ├── Finite.lagda │ │ │ ├── Sequences.lagda │ │ │ └── Vectors.lagda │ │ ├── Chapter3 │ │ │ ├── ClosenessSpaces-Examples.lagda │ │ │ ├── ClosenessSpaces.lagda │ │ │ ├── PredicateEquality.lagda │ │ │ ├── SearchableTypes-Examples.lagda │ │ │ └── SearchableTypes.lagda │ │ ├── Chapter4 │ │ │ ├── ApproxOrder-Examples.lagda │ │ │ ├── ApproxOrder.lagda │ │ │ ├── GlobalOptimisation.lagda │ │ │ └── ParametricRegression.lagda │ │ ├── Chapter5 │ │ │ ├── BoehmStructure.lagda │ │ │ ├── BoehmVerification.lagda │ │ │ ├── Integers.lagda │ │ │ ├── IntervalObject.lagda │ │ │ ├── IntervalObjectApproximation.lagda │ │ │ ├── SignedDigit.lagda │ │ │ └── SignedDigitIntervalObject.lagda │ │ ├── Chapter6 │ │ │ ├── Main.lagda │ │ │ ├── SequenceContinuity.lagda │ │ │ ├── SignedDigitContinuity.lagda │ │ │ ├── SignedDigitExamples.lagda │ │ │ ├── SignedDigitOrder.lagda │ │ │ └── SignedDigitSearch.lagda │ │ └── index.lagda │ └── index.lagda ├── Taboos │ ├── BasicDiscontinuity.lagda │ ├── Decomposability.lagda │ ├── DrinkerParadox.lagda │ ├── FiniteSubsetTaboo.lagda │ ├── LLPO.lagda │ ├── LPO.lagda │ ├── MarkovsPrinciple.lagda │ ├── P2.lagda │ ├── WLPO.lagda │ └── index.lagda ├── TypeTopology │ ├── ADecidableQuantificationOverTheNaturals.lagda │ ├── AbsolutenessOfCompactness.lagda │ ├── AbsolutenessOfCompactnessExample.lagda │ ├── Cantor.lagda │ ├── CantorMinusPoint.lagda │ ├── CantorSearch.lagda │ ├── CompactTypes.lagda │ ├── ConvergentSequenceHasInf.lagda │ ├── DecidabilityOfNonContinuity.lagda │ ├── DenseMapsProperties.lagda │ ├── Density.lagda │ ├── DisconnectedTypes.lagda │ ├── ExtendedSumCompact.lagda │ ├── FailureOfTotalSeparatedness.lagda │ ├── GenericConvergentSequenceCompactness.lagda │ ├── LimitPoints.lagda │ ├── PropInfTychonoff.lagda │ ├── PropTychonoff.lagda │ ├── RicesTheoremForTheUniverse.lagda │ ├── SequentiallyHausdorff.lagda │ ├── SigmaDiscreteAndTotallySeparated.lagda │ ├── SimpleTypes.lagda │ ├── SquashedCantor.lagda │ ├── SquashedSum.lagda │ ├── TheTopologyOfTheUniverse.lagda │ ├── TotallySeparated.lagda │ ├── UniformSearch.lagda │ ├── WeaklyCompactTypes.lagda │ └── index.lagda ├── UF │ ├── Base.lagda │ ├── Choice.lagda │ ├── ClassicalLogic.lagda │ ├── Classifiers-Old.lagda │ ├── Classifiers.lagda │ ├── Connected.lagda │ ├── ConnectedTypes.lagda │ ├── CumulativeHierarchy-LocallySmall.lagda │ ├── CumulativeHierarchy.lagda │ ├── DiscreteAndSeparated.lagda │ ├── Embeddings.lagda │ ├── Equiv-FunExt.lagda │ ├── Equiv.lagda │ ├── EquivalenceExamples.lagda │ ├── ExitPropTrunc.lagda │ ├── FunExt-Properties.lagda │ ├── FunExt-from-Naive-FunExt.lagda │ ├── FunExt.lagda │ ├── Groupoids.lagda │ ├── HLevels.lagda │ ├── Hedberg.lagda │ ├── HedbergApplications.lagda │ ├── HiddenSwap.lagda │ ├── HiggsInvolutionTheorem.lagda │ ├── IdEmbedding.lagda │ ├── IdentitySystems.lagda │ ├── ImageAndSurjection-Variation.lagda │ ├── ImageAndSurjection.lagda │ ├── Knapp-UA.lagda │ ├── KrausLemma.lagda │ ├── LeftCancellable.lagda │ ├── Logic.lagda │ ├── Lower-FunExt.lagda │ ├── NotNotStablePropositions.lagda │ ├── PairFun.lagda │ ├── Powerset-Fin.lagda │ ├── Powerset-MultiUniverse.lagda │ ├── Powerset-Resizing.lagda │ ├── Powerset.lagda │ ├── PreSIP-Examples.lagda │ ├── PreSIP.lagda │ ├── PreUnivalence.lagda │ ├── PropIndexedPiSigma.lagda │ ├── PropTrunc-Variation.lagda │ ├── PropTrunc.lagda │ ├── Pullback.lagda │ ├── Retracts-FunExt.lagda │ ├── Retracts.lagda │ ├── SIP-Examples.lagda │ ├── SIP.lagda │ ├── Section-Embedding.lagda │ ├── SemistrictIdentity.lagda │ ├── SetTrunc.lagda │ ├── Sets-Properties.lagda │ ├── Sets.lagda │ ├── SigmaIdentity.lagda │ ├── Singleton-Properties.lagda │ ├── Size-TruncatedConnected.lagda │ ├── Size.lagda │ ├── SmallnessProperties.lagda │ ├── StructureIdentityPrinciple.lagda │ ├── Subsingletons-FunExt.lagda │ ├── Subsingletons-Properties.lagda │ ├── Subsingletons.lagda │ ├── SubtypeClassifier-Properties.lagda │ ├── SubtypeClassifier.lagda │ ├── TruncatedTypes.lagda │ ├── TruncationLevels.lagda │ ├── Truncations.lagda │ ├── UA-FunExt.lagda │ ├── Univalence.lagda │ ├── UniverseEmbedding.lagda │ ├── Universes.lagda │ ├── Yoneda.lagda │ └── index.lagda ├── Unsafe │ ├── CantorCompact.lagda │ ├── CoNat-Equiv.lagda │ ├── CountableTychonoff.lagda │ ├── Haskell.lagda │ ├── Type-in-Type-False.lagda │ └── index.lagda ├── Various │ ├── CantorTheoremForEmbeddings.lagda │ ├── Dedekind.lagda │ ├── DummettDisjunction.lagda │ ├── Hydra.lagda │ ├── LawvereFPT.lagda │ ├── Lumsdaine.lagda │ ├── NonCollapsibleFamily.lagda │ ├── Pataraia-Taylor.lagda │ ├── Pataraia.lagda │ ├── RootsOfBooleanFunctions.lagda │ ├── Types2019.lagda │ ├── UnivalenceFromScratch.lagda │ └── index.lagda ├── W │ ├── Numbers.lagda │ ├── Paths.lagda │ ├── Properties.lagda │ ├── Type.lagda │ └── index.lagda ├── WildCategories │ ├── Base.lagda │ ├── Cones.lagda │ ├── Idempotents.lagda │ └── index.lagda ├── gist │ ├── DependentlyTypedTensors.lagda │ ├── InjectivesVersusAlgebras.lagda │ ├── IntervalObject.lagda │ ├── index.lagda │ ├── multiset-addendum-question.lagda │ ├── not-an-apartness.lagda │ ├── remove-swap.lagda │ └── transport-discussion.lagda └── index.lagda ├── typetopology.agda-lib └── updatehtml /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | pull_request: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | typecheck: 11 | runs-on: ubuntu-latest 12 | name: Typechecking 13 | if: github.event.pull_request.draft == false 14 | steps: 15 | - name: "Clone repository" 16 | uses: actions/checkout@v4 17 | 18 | - name: "Print environment information" 19 | shell: bash 20 | run: | 21 | echo "github.ref_name = ${{ github.ref_name }}" 22 | echo "github.sha = ${{ github.sha }}" 23 | echo "github.event.before = ${{ github.event.before }}" 24 | echo "github.event.after = ${{ github.event.after }}" 25 | echo "github.event.pull_request.head.sha = ${{ github.event.pull_request.head.sha }}" 26 | 27 | - name: "Restore cached .agdai files" 28 | id: cache-agdai-restore 29 | uses: actions/cache/restore@v4 30 | with: 31 | path: _build 32 | key: ${{ runner.os }}-agdai-cache-${{ github.ref_name }}-${{ github.event.before }} 33 | restore-keys: | 34 | ${{ runner.os }}-agdai-cache-${{ github.ref_name }}- 35 | 36 | - name: Run Agda 37 | id: typecheck 38 | uses: ayberkt/agda-github-action@v4.0 39 | with: 40 | main-file: AllModulesIndex.lagda 41 | source-dir: source 42 | unsafe: true 43 | 44 | - name: "Save .agdai files" 45 | id: cache-agdai-save 46 | uses: actions/cache/save@v4 47 | with: 48 | path: _build 49 | key: ${{ runner.os }}-agdai-cache-${{ github.ref_name }}-${{ github.event.after }} 50 | 51 | - name: Upload HTML 52 | id: html-upload 53 | if: github.ref == 'refs/heads/master' 54 | uses: actions/upload-artifact@v4 55 | with: 56 | name: html 57 | path: source/html 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | deploy 2 | agdatomd 3 | illiterator 4 | clean 5 | source/compileall 6 | source/working/* 7 | source/obsolete 8 | *.agdai 9 | *~ 10 | *.hi 11 | *.o 12 | *.aux 13 | *.log 14 | *.out 15 | *.pdf 16 | *.html 17 | *.blg 18 | *.bbl 19 | m 20 | c 21 | b 22 | e 23 | eq 24 | equiv 25 | html/* 26 | source/html/* 27 | *.DS_Store 28 | #* 29 | -------------------------------------------------------------------------------- /CODE-OF-CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of conduct 2 | 3 | By contributing, with pull requests, issues, discussion etc. in this 4 | repository, all participants agree to abide by the [Statement of 5 | Inclusion](STATEMENT-OF-INCLUSION.md). 6 | 7 | They also agree to abide by the [GitHub Community Code of 8 | Conduct](https://docs.github.com/en/site-policy/github-terms/github-community-code-of-conduct). 9 | -------------------------------------------------------------------------------- /STATEMENT-OF-INCLUSION.md: -------------------------------------------------------------------------------- 1 | # Statement of inclusion 2 | 3 | There are many reasons to contribute something to a library of formalized 4 | mathematics. Some do it just for fun, some do it for their research, some do it 5 | to learn something. Whatever your reason is, we welcome your contributions! To 6 | keep the experience of contributing something to our library enjoyable for 7 | everyone, we strive for an inclusive community of contributors. You can expect 8 | from us that we are kind and respectful in discussions, that we will be mindful 9 | of your pronouns and use 10 | [inclusive language](https://www.apa.org/about/apa/equity-diversity-inclusion/language-guidelines), 11 | and that we value your input regardless of your level of experience or status in 12 | the community. We're committed to providing a safe and welcoming environment to 13 | people of any gender identity, sexual orientation, race, colour, age, ability, 14 | ethnicity, background, or fluency in English -- here on GitHub, in online 15 | communication channels, and in person. Homotopy type theory is difficult enough 16 | without all the barriers that many of us have to face, so we hope to bring some 17 | of those down a bit. 18 | 19 | We have borrowed this statement literally from [agda-unimath](https://github.com/UniMath/agda-unimath/tree/master) with Egbert Rijke's permission. 20 | -------------------------------------------------------------------------------- /admin-utilities/generate-makefile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | agda --dependency-graph="admin-utilities/dependency_graph.dot" source/index.lagda && echo "Successfully generated `dependency_graph.dot`." 4 | 5 | ghc -O3 admin-utilities/GenerateMakefile.hs -o GenerateMakefile 6 | 7 | echo "Now generating Makefile..." 8 | 9 | ./GenerateMakefile > Makefile 10 | -------------------------------------------------------------------------------- /admin-utilities/illiterate: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p tmp/tmp-illiterate 3 | ghc --make illiterator.hs 4 | rm -f tmp/tmp-illiterate/*agda 5 | 6 | for i in $( ls | grep ".lagda" | grep -v "~" ); do 7 | cat ${i} | ./illiterator > tmp/tmp-illiterate/${i%%.*}.agda 8 | done 9 | -------------------------------------------------------------------------------- /admin-utilities/illiterator.hs: -------------------------------------------------------------------------------- 1 | {- 2 | Agda illiterator. 3 | 4 | This Haskell program converts from .lagda files to .agda files. 5 | Keeps only what is within code environments, removing lines which 6 | consist of comments without code. It it a unix pipe. There are 7 | no command-line options. 8 | 9 | Typical usage: 10 | 11 | $ cat file.lagda | runhaskell illiterator.hs > file.agda 12 | -} 13 | 14 | import Data.Char 15 | 16 | isComment :: String -> Bool 17 | isComment [] = False 18 | isComment (x : xs) = (x == '-' && not (null xs) && head xs == '-') 19 | || (isSpace x && isComment xs) 20 | 21 | begin = "\\begin{code}" 22 | end = "\\end{code}" 23 | 24 | illiterator, copy :: [String] -> String 25 | 26 | illiterator [] = [] 27 | illiterator (xs:xss) 28 | | take (length begin) (dropWhile isSpace xs) == begin = copy xss 29 | | otherwise = illiterator xss 30 | 31 | 32 | copy [] = [] 33 | copy (xs:xss) 34 | | take (length end) (dropWhile isSpace xs) == end = "\n" ++ illiterator xss 35 | | isComment xs = copy xss 36 | | otherwise = xs ++ "\n" ++ copy xss 37 | 38 | 39 | reduceBlankLines :: String -> String 40 | reduceBlankLines "" = "" 41 | reduceBlankLines ('\n' : '\n' : '\n' : xs) = reduceBlankLines ('\n' : '\n' : xs) 42 | reduceBlankLines (x:xs) = x : reduceBlankLines xs 43 | 44 | pipe :: String -> String 45 | pipe stdin = reduceBlankLines(illiterator(lines stdin)) 46 | 47 | 48 | main :: IO() 49 | main = interact pipe 50 | -------------------------------------------------------------------------------- /approximatefinddef: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Finds any definition that contains the word specified in the parameter. 4 | # Call from TypeTopology/source. 5 | 6 | # Example: 7 | # $ ../approximatefinddef is-prop 8 | 9 | set -Eeo pipefail 10 | 11 | param="$1" 12 | 13 | regex="^[[:space:]]*[^(){}]*${param}.* :" 14 | 15 | # This means "newline followed by zero or more spaces, then zero or 16 | # more characters that are not brackets, followed by the specified 17 | # word, following by zero or more occurences of anything, 18 | # followed by " :". 19 | 20 | echo $regex 21 | 22 | git ls-files . | grep agda | xargs grep -E "$regex" 23 | -------------------------------------------------------------------------------- /count-agda-files-and-lines: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | root_dir=$(git rev-parse --show-toplevel) 4 | 5 | git ls-files $root_dir/source | grep agda | wc -l 6 | git ls-files $root_dir/source | grep agda | xargs cat | wc -l 7 | -------------------------------------------------------------------------------- /findexactdef: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Finds any definition of the word specified in the parameter. 4 | # Call from TypeTopology/source. 5 | 6 | # Example: 7 | # $ ../findexactdef is-prop 8 | 9 | set -Eeo pipefail 10 | 11 | param="$1" 12 | 13 | regex="^[[:space:]]*${param} :" 14 | 15 | # This means newline followed by zero or more spaces, followed by the 16 | # specified word, followed by " :". 17 | 18 | git ls-files . | grep agda | xargs grep -E "$regex" 19 | -------------------------------------------------------------------------------- /indexupdatecount: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -Eeo pipefail 4 | 5 | root_dir=$(git rev-parse --show-toplevel) 6 | 7 | input_file="$root_dir/source/index.lagda" 8 | 9 | current_date=$(date +"%Y.%m.%d") 10 | 11 | file_count=$(git ls-files $root_dir/source | grep agda | wc -l | xargs) 12 | line_count=$(git ls-files $root_dir/source | grep agda | xargs cat | wc -l | xargs | awk '{printf "%.0fK\n", $1/1000}') 13 | 14 | echo "File count is $file_count." 15 | echo "Line count is $line_count." 16 | 17 | sed -i '' "s/In our last count, on [0-9.]\{1,\},/In our last count, on $current_date,/g" $input_file 18 | sed -i '' "s/this development has [0-9]\{1,\} Agda/this development has $file_count Agda/g" $input_file 19 | sed -i '' "s/files with [0-9kK]\{1,\} lines of code/files with $line_count lines of code/g" $input_file 20 | -------------------------------------------------------------------------------- /latex/CSB/PublicationAgreement.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinescardo/TypeTopology/1f8c0f01bcab53bb6473c8ace4739cb580fb5673/latex/CSB/PublicationAgreement.pdf -------------------------------------------------------------------------------- /latex/EffectfulForcing/dialogue.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinescardo/TypeTopology/1f8c0f01bcab53bb6473c8ace4739cb580fb5673/latex/EffectfulForcing/dialogue.pdf -------------------------------------------------------------------------------- /latex/EffectfulForcing/do: -------------------------------------------------------------------------------- 1 | # agda --html dialogue.lagda 2 | agda --latex dialogue.lagda 3 | # The following is needed to fix a bug in --latex in Agda 2.3.2: 4 | sed 's|extbackslash|\\textbackslash|' < latex/dialogue.tex > dialogue.tex 5 | # bibtex dialogue # .bbl is now included in the file 6 | pdflatex dialogue.tex # run a couple of times, as usual 7 | 8 | 9 | -------------------------------------------------------------------------------- /latex/EffectfulForcing/readme: -------------------------------------------------------------------------------- 1 | The file dialogue.lagda generates LaTeX and then pdf using the script 2 | "do". The script uses uses "sed" to fix a bug in --latex in Agda 3 | 2.3.2, wwhich is already fixed in the development version. 4 | 5 | -------------------------------------------------------------------------------- /latex/compact-ordinals-abstract/compact-ordinals-Types-2019-abstract.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/martinescardo/TypeTopology/1f8c0f01bcab53bb6473c8ace4739cb580fb5673/latex/compact-ordinals-abstract/compact-ordinals-Types-2019-abstract.pdf -------------------------------------------------------------------------------- /source/AllModulesIndex.lagda: -------------------------------------------------------------------------------- 1 | TypeTopology 2 | 3 | Various new theorems in 4 | constructive univalent mathematics 5 | written in Agda 6 | 7 | Martin Escardo and collaborators, 2010--2025--∞ 8 | Continuously evolving. 9 | 10 | https://www.cs.bham.ac.uk/~mhe/TypeTopology/ 11 | https://github.com/martinescardo/TypeTopology/ 12 | 13 | Tested with Agda 2.7.0.1. (It may still work with Agda 2.6.4.3.) 14 | 15 | \begin{code} 16 | 17 | {-# OPTIONS --without-K --type-in-type --no-level-universe --no-termination-check --guardedness #-} 18 | 19 | import index -- (1) 20 | import GamesMGU.index -- (2) 21 | import MonadOnTypesMGU.index -- (2) 22 | import RelativeMonadOnStructuredTypes.index -- (2) 23 | import Unsafe.index -- (3) 24 | import InfinitePigeon.index -- (4) 25 | 26 | \end{code} 27 | 28 | (1) Of --safe modules using --level-universe. 29 | (2) With --safe but --no-level-universe. 30 | (3) Of unsafe modules. 31 | (4) Disables termination check for bar recursion. 32 | 33 | See the module index for an explanation of the philosophy of TypeTopology. 34 | -------------------------------------------------------------------------------- /source/Apartness/Morphisms.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, 26 January 2018. 2 | 3 | Moved from the file TotallySeparated 22 August 2024. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | module Apartness.Morphisms where 10 | 11 | open import Apartness.Definition 12 | open import MLTT.Spartan 13 | open import UF.FunExt 14 | open import UF.Subsingletons 15 | open import UF.Subsingletons-FunExt 16 | 17 | \end{code} 18 | 19 | A map is called strongly extensional if it reflects apartness. In the 20 | category of apartness types, the morphisms are the strongly 21 | extensional maps. 22 | 23 | \begin{code} 24 | 25 | is-strongly-extensional : ∀ {𝓣} {X : 𝓤 ̇ } {Y : 𝓥 ̇ } 26 | → (X → X → 𝓦 ̇ ) → (Y → Y → 𝓣 ̇ ) → (X → Y) → 𝓤 ⊔ 𝓦 ⊔ 𝓣 ̇ 27 | is-strongly-extensional _♯_ _♯'_ f = ∀ x x' → f x ♯' f x' → x ♯ x' 28 | 29 | being-strongly-extensional-is-prop : Fun-Ext 30 | → {X : 𝓤 ̇ } {Y : 𝓥 ̇ } 31 | → (_♯_ : X → X → 𝓦 ̇ ) 32 | → (_♯'_ : Y → Y → 𝓣 ̇ ) 33 | → is-prop-valued _♯_ 34 | → (f : X → Y) 35 | → is-prop (is-strongly-extensional _♯_ _♯'_ f) 36 | being-strongly-extensional-is-prop fe _♯_ _♯'_ ♯p f = 37 | Π₃-is-prop fe (λ x x' a → ♯p x x') 38 | 39 | preserves : ∀ {𝓣} {X : 𝓤 ̇ } {Y : 𝓥 ̇ } 40 | → (X → X → 𝓦 ̇ ) → (Y → Y → 𝓣 ̇ ) → (X → Y) → 𝓤 ⊔ 𝓦 ⊔ 𝓣 ̇ 41 | preserves R S f = ∀ {x x'} → R x x' → S (f x) (f x') 42 | 43 | \end{code} 44 | -------------------------------------------------------------------------------- /source/Apartness/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, 26 January 2018 2 | 3 | Moved from the file TotallySeparated 22 August 2024, and split into 4 | the following modules. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module Apartness.index where 11 | 12 | import Apartness.Definition 13 | import Apartness.Morphisms 14 | import Apartness.Negation 15 | import Apartness.Properties 16 | import Apartness.TightReflection 17 | 18 | \end{code} 19 | -------------------------------------------------------------------------------- /source/BinarySystems/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module BinarySystems.index where 8 | 9 | import BinarySystems.InitialBinarySystem -- More work than needed! 10 | import BinarySystems.InitialBinarySystem2 -- No need to work with subtype of normal elements. 11 | -- import BinarySystems.CubicalBinarySystem -- By Martin Escardo and Alex Rice; 12 | -- works with Agda 2.6.2 and needs the Cubical Library. 13 | \end{code} 14 | -------------------------------------------------------------------------------- /source/CantorSchroederBernstein/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 2 | 3 | https://doi.org/10.1007/s40062-021-00284-6 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | module CantorSchroederBernstein.index where 10 | 11 | import CantorSchroederBernstein.CSB 12 | import CantorSchroederBernstein.CSB-TheoryLabLunch 13 | 14 | \end{code} 15 | -------------------------------------------------------------------------------- /source/Cardinals/Type.lagda: -------------------------------------------------------------------------------- 1 | Jon Sterling, 25th March 2023. 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | open import MLTT.Spartan 8 | open import UF.SetTrunc 9 | 10 | module Cardinals.Type (st : set-truncations-exist) where 11 | 12 | open import UF.Sets 13 | 14 | import UF.Logic 15 | 16 | open set-truncations-exist st 17 | 18 | Card : (𝓤 : Universe) → 𝓤 ⁺ ̇ 19 | Card 𝓤 = set-trunc (hSet 𝓤) 20 | 21 | Card-is-set : is-set (Card 𝓤) 22 | Card-is-set = set-trunc-is-set 23 | 24 | \end{code} 25 | -------------------------------------------------------------------------------- /source/Cardinals/index.lagda: -------------------------------------------------------------------------------- 1 | Jon Sterling 2 | 3 | Started 25 March 2023. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | module Cardinals.index where 10 | 11 | import Cardinals.Type 12 | import Cardinals.Preorder 13 | import Cardinals.Successor 14 | 15 | \end{code} 16 | -------------------------------------------------------------------------------- /source/Categories/index.lagda: -------------------------------------------------------------------------------- 1 | Jon Sterling, 16 Dec 2022 2 | 3 | This is a nascent development of some basic 1-category theory from the univalent 4 | point of view. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module Categories.index where 11 | 12 | import Categories.Category 13 | import Categories.Functor 14 | import Categories.NaturalTransformation 15 | import Categories.Adjunction 16 | 17 | \end{code} 18 | -------------------------------------------------------------------------------- /source/Circle/Integers.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong 2 | Reboot: 22 January 2021 3 | Earlier version: 18 September 2020 4 | 5 | We construct the type of integers with the aim of using them in constructing the 6 | circle as the type of ℤ-torsors, as described in "Construction of the circle in 7 | UniMath" by Bezem, Buchholtz, Grayson and Shulman 8 | (doi:10.1016/j.jpaa.2021.106687). 9 | 10 | See Integers-Properties and Integers-SymmetricInduction for (more) properties of 11 | the type of integers. 12 | 13 | \begin{code} 14 | 15 | {-# OPTIONS --safe --without-K #-} 16 | 17 | open import MLTT.Spartan 18 | 19 | module Circle.Integers where 20 | 21 | ℤ : 𝓤₀ ̇ 22 | ℤ = 𝟙 + ℕ + ℕ 23 | 24 | pattern 𝟎 = inl ⋆ 25 | pattern pos i = inr (inl i) 26 | pattern neg i = inr (inr i) 27 | 28 | ℕ-to-ℤ₊ : ℕ → ℤ 29 | ℕ-to-ℤ₊ 0 = 𝟎 30 | ℕ-to-ℤ₊ (succ n) = pos n 31 | 32 | ℕ-to-ℤ₋ : ℕ → ℤ 33 | ℕ-to-ℤ₋ 0 = 𝟎 34 | ℕ-to-ℤ₋ (succ n) = neg n 35 | 36 | ℤ-induction : {𝓤 : Universe} (P : ℤ → 𝓤 ̇ ) 37 | → P 𝟎 38 | → ((n : ℕ) → P (ℕ-to-ℤ₊ n) → P (ℕ-to-ℤ₊ (succ n))) 39 | → ((n : ℕ) → P (ℕ-to-ℤ₋ n) → P (ℕ-to-ℤ₋ (succ n))) 40 | → (z : ℤ) → P z 41 | ℤ-induction {𝓤} P p₀ p₊ p₋ 𝟎 = p₀ 42 | ℤ-induction {𝓤} P p₀ p₊ p₋ (pos i) = h (succ i) 43 | where 44 | P₊ : ℕ → 𝓤 ̇ 45 | P₊ = P ∘ ℕ-to-ℤ₊ 46 | h : (n : ℕ) → P₊ n 47 | h = ℕ-induction p₀ p₊ 48 | ℤ-induction {𝓤} P p₀ p₊ p₋ (neg i) = h (succ i) 49 | where 50 | P₋ : ℕ → 𝓤 ̇ 51 | P₋ = P ∘ ℕ-to-ℤ₋ 52 | h : (n : ℕ) → P₋ n 53 | h = ℕ-induction p₀ p₋ 54 | 55 | \end{code} 56 | -------------------------------------------------------------------------------- /source/Circle/index.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong, 2 April 2021 2 | 3 | The following modules construct the circle 𝕊¹ as the type of ℤ-torsors, 4 | following "Construction of the circle in UniMath" by Bezem, Buchholtz, Grayson 5 | and Shulman (doi:10.1016/j.jpaa.2021.106687). 6 | 7 | \begin{code} 8 | 9 | {-# OPTIONS --safe --without-K #-} 10 | 11 | module Circle.index where 12 | 13 | import Circle.Integers 14 | import Circle.Integers-Properties 15 | import Circle.Integers-SymmetricInduction 16 | 17 | import Circle.Construction 18 | import Circle.Induction 19 | 20 | \end{code} 21 | -------------------------------------------------------------------------------- /source/CoNaturals/BothTypes.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module CoNaturals.BothTypes where 6 | 7 | open import CoNaturals.GenericConvergentSequence public hiding (is-finite') 8 | open import CoNaturals.GenericConvergentSequence2 public 9 | open import CoNaturals.Equivalence public 10 | open import CoNaturals.Type2Properties public 11 | 12 | \end{code} 13 | -------------------------------------------------------------------------------- /source/CoNaturals/Type.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 2024. 2 | 3 | Interface file. Please use this rather than the 2012 file imported below. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | module CoNaturals.Type where 10 | 11 | open import CoNaturals.GenericConvergentSequence public 12 | 13 | \end{code} 14 | -------------------------------------------------------------------------------- /source/CoNaturals/Type2.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module CoNaturals.Type2 where 6 | 7 | open import CoNaturals.GenericConvergentSequence2 8 | renaming ( 9 | ℕ∞' to ℕ∞ ; 10 | ℕ-to-ℕ∞' to ℕ-to-ℕ∞ ; 11 | is-finite' to is-finite ; 12 | size' to size ; 13 | being-finite'-is-prop to being-finite-is-prop ; 14 | ℕ∞'-to-ℕ→𝟚 to ℕ∞-to-ℕ→𝟚 ; 15 | ∞' to ∞ ; 16 | is-infinite-∞' to is-infinite-∞ ; 17 | ℕ-to-ℕ∞'-is-finite' to ℕ-to-ℕ∞-is-finite 18 | ) 19 | public 20 | 21 | open import CoNaturals.Type2Properties 22 | renaming ( 23 | ℕ-to-ℕ∞'-diagonal to ℕ-to-ℕ∞-diagonal ; 24 | ℕ∞'-equality-criterion to ℕ∞-equality-criterion ; 25 | ℕ-to-ℕ∞'-lc to ℕ-to-ℕ∞-lc ; 26 | finite'-isolated to finite-isolated ; 27 | size'-property' to size-property 28 | ) 29 | public 30 | 31 | \end{code} 32 | -------------------------------------------------------------------------------- /source/CoNaturals/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module CoNaturals.index where 8 | 9 | import CoNaturals.Type -- The type of conatural numbers. 10 | import CoNaturals.Type2 -- An equivalent copy. 11 | import CoNaturals.UniversalProperty 12 | import CoNaturals.Equivalence 13 | import CoNaturals.Type2Properties 14 | import CoNaturals.BothTypes 15 | import CoNaturals.Arithmetic 16 | import CoNaturals.Exercise -- With Chuangjie Xu. 17 | import CoNaturals.GenericConvergentSequence -- Avoid to import directly. 18 | import CoNaturals.GenericConvergentSequence2 -- Avoid to import directly. 19 | import CoNaturals.Sharp 20 | 21 | \end{code} 22 | -------------------------------------------------------------------------------- /source/ContinuityAxiom/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo and Chuangjie Xu, 2013, 2015 2 | 3 | The Inconsistency of a Brouwerian Continuity Principle with the 4 | Curry–Howard Interpretation (TLCA'2015). 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module ContinuityAxiom.index where 11 | 12 | import ContinuityAxiom.False 13 | import ContinuityAxiom.FalseWithoutIdentityTypes 14 | import ContinuityAxiom.ExitingTruncations 15 | import ContinuityAxiom.Preliminaries 16 | import ContinuityAxiom.UniformContinuity 17 | 18 | \end{code} 19 | 20 | @InProceedings{htzelescard_et_al:LIPIcs:2015:5161, 21 | author = {Mart{\'i}n H{\"o}tzel Escard{\'o} and Chuangjie Xu}, 22 | title = {{The Inconsistency of a Brouwerian Continuity Principle with the Curry–Howard Interpretation}}, 23 | booktitle = {13th International Conference on Typed Lambda Calculi and Applications (TLCA 2015)}, 24 | pages = {153--164}, 25 | series = {Leibniz International Proceedings in Informatics (LIPIcs)}, 26 | ISBN = {978-3-939897-87-3}, 27 | ISSN = {1868-8969}, 28 | year = {2015}, 29 | volume = {38}, 30 | editor = {Thorsten Altenkirch}, 31 | publisher = {Schloss Dagstuhl--Leibniz-Zentrum fuer Informatik}, 32 | address = {Dagstuhl, Germany}, 33 | URL = {http://drops.dagstuhl.de/opus/volltexte/2015/5161}, 34 | URN = {urn:nbn:de:0030-drops-51618}, 35 | doi = {10.4230/LIPIcs.TLCA.2015.153}, 36 | annote = {Keywords: Dependent type, intensional Martin-L{\"o}f type theory, Curry-Howard interpretation, constructive mathematics, Brouwerian continuity axioms, anonymous exi} 37 | } 38 | -------------------------------------------------------------------------------- /source/Coslice/Type.lagda: -------------------------------------------------------------------------------- 1 | Jonathan Sterling, 22nd March 2023. 2 | 3 | In this module we define the coslice of a universe under a given type; in fact, 4 | our construction is slightly more general, as we allow the given type to lie in 5 | a different universe. This is useful for characterizing things like small 6 | reflective subuniverses, which arise when studying impredicativity. 7 | 8 | \begin{code} 9 | {-# OPTIONS --safe --without-K #-} 10 | 11 | module Coslice.Type where 12 | 13 | open import MLTT.Spartan 14 | 15 | _↓_ : 𝓥 ̇ → (𝓤 : Universe) → 𝓥 ⊔ 𝓤 ⁺ ̇ 16 | A ↓ 𝓤 = Σ I ꞉ 𝓤 ̇ , (A → I) 17 | 18 | Coslice : 𝓤 ̇ → 𝓤 ⁺ ̇ 19 | Coslice A = A ↓ _ 20 | 21 | module _ {A : 𝓥 ̇ } where 22 | target : A ↓ 𝓤 → 𝓤 ̇ 23 | target (I , α) = I 24 | 25 | alg : (X : A ↓ 𝓤) → A → target X 26 | alg (I , α) = α 27 | 28 | \end{code} 29 | -------------------------------------------------------------------------------- /source/Coslice/index.lagda: -------------------------------------------------------------------------------- 1 | Jonathan Sterling 2 | 3 | The goal of these modules is to study the coslice (∞,1)-category of a universe 4 | under a given type. We cannot formalize the entirety of this concept in the 5 | current univalent foundations, but we nonetheless can do things like 6 | characterize path spaces, etc. 7 | 8 | \begin{code} 9 | 10 | {-# OPTIONS --safe --without-K #-} 11 | 12 | module Coslice.index where 13 | 14 | import Coslice.Type 15 | import Coslice.Hom 16 | 17 | \end{code} 18 | -------------------------------------------------------------------------------- /source/CrossedModules/index.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module CrossedModules.index where 6 | 7 | import CrossedModules.CrossedModules -- by Ettore Aldrovandi and Keri D'Angelo 8 | 9 | \end{code} 10 | -------------------------------------------------------------------------------- /source/DedekindReals/index.lagda: -------------------------------------------------------------------------------- 1 | Andrew Sneap 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module DedekindReals.index where 8 | 9 | import DedekindReals.Type 10 | import DedekindReals.Addition 11 | import DedekindReals.Extension 12 | import DedekindReals.Functions 13 | import DedekindReals.Multiplication 14 | import DedekindReals.Order 15 | import DedekindReals.Properties 16 | 17 | \end{code} 18 | -------------------------------------------------------------------------------- /source/DiscreteGraphicMonoids/LWRDGM.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo and Paulo Oliva, April 2024 2 | 3 | The type of lists without repetitions over a discrete type forms a 4 | discrete graphic monoid. In another module, we prove that it gives the 5 | free discrete graphic monoid. 6 | 7 | \begin{code} 8 | 9 | {-# OPTIONS --safe --without-K #-} 10 | 11 | open import UF.FunExt 12 | 13 | module DiscreteGraphicMonoids.LWRDGM 14 | (fe : Fun-Ext) 15 | where 16 | 17 | open import DiscreteGraphicMonoids.ListsWithoutRepetitions fe 18 | open import DiscreteGraphicMonoids.Type 19 | open import MLTT.List 20 | renaming (_∷_ to _•_ ; -- typed as \bub 21 | _++_ to _◦_ ; -- typed as \buw 22 | ++-assoc to ◦-assoc) 23 | open import MLTT.Spartan 24 | open import UF.DiscreteAndSeparated 25 | 26 | module _ 27 | {𝓤 : Universe} 28 | {X : 𝓤 ̇ } 29 | {{d' : is-discrete' X}} 30 | where 31 | 32 | private 33 | d : is-discrete X 34 | d = discrete'-gives-discrete 35 | 36 | graphical⁻ : graphical (_·_ {𝓤} {X}) 37 | graphical⁻ (xs , a) (ys , b) = 38 | to-List⁻-= 39 | (ρ (ρ (xs ◦ ys) ◦ xs) =⟨ ρ-left (xs ◦ ys) xs ⟩ 40 | ρ ((xs ◦ ys) ◦ xs) =⟨ ρ-◦ (xs ◦ ys) xs ⟩ 41 | ρ (xs ◦ ys) ◦ (Δ (xs ◦ ys) (ρ xs)) =⟨ ap (ρ (xs ◦ ys) ◦_) (ρ-all xs ys) ⟩ 42 | ρ (xs ◦ ys) ◦ [] =⟨ ([]-right-neutral (ρ (xs ◦ ys)))⁻¹ ⟩ 43 | ρ (xs ◦ ys) ∎) 44 | 45 | \end{code} 46 | 47 | The discrete graphic monoid of lists without repetition over a 48 | discrete type. 49 | 50 | \begin{code} 51 | 52 | List⁻-DGM : (X : 𝓤 ̇ ) {{d : is-discrete' X}} → DGM 𝓤 53 | List⁻-DGM X = 54 | List⁻ X , 55 | ([]⁻ , _·_) , 56 | List⁻-is-discrete , 57 | []⁻-left-neutral , 58 | []⁻-right-neutral , 59 | ·-assoc , 60 | graphical⁻ 61 | 62 | \end{code} 63 | -------------------------------------------------------------------------------- /source/DomainTheory/ScottModelOfPCF/PCF.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong & Martin Escardo, 20 May 2019. 2 | 3 | Combinatory version of Platek-Scott-Plotkin PCF. 4 | Includes (reflexive transitive closure of) operational semantics. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | open import UF.PropTrunc 11 | 12 | module DomainTheory.ScottModelOfPCF.PCF (pt : propositional-truncations-exist) where 13 | 14 | open import PCF.Combinatory.PCF pt public 15 | 16 | \end{code} 17 | -------------------------------------------------------------------------------- /source/DomainTheory/ScottModelOfPCF/PCFCombinators.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong, 27 May 2019. 2 | Refactored December 2021. 3 | 4 | * Continuous K and S functions. These will interpret the K and S combinators of 5 | PCF in ScottModelOfPCF.lagda. 6 | * Continuous ifZero function specific to the lifting of the natural numbers. 7 | This will then be used to interpret the ifZero combinator of PCF in 8 | ScottModelOfPCF.lagda. 9 | 10 | \begin{code} 11 | 12 | {-# OPTIONS --safe --without-K #-} 13 | 14 | open import MLTT.Spartan 15 | open import UF.FunExt 16 | open import UF.PropTrunc 17 | 18 | module DomainTheory.ScottModelOfPCF.PCFCombinators 19 | (pt : propositional-truncations-exist) 20 | (fe : Fun-Ext) 21 | (𝓥 : Universe) 22 | where 23 | 24 | open import PCF.Combinatory.PCFCombinators pt fe 𝓥 public 25 | 26 | \end{code} 27 | -------------------------------------------------------------------------------- /source/DomainTheory/ScottModelOfPCF/ScottModelOfPCF.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong, 31 May 2019 2 | Updated comments on 21 June 2022. 3 | Added examples at the end on 22 December 2022. 4 | 5 | The denotational semantics of PCF based on pointed directed complete posets. 6 | 7 | The flag --lossy-unification significantly speeds up the 8 | typechecking of the line ⟦ S {ρ} {σ} {τ} ⟧ₑ = Sᵈᶜᵖᵒ⊥ ⟦ ρ ⟧ ⟦ σ ⟧ ⟦ τ ⟧ below. 9 | (https://agda.readthedocs.io/en/latest/language/lossy-unification.html) 10 | 11 | 12 | We consider the combinatory version of PCF here. This development was extended 13 | to PCF with variables and λ-abstraction by Brendan Hart in a final year project 14 | supervised by Martín Escardó and myself. Notably, Brendan's extension contains 15 | an Agda formalization of soundness and computational adequacy. 16 | 17 | Brendan's code, using a previous version of our library, can be found 18 | here: https://github.com/BrendanHart/Investigating-Properties-of-PCF. 19 | 20 | The repository also contains Brendan's report describing the project: 21 | https://github.com/BrendanHart/Investigating-Properties-of-PCF/blob/master/InvestigatingPropertiesOfPCFInAgda.pdf. 22 | 23 | \begin{code} 24 | 25 | {-# OPTIONS --safe --without-K --lossy-unification #-} 26 | 27 | open import MLTT.Spartan 28 | open import UF.PropTrunc 29 | open import UF.FunExt 30 | open import UF.Subsingletons 31 | 32 | module DomainTheory.ScottModelOfPCF.ScottModelOfPCF 33 | (pt : propositional-truncations-exist) 34 | (fe : Fun-Ext) 35 | (pe : propext 𝓤₀) 36 | where 37 | 38 | 39 | open import PCF.Combinatory.ScottModelOfPCF pt fe pe public 40 | 41 | \end{code} 42 | -------------------------------------------------------------------------------- /source/Dominance/Decidable.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, January 2018, May 2020 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module Dominance.Decidable where 8 | 9 | open import Dominance.Definition 10 | open import MLTT.Spartan 11 | open import NotionsOfDecidability.Decidable 12 | open import UF.FunExt 13 | open import UF.Subsingletons 14 | open import UF.Subsingletons-FunExt 15 | 16 | decidable-dominance : Fun-Ext → Dominance {𝓤} {𝓤} 17 | decidable-dominance fe = (λ P → is-prop P × is-decidable P) , 18 | (λ P → Σ-is-prop 19 | (being-prop-is-prop fe) 20 | (decidability-of-prop-is-prop fe)) , 21 | (λ X → pr₁) , 22 | (𝟙-is-prop , inl ⋆) , 23 | λ P Q dP dQ → Σ-is-prop (pr₁ dP) (λ p → pr₁ (dQ p)) , 24 | decidable-closed-under-Σ 25 | (pr₁ dP) (pr₂ dP) λ p → pr₂ (dQ p) 26 | \end{code} 27 | -------------------------------------------------------------------------------- /source/Dominance/Initial.lagda: -------------------------------------------------------------------------------- 1 | Jonathan Sterling, June 2023 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | open import Dominance.Definition 8 | open import MLTT.Spartan 9 | open import UF.Univalence 10 | 11 | 12 | import UF.PairFun as PairFun 13 | 14 | module Dominance.Initial 15 | {𝓣 𝓚 : Universe} 16 | (𝓣-ua : is-univalent 𝓣) 17 | (d : 𝓣 ̇ → 𝓚 ̇ ) 18 | (isd : is-dominance d) 19 | where 20 | 21 | open import Dominance.Lifting {𝓣} {𝓚} 𝓣-ua d isd 22 | open import W.Type 23 | 24 | module Initial-Lift-Algebra where 25 | ω : 𝓣 ⁺ ⊔ 𝓚 ̇ 26 | ω = W (dominant-prop D) pr₁ 27 | 28 | \end{code} 29 | -------------------------------------------------------------------------------- /source/Dominance/index.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module Dominance.index where 6 | 7 | import Dominance.Definition 8 | import Dominance.Decidable 9 | import Dominance.Initial 10 | import Dominance.Lifting 11 | 12 | \end{code} 13 | -------------------------------------------------------------------------------- /source/Dyadics/index.lagda: -------------------------------------------------------------------------------- 1 | Andrew Sneap 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module Dyadics.index where 8 | 9 | import Dyadics.Addition 10 | import Dyadics.Multiplication 11 | import Dyadics.Negation 12 | import Dyadics.Order 13 | import Dyadics.Type 14 | 15 | \end{code} 16 | -------------------------------------------------------------------------------- /source/DyadicsInductive/DyadicOrder-PropTrunc.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong, 7 March 2020 2 | 3 | As suggested by Martin Escardo. 4 | 5 | No endpoints, density and binary interpolation for (𝔻 , ≺) formulated using ∃. 6 | 7 | \begin{code} 8 | 9 | {-# OPTIONS --safe --without-K #-} 10 | 11 | open import MLTT.Spartan 12 | open import DyadicsInductive.Dyadics 13 | open import DyadicsInductive.DyadicOrder 14 | open import UF.PropTrunc 15 | 16 | module DyadicsInductive.DyadicOrder-PropTrunc (pt : propositional-truncations-exist) where 17 | 18 | open PropositionalTruncation pt 19 | 20 | ≺-has-no-left-endpoint : (x : 𝔻) → ∃ y ꞉ 𝔻 , y ≺ x 21 | ≺-has-no-left-endpoint x = ∣ ≺-has-no-left-endpoint-Σ x ∣ 22 | 23 | ≺-has-no-right-endpoint : (x : 𝔻) → ∃ y ꞉ 𝔻 , x ≺ y 24 | ≺-has-no-right-endpoint x = ∣ ≺-has-no-right-endpoint-Σ x ∣ 25 | 26 | ≺-is-dense : {x y : 𝔻} → x ≺ y → ∃ z ꞉ 𝔻 , x ≺ z × z ≺ y 27 | ≺-is-dense {x} {y} l = ∣ ≺-is-dense-Σ x y l ∣ 28 | 29 | ≺-interpolation₂ : (x₁ x₂ y : 𝔻) → x₁ ≺ y → x₂ ≺ y 30 | → ∃ z ꞉ 𝔻 , x₁ ≺ z × x₂ ≺ z × z ≺ y 31 | ≺-interpolation₂ x₁ x₂ y l₁ l₂ = ∣ ≺-interpolation₂-Σ x₁ x₂ y l₁ l₂ ∣ 32 | 33 | \end{code} 34 | -------------------------------------------------------------------------------- /source/DyadicsInductive/index.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong, 10 March 2020 2 | 3 | As suggested by Martin Escardo. 4 | 5 | Cluster module for inductively defined dyadic rationals. 6 | 7 | \begin{code} 8 | 9 | {-# OPTIONS --safe --without-K #-} 10 | 11 | module DyadicsInductive.index where 12 | 13 | import DyadicsInductive.Dyadics 14 | import DyadicsInductive.DyadicOrder 15 | import DyadicsInductive.DyadicOrder-PropTrunc 16 | 17 | \end{code} 18 | -------------------------------------------------------------------------------- /source/EffectfulForcing/Internal/Degrees.lagda: -------------------------------------------------------------------------------- 1 | Ayberk Tosun 2 | 3 | Finished on 31 August 2023. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | open import UF.FunExt 10 | 11 | module EffectfulForcing.Internal.Degrees (fe : Fun-Ext) where 12 | 13 | open import MLTT.Spartan 14 | open import EffectfulForcing.MFPSAndVariations.SystemT 15 | using (type; ι; _⇒_;〖_〗) 16 | open import Naturals.Order using (max) 17 | open import EffectfulForcing.Internal.SystemT 18 | 19 | \end{code} 20 | 21 | The degree of a type is the height of the tallest exponent tower involved in it. 22 | 23 | \begin{code} 24 | 25 | degree : type → ℕ 26 | degree ι = 0 27 | degree (τ₁ ⇒ τ₂) = max (succ (degree τ₁)) (degree τ₂) 28 | 29 | \end{code} 30 | 31 | Some examples of `degree`. 32 | 33 | \begin{code} 34 | 35 | degree-example₁ : degree (ι ⇒ ι) = 1 36 | degree-example₁ = refl 37 | 38 | degree-example₂ : degree (ι ⇒ (ι ⇒ ι)) = 1 39 | degree-example₂ = refl 40 | 41 | degree-example₃ : degree ((ι ⇒ ι) ⇒ ι) = 2 42 | degree-example₃ = refl 43 | 44 | \end{code} 45 | 46 | \begin{code} 47 | 48 | rank : {Γ : Cxt} {τ : type} → T Γ τ → ℕ 49 | rank {_} {ι} Zero = 0 50 | rank {_} {ι} (Succ t) = rank t 51 | rank {_} {τ} (Rec t t₁ t₂) = max (max (degree τ) (rank t₁)) (rank t₂) 52 | rank {_} {τ} (ν i) = 0 53 | rank {_} {τ} (ƛ t) = rank t 54 | rank {_} {_} (t₁ · t₂) = max (rank t₁) (rank t₂) 55 | 56 | \end{code} 57 | -------------------------------------------------------------------------------- /source/EffectfulForcing/Internal/ExtensionalEquality.lagda: -------------------------------------------------------------------------------- 1 | --- 2 | authors: 3 | - Bruno da Rocha Paiva 4 | - Vincent Rahli 5 | date-started: 2023-11-08 6 | --- 7 | 8 | \begin{code} 9 | 10 | {-# OPTIONS --safe --without-K --exact-split #-} 11 | 12 | module EffectfulForcing.Internal.ExtensionalEquality where 13 | 14 | open import MLTT.Spartan hiding (rec ; _^_) renaming (⋆ to 〈〉) 15 | open import EffectfulForcing.MFPSAndVariations.SystemT 16 | using (type ; ι ; _⇒_ ; 〖_〗) 17 | 18 | \end{code} 19 | 20 | Extensional equality of System T terms. 21 | 22 | \begin{code} 23 | 24 | _≡_ : {A : type} → 〖 A 〗 → 〖 A 〗 → 𝓤₀ ̇ 25 | _≡_ {ι} n₁ n₂ = n₁ = n₂ 26 | _≡_ {σ ⇒ τ} f₁ f₂ = {x₁ x₂ : 〖 σ 〗} → x₁ ≡ x₂ → f₁ x₁ ≡ f₂ x₂ 27 | 28 | \end{code} 29 | 30 | The following explicit version is used to define a nice syntax for the 31 | extensional equality operation. 32 | 33 | \begin{code} 34 | 35 | ≡-syntax : (A : type) → 〖 A 〗 → 〖 A 〗 → 𝓤₀ ̇ 36 | ≡-syntax A f g = f ≡ g 37 | 38 | syntax ≡-syntax A f g = f ≡[ A ] g 39 | 40 | \end{code} 41 | -------------------------------------------------------------------------------- /source/EffectfulForcing/Internal/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, Bruno da Rocha Paiva, Ayberk Tosun, and Vincent Rahli, June 2023 2 | 3 | The main theorem is that for every system T closed term t : (ι → ι) → ι 4 | there is a system T term which Church-encodes a dialogue tree of the 5 | standard interpretation ⟦ t ⟧ of t (defined in the file System T). 6 | 7 | \begin{code} 8 | 9 | {-# OPTIONS --safe --without-K #-} 10 | 11 | module EffectfulForcing.Internal.index where 12 | 13 | import EffectfulForcing.Internal.SystemT 14 | import EffectfulForcing.Internal.Internal 15 | import EffectfulForcing.Internal.Subst 16 | import EffectfulForcing.Internal.External 17 | import EffectfulForcing.Internal.Correctness 18 | import EffectfulForcing.Internal.FurtherThoughts 19 | import EffectfulForcing.Internal.InternalModCont -- by Ayberk Tosun 20 | import EffectfulForcing.Internal.InternalModUniCont -- by Ayberk Tosun 21 | import EffectfulForcing.Internal.PaperIndex 22 | 23 | \end{code} 24 | 25 | 1. The file Internal gives Church-encoded dialogue trees of system T 26 | terms t : (ι → ι) → ι. 27 | 28 | 2. The file External gives a semantics in terms of inductive dialogue 29 | trees and formulates and proves the correctness of the produced 30 | dialogue trees. 31 | 32 | 3. The file Correctness proves the correctness of (1) using the 33 | composition of the logical relation defined in (2) with a second 34 | logical relation defined for that purpose. 35 | 36 | 4. The file FurtherThoughts contains some work in progress. 37 | 38 | 5. The file `InternalModCont` contains the proof of correctness of the internal 39 | modulus of continuity operator. 40 | 41 | 6. The file `InternalModUniCont` contains the proof of correctness of the 42 | internal modulus of _uniform_ continuity operator. 43 | -------------------------------------------------------------------------------- /source/EffectfulForcing/InternalWithoutOracle.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo & Vincent Rahli 20 May 2023 2 | 3 | This is an adaptation of Internal.lagda written by Martin, which defines dialogue-tree⋆ without using T' 4 | but directly using T. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module EffectfulForcing.InternalWithoutOracle where 11 | 12 | open import MLTT.Spartan hiding (rec ; _^_) renaming (⋆ to 〈〉) 13 | open import EffectfulForcing.SystemT 14 | open import EffectfulForcing.Internal hiding (B⋆⟦_⟧ ; dialogue-tree⋆) 15 | 16 | B⋆⟦_⟧ : {n : ℕ} {Γ : Cxt n} {σ : type} {A : Type} 17 | → T Γ σ 18 | → B⋆【 Γ 】 A 19 | → B⋆〖 σ 〗 A 20 | B⋆⟦ Zero ⟧ _ = zero⋆ 21 | B⋆⟦ Succ ⟧ _ = succ⋆ 22 | B⋆⟦ Rec {_} {_} {σ} ⟧ _ = rec⋆ {σ} 23 | B⋆⟦ ν i ⟧ xs = xs i 24 | B⋆⟦ ƛ t ⟧ xs = λ x → B⋆⟦ t ⟧ (xs ‚‚⋆ x) 25 | B⋆⟦ t · u ⟧ xs = (B⋆⟦ t ⟧ xs) (B⋆⟦ u ⟧ xs) 26 | 27 | B⋆⟦_⟧₀ : {σ : type} {A : Type} → T₀ σ → B⋆〖 σ 〗 A 28 | B⋆⟦ t ⟧₀ = B⋆⟦ t ⟧ ⟪⟫⋆ 29 | 30 | dialogue-tree⋆ : {A : Type} → T₀ ((ι ⇒ ι) ⇒ ι) → B⋆ ℕ A 31 | dialogue-tree⋆ t = B⋆⟦ t ⟧₀ generic⋆ 32 | 33 | \end{code} 34 | -------------------------------------------------------------------------------- /source/EffectfulForcing/MFPSAndVariations/Combinators.lagda: -------------------------------------------------------------------------------- 1 | sMartin Escardo 2012 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module EffectfulForcing.MFPSAndVariations.Combinators where 8 | 9 | open import MLTT.Spartan hiding (rec) 10 | 11 | Ķ : {X Y : 𝓤 ̇ } → X → Y → X 12 | Ķ x y = x 13 | 14 | Ş : {X Y Z : 𝓤 ̇ } → (X → Y → Z) → (X → Y) → X → Z 15 | Ş f g x = f x (g x) 16 | 17 | iter : {X : 𝓤 ̇ } → (X → X) → X → ℕ → X 18 | iter f x 0 = x 19 | iter f x (succ n) = f (iter f x n) 20 | 21 | rec : {X : 𝓤 ̇ } → (ℕ → X → X) → X → ℕ → X 22 | rec f x 0 = x 23 | rec f x (succ n) = f n (rec f x n) 24 | 25 | \end{code} 26 | -------------------------------------------------------------------------------- /source/EffectfulForcing/index.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module EffectfulForcing.index where 6 | 7 | import EffectfulForcing.MFPSAndVariations.index 8 | import EffectfulForcing.Internal.index 9 | 10 | \end{code} 11 | -------------------------------------------------------------------------------- /source/Factorial/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 2 | 3 | For a discussion of what is done here, see 4 | https://mathstodon.xyz/@MartinEscardo/109395006766077334 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module Factorial.index where 11 | 12 | import Factorial.Law 13 | import Factorial.PlusOneLC 14 | import Factorial.Swap 15 | 16 | \end{code} 17 | -------------------------------------------------------------------------------- /source/Field/DedekindReals.lagda: -------------------------------------------------------------------------------- 1 | Andrew Sneap, 7 February 2021 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K --lossy-unification #-} 6 | 7 | 8 | open import UF.PropTrunc 9 | open import UF.FunExt 10 | open import UF.Subsingletons 11 | 12 | 13 | module Field.DedekindReals 14 | (fe : Fun-Ext) 15 | (pt : propositional-truncations-exist) 16 | (pe : Prop-Ext) 17 | where 18 | 19 | 20 | {- 21 | DedekindRealsField : Field-structure ℝ { 𝓤₀} 22 | DedekindRealsField = ({!!} , {!!} , _♯_) , ℝ-is-set , {!!} , {!!} , {!!} , {!!} , {!!} , (0ℝ , 1ℝ) , ℝ-zero-apart-from-one , {!!} , {!!} , {!!} , {!!} 23 | 24 | DedekindRealsOrderedField : Ordered-field-structure { 𝓤₁} { 𝓤₀} { 𝓤₀} ℝ DedekindRealsField 25 | DedekindRealsOrderedField = _<ℝ_ , {!!} , {!!} 26 | 27 | DedekindRealsOrderedField' : Ordered-Field 𝓤₁ { 𝓤₀} { 𝓤₀} 28 | DedekindRealsOrderedField' = (ℝ , DedekindRealsField) , DedekindRealsOrderedField 29 | 30 | DedekindRealsArchimedeanOrderedField : ArchimedeanOrderedField 𝓤₁ 31 | DedekindRealsArchimedeanOrderedField = DedekindRealsOrderedField' , I 32 | where 33 | I : (f : ℚ → ℝ) → (x y : ℝ) → Σ z ꞉ ℚ , x < f z × f z < y 34 | I f x y = {!!} 35 | -} 36 | 37 | 38 | \end{code} 39 | -------------------------------------------------------------------------------- /source/Field/Rationals.lagda: -------------------------------------------------------------------------------- 1 | Andrew Sneap, 7 February 2021 2 | 3 | In this file I prove that the rationals are an ordered field. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | open import MLTT.Spartan renaming (_+_ to _∔_) 10 | 11 | open import Notation.Order 12 | open import Field.Axioms 13 | open import Rationals.Type 14 | open import Rationals.Addition 15 | open import Rationals.Multiplication 16 | open import Rationals.Negation 17 | open import Rationals.Order 18 | 19 | module Field.Rationals where 20 | 21 | _#_ : (x y : ℚ) → 𝓤₀ ̇ 22 | x # y = ¬ (x = y) 23 | 24 | 0ℚ#1ℚ : 0ℚ # 1ℚ 25 | 0ℚ#1ℚ = ℚ-zero-not-one 26 | 27 | RationalsField : Field-structure ℚ { 𝓤₀} 28 | RationalsField = (_+_ , _*_ , _#_) , ℚ-is-set 29 | , ℚ+-assoc 30 | , ℚ*-assoc 31 | , ℚ+-comm 32 | , ℚ*-comm 33 | , ℚ-distributivity 34 | , (0ℚ , 1ℚ) , 0ℚ#1ℚ 35 | , ℚ-zero-left-neutral 36 | , ℚ+-inverse 37 | , ℚ-mult-left-id 38 | , ℚ*-inverse 39 | 40 | RationalsOrderedField : Ordered-field-structure { 𝓤₀} { 𝓤₀} { 𝓤₀} ℚ RationalsField 41 | RationalsOrderedField = _<_ , ℚ<-addition-preserves-order , ℚ<-pos-multiplication-preserves-order 42 | 43 | RationalsOrderedField' : Ordered-Field 𝓤₀ { 𝓤₀} { 𝓤₀} 44 | RationalsOrderedField' = (ℚ , RationalsField) , RationalsOrderedField 45 | -------------------------------------------------------------------------------- /source/Field/index.lagda: -------------------------------------------------------------------------------- 1 | Andrew Sneap 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module Field.index where 8 | 9 | import Field.Axioms 10 | import Field.DedekindReals 11 | import Field.Rationals 12 | 13 | \end{code} 14 | -------------------------------------------------------------------------------- /source/Fin/Dedekind.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, 3rd September 2023. 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module Fin.Dedekind where 8 | 9 | open import MLTT.Spartan 10 | open import UF.Embeddings 11 | open import UF.Equiv 12 | 13 | is-Dedekind-finite : 𝓤 ̇ → 𝓤 ̇ 14 | is-Dedekind-finite X = (f : X → X) → is-embedding f → is-equiv f 15 | 16 | \end{code} 17 | 18 | Notice that we replace the conclusion is-equiv f by is-surjection f to 19 | get an equivalent definition, because if an embedding is a surjection 20 | iff it is an equivalence, but this requires assuming propositional 21 | truncations. 22 | 23 | Example. The type Ω 𝓤 of propositions is Dedekind finite. 24 | 25 | \begin{code} 26 | 27 | open import UF.FunExt 28 | open import UF.HiggsInvolutionTheorem 29 | open import UF.Subsingletons 30 | open import UF.SubtypeClassifier 31 | 32 | Ω-is-Dedekind-finite : Fun-Ext → Prop-Ext → is-Dedekind-finite (Ω 𝓤) 33 | Ω-is-Dedekind-finite fe pe = autoembeddings-of-Ω-are-equivs fe pe 34 | 35 | \end{code} 36 | 37 | Example. A weakly connected type (a type that is (1-)connected if it 38 | is inhabited), is Dedekind finite, so, for instance, the circle S¹ is 39 | Dedekind finite. 40 | 41 | \begin{code} 42 | 43 | open import CantorSchroederBernstein.CSB 44 | open import UF.PropTrunc 45 | 46 | module _ (pt : propositional-truncations-exist) where 47 | 48 | open import UF.Connected pt 49 | 50 | wconnected-types-are-Dedekind-finite : {X : 𝓤 ̇ } 51 | → is-wconnected X 52 | → is-Dedekind-finite X 53 | wconnected-types-are-Dedekind-finite = 54 | CSB-for-connected-types-without-EM.wconnected-types-are-Dedekind-finite pt 55 | 56 | \end{code} 57 | 58 | TODO. Relate this to the other notions of finiteness. 59 | -------------------------------------------------------------------------------- /source/Fin/Type.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, 2014. 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module Fin.Type where 8 | 9 | 10 | open import MLTT.Spartan 11 | open import MLTT.Plus-Properties 12 | 13 | Fin : ℕ → 𝓤₀ ̇ 14 | Fin 0 = 𝟘 15 | Fin (succ n) = Fin n + 𝟙 16 | 17 | \end{code} 18 | 19 | We have zero and successor for finite sets, with the following types: 20 | 21 | \begin{code} 22 | 23 | fzero : {n : ℕ} → Fin (succ n) 24 | fzero = inr ⋆ 25 | 26 | fsucc : {n : ℕ} → Fin n → Fin (succ n) 27 | fsucc = inl 28 | 29 | suc-lc : {n : ℕ} {j k : Fin n} → fsucc j = fsucc k → j = k 30 | suc-lc = inl-lc 31 | 32 | \end{code} 33 | 34 | But it will more convenient to have them as patterns, for the sake of 35 | clarity in definitions by pattern matching: 36 | 37 | \begin{code} 38 | 39 | pattern 𝟎 = inr ⋆ 40 | pattern suc i = inl i 41 | pattern 𝟏 = suc 𝟎 42 | pattern 𝟐 = suc 𝟏 43 | pattern 𝟑 = suc 𝟐 44 | pattern 𝟒 = suc 𝟑 45 | pattern 𝟓 = suc 𝟒 46 | pattern 𝟔 = suc 𝟓 47 | pattern 𝟕 = suc 𝟔 48 | pattern 𝟖 = suc 𝟕 49 | pattern 𝟗 = suc 𝟖 50 | 51 | \end{code} 52 | 53 | The induction principle for Fin is proved by induction on ℕ: 54 | 55 | \begin{code} 56 | 57 | Fin-induction : (P : (n : ℕ) → Fin n → 𝓤 ̇ ) 58 | → ((n : ℕ) → P (succ n) 𝟎) 59 | → ((n : ℕ) (i : Fin n) → P n i → P (succ n) (suc i)) 60 | → (n : ℕ) (i : Fin n) → P n i 61 | 62 | Fin-induction P β σ 0 i = 𝟘-elim i 63 | Fin-induction P β σ (succ n) 𝟎 = β n 64 | Fin-induction P β σ (succ n) (suc i) = σ n i (Fin-induction P β σ n i) 65 | 66 | \end{code} 67 | -------------------------------------------------------------------------------- /source/Fin/Variation.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, 2nd December 2019 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module Fin.Variation where 8 | 9 | 10 | open import Fin.Type 11 | open import MLTT.Spartan 12 | open import Naturals.Order 13 | open import Notation.Order 14 | open import UF.Equiv 15 | 16 | \end{code} 17 | 18 | An isomorphic copy of the type Fin n: 19 | 20 | \begin{code} 21 | 22 | Fin' : ℕ → 𝓤₀ ̇ 23 | Fin' n = Σ k ꞉ ℕ , k < n 24 | 25 | 𝟎' : {n : ℕ} → Fin' (succ n) 26 | 𝟎' {n} = 0 , zero-least n 27 | 28 | suc' : {n : ℕ} → Fin' n → Fin' (succ n) 29 | suc' (k , l) = succ k , l 30 | 31 | Fin-unprime : (n : ℕ) → Fin' n → Fin n 32 | Fin-unprime 0 (k , l) = 𝟘-elim l 33 | Fin-unprime (succ n) (0 , l) = 𝟎 34 | Fin-unprime (succ n) (succ k , l) = suc (Fin-unprime n (k , l)) 35 | 36 | Fin-prime : (n : ℕ) → Fin n → Fin' n 37 | Fin-prime 0 i = 𝟘-elim i 38 | Fin-prime (succ n) (suc i) = suc' (Fin-prime n i) 39 | Fin-prime (succ n) 𝟎 = 𝟎' 40 | 41 | ηFin : (n : ℕ) → Fin-prime n ∘ Fin-unprime n ∼ id 42 | ηFin 0 (k , l) = 𝟘-elim l 43 | ηFin (succ n) (0 , *) = refl 44 | ηFin (succ n) (succ k , l) = ap suc' (ηFin n (k , l)) 45 | 46 | 47 | εFin : (n : ℕ) → Fin-unprime n ∘ Fin-prime n ∼ id 48 | εFin 0 i = 𝟘-elim i 49 | εFin (succ n) (suc i) = ap suc (εFin n i) 50 | εFin (succ n) 𝟎 = refl 51 | 52 | Fin-prime-is-equiv : (n : ℕ) → is-equiv (Fin-prime n) 53 | Fin-prime-is-equiv n = qinvs-are-equivs (Fin-prime n) 54 | (Fin-unprime n , εFin n , ηFin n) 55 | 56 | 57 | ≃-Fin : (n : ℕ) → Fin n ≃ Fin' n 58 | ≃-Fin n = Fin-prime n , Fin-prime-is-equiv n 59 | 60 | \end{code} 61 | -------------------------------------------------------------------------------- /source/Fin/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module Fin.index where 8 | 9 | import Fin.ArgMinMax 10 | import Fin.ArithmeticViaEquivalence 11 | import Fin.Bishop 12 | import Fin.Choice 13 | import Fin.Dedekind 14 | import Fin.Embeddings 15 | import Fin.Kuratowski 16 | import Fin.Omega 17 | import Fin.Order 18 | import Fin.Pigeonhole 19 | import Fin.Properties 20 | import Fin.Topology 21 | import Fin.Type 22 | import Fin.UniverseInvariance 23 | import Fin.Variation 24 | 25 | \end{code} 26 | -------------------------------------------------------------------------------- /source/Games/Main.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo and Paulo Oliva, 19th March 2023. 2 | 3 | Compile with 4 | 5 | $ Agda --compile --ghc-flag=-O2 Main.lagda 6 | 7 | from TypeTopology/source/Games 8 | 9 | To run, change to TypeTopology/source and do 10 | 11 | $ ./Main 12 | 13 | The Haskell code is generated in TypeTopology/source/MAlonzo. 14 | 15 | \begin{code} 16 | 17 | {-# OPTIONS --without-K #-} 18 | 19 | module Games.Main where 20 | 21 | open import Unsafe.Haskell 22 | 23 | 24 | {- 25 | 26 | Fin-to-ℕ : {n : ℕ} → Fin' n → ℕ 27 | Fin-to-ℕ {succ n} (inl x) = Fin-to-ℕ x 28 | Fin-to-ℕ {succ n} (inr x) = 0 29 | 30 | main : IO ⊤ 31 | main = putStrLn (showℕ (Fin-to-ℕ r)) 32 | -} 33 | 34 | open import Games.alpha-beta 35 | 36 | main₀ : IO Unit 37 | main₀ = putStrLn (showListℕ test⋆) 38 | 39 | 40 | main₁ : IO Unit 41 | main₁ = putStrLn (showListℕ (test† fe)) 42 | where 43 | open import UF.FunExt 44 | postulate fe : Fun-Ext 45 | 46 | main₂ : IO Unit 47 | main₂ = putStrLn (showListℕ testo) 48 | 49 | main₃ : IO Unit 50 | main₃ = putStrLn (showℕ test) 51 | 52 | main = main₁ 53 | 54 | \end{code} 55 | -------------------------------------------------------------------------------- /source/Games/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo and Paulo Oliva, 2-27 July 2021, with more additions later. 2 | 3 | Refactored and slightly improved October 2022, and then again in April 4 | 2023 with many additions. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module Games.index where 11 | 12 | import Games.Constructor -- For simplifying the construction of games. 13 | import Games.Examples -- Miscelaneous small examples. 14 | import Games.FiniteHistoryDependent -- Theory of finite history dependent games. 15 | import Games.FiniteHistoryDependentMonadic 16 | -- With additional monad for irrational players. 17 | import Games.TicTacToe0 18 | import Games.TicTacToe1 -- Like TicTacToe0 but using Games.Constructor. 19 | import Games.TicTacToe2 -- More efficient and less elegant version. 20 | import Games.TypeTrees -- Dependent type trees. 21 | import Games.alpha-beta -- Many new things for efficiency. 22 | import Games.Discussion 23 | import Games.OptimalPlays -- Computes the list of all optimal plays of a game. 24 | 25 | -- import Games.Main -- To be able to compile for efficieny. 26 | -- Can't be imported here as it's not --safe. 27 | -- This is for Agda compilation to Haskell of 28 | -- examples to be able to run them more efficiently. 29 | 30 | \end{code} 31 | -------------------------------------------------------------------------------- /source/GamesMGU/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo and Paulo Oliva, 2-27 July 2021, 2 | 3 | Same as Games but with more general universes (MGU), and also using the flag --no-level-universe. 4 | 5 | The main novelty here, for now, is FiniteHistoryDependentRelativeMonadic, which works with relative 6 | monads on structured types, so that e.g. we can work with the affine 7 | monad of non-empty lists without repetitions for some applications. 8 | 9 | \begin{code} 10 | 11 | {-# OPTIONS --safe --without-K --no-level-universe #-} 12 | 13 | module GamesMGU.index where 14 | 15 | import GamesMGU.Constructor -- For simplifying the construction of games. 16 | import GamesMGU.Examples -- Miscelaneous small examples. 17 | import GamesMGU.FiniteHistoryDependent -- Theory of finite history dependent games. 18 | import GamesMGU.FiniteHistoryDependentMonadic 19 | -- With additional monad for irrational players. 20 | import GamesMGU.FiniteHistoryDependentRelativeMonadic 21 | -- Same but with relative monad. 22 | import GamesMGU.TicTacToe0 23 | import GamesMGU.TicTacToe1 -- Like TicTacToe0 but using GamesMGU.Constructor. 24 | import GamesMGU.TicTacToe2 -- More efficient and less elegant version. 25 | import GamesMGU.TypeTrees -- Dependent type trees. 26 | import GamesMGU.alpha-beta -- Many new things for efficiency. 27 | import GamesMGU.alpha-beta-examples 28 | import GamesMGU.Discussion 29 | 30 | \end{code} 31 | -------------------------------------------------------------------------------- /source/Groups/Opposite.lagda: -------------------------------------------------------------------------------- 1 | Ettore Aldrovandi ealdrovandi@fsu.edu 2 | Keri D'Angelo kd349@cornell.edu 3 | 4 | July 17, 2021 5 | -------------------------------------------------------------------------------- 6 | 7 | Opposite of a Group. Given a group G, its opposite G ᵒᵖ has the same 8 | underlying type, but the "opposite" group structure: 9 | 10 | g ·⟨ G ᵒᵖ ⟩ h = h ·⟨ G ⟩ g 11 | 12 | \begin{code} 13 | 14 | {-# OPTIONS --safe --without-K #-} 15 | 16 | 17 | open import MLTT.Spartan 18 | open import Groups.Type renaming (_≅_ to _≣_) 19 | 20 | 21 | module Groups.Opposite where 22 | 23 | _ᵒᵖ : Group 𝓤 → Group 𝓤 24 | G ᵒᵖ = ⟨ G ⟩ , ( 25 | (λ g h → h ·⟨ G ⟩ g) , 26 | (groups-are-sets G) , 27 | ((λ x y z → (assoc G z y x) ⁻¹) , 28 | (unit G) , 29 | ((λ x → unit-right G x) , ((λ x → unit-left G x) , 30 | (λ x → (inv G x) , (inv-right G x) , (inv-left G x)))))) 31 | 32 | infixr 30 _ᵒᵖ 33 | 34 | \end{code} 35 | 36 | Forming the opposite gives a functor 37 | 38 | \begin{code} 39 | 40 | op-functoriality : (G H : Group 𝓤) 41 | → (f : ⟨ G ⟩ → ⟨ H ⟩) (i : is-hom G H f) 42 | → is-hom (G ᵒᵖ) (H ᵒᵖ) f 43 | op-functoriality G H f i {x} {y} = i {y} {x} 44 | 45 | \end{code} 46 | 47 | Forming the opposite is idempotent. 48 | 49 | \begin{code} 50 | 51 | opposite-idempotent : (G : Group 𝓤) → G ≣ (G ᵒᵖ) ᵒᵖ 52 | opposite-idempotent G = id , ((pr₂ (≃-refl ⟨ G ⟩)) , refl) 53 | where 54 | open import UF.Equiv 55 | 56 | \end{code} 57 | 58 | The underlying identity map ⟨ G ⟩ → ⟨ G ᵒᵖ ⟩ is NOT a homomorphism, 59 | unless G is abelian. In fact this is equivalent to G being abelian. 60 | 61 | \begin{code} 62 | 63 | underlying-id-is-hom : (G : Group 𝓤) (ab : is-abelian G) 64 | → is-hom G (G ᵒᵖ) id 65 | underlying-id-is-hom G ab {x} {y} = ab x y 66 | 67 | op-hom-gives-abelian : (G : Group 𝓤) 68 | → (i : is-hom G (G ᵒᵖ) id) 69 | → is-abelian G 70 | op-hom-gives-abelian G i = λ x y → i {x} {y} 71 | 72 | \end{code} 73 | -------------------------------------------------------------------------------- /source/Groups/Symmetric.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, 3rd November 2023. 2 | 3 | The symmetric group on a set X, namely the group of automorphisms on X 4 | under composition with the identity automorphism as the unit. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | open import UF.FunExt 11 | 12 | module Groups.Symmetric (fe : Fun-Ext) where 13 | 14 | open import Groups.Type 15 | open import MLTT.Spartan 16 | open import UF.Sets 17 | open import UF.Equiv 18 | open import UF.Equiv-FunExt 19 | 20 | private 21 | fe' : FunExt 22 | fe' 𝓤 𝓥 = fe {𝓤} {𝓥} 23 | 24 | symmetric-group : (X : 𝓤 ̇ ) → is-set X → Group 𝓤 25 | symmetric-group X X-is-set = 26 | Aut X , 27 | _●_ , 28 | ≃-is-set fe X-is-set , 29 | (λ 𝕗 𝕘 𝕙 → (≃-assoc fe' 𝕗 𝕘 𝕙)⁻¹) , 30 | 𝕚𝕕 , 31 | ≃-refl-left fe' , 32 | ≃-refl-right fe' , 33 | (λ 𝕗 → ≃-sym 𝕗 , ≃-sym-left-inverse fe' 𝕗 , ≃-sym-right-inverse fe' 𝕗) 34 | 35 | \end{code} 36 | -------------------------------------------------------------------------------- /source/Groups/index.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module Groups.index where 6 | 7 | import Groups.Type -- by [1] 8 | import Groups.Subgroups -- by [1], copied to this place by [3] 9 | import Groups.Free -- by [2] 10 | import Groups.Large -- by [2] 11 | import Groups.Type-Supplement -- by [3] 12 | import Groups.Aut -- by [3] 13 | import Groups.Cokernel -- by [3] 14 | import Groups.GroupActions -- by [3] 15 | import Groups.Homomorphisms -- by [3] 16 | import Groups.Image -- by [3] 17 | import Groups.Kernel -- by [3] 18 | import Groups.Opposite -- by [3] 19 | import Groups.Quotient -- by [3] 20 | import Groups.Symmetric -- by [1] 21 | import Groups.Torsors -- by [3] 22 | import Groups.Triv -- by [3] 23 | 24 | \end{code} 25 | 26 | [1] Martin Escardo 27 | [2] Bezem, Coquand, Dybjer and Escardo 28 | [3] Ettore Aldrovandi and Keri D'Angelo 29 | -------------------------------------------------------------------------------- /source/InfinitePigeon/Cantor.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module InfinitePigeon.Cantor where 6 | 7 | open import InfinitePigeon.Naturals 8 | open import InfinitePigeon.Two 9 | 10 | ₂ℕ : Set 11 | ₂ℕ = ℕ → ₂ 12 | -------------------------------------------------------------------------------- /source/InfinitePigeon/Choice.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module InfinitePigeon.Choice where 6 | 7 | open import InfinitePigeon.Equality 8 | open import InfinitePigeon.Logic 9 | open import InfinitePigeon.Naturals 10 | 11 | 12 | AC : {X : Set} {Y : X → Set} {A : (x : X) → Y x → Ω} → 13 | -- 14 | (∀(x : X) → ∃ \(y : Y x) → A x y) 15 | → ∃ \(f : ((x : X) → Y x)) → ∀(x : X) → A x (f x) 16 | 17 | AC g = ∃-intro (λ x → ∃-witness (g x)) (λ x → ∃-elim (g x)) 18 | 19 | 20 | DC : {X : Set} {P : ℕ → X → X → Ω} → 21 | -- 22 | ∀(x₀ : X) → (∀(n : ℕ) → ∀(x : X) → ∃ \(y : X) → P n x y) 23 | → ∃ \(α : ℕ → X) → α O ≡ x₀ ∧ (∀(n : ℕ) → P n (α n) (α(succ n))) 24 | 25 | DC {X} x₀ g = ∃-intro α (∧-intro reflexivity (λ n → ∃-elim(g n (α n)))) 26 | where α : ℕ → X 27 | α = induction x₀ (λ k x → ∃-witness(g k x)) 28 | 29 | -- Dependently typed, dependent choice: 30 | 31 | DDC : {X : ℕ → Set} {P : (n : ℕ) → X n → X(succ n) → Ω} → 32 | --- 33 | ∀(x₀ : X O) → (∀(n : ℕ) → ∀(x : X n) → ∃ \(y : X(succ n)) → P n x y) 34 | → ∃ \(α : (n : ℕ) → X n) → α O ≡ x₀ ∧ (∀(n : ℕ) → P n (α n) (α(succ n))) 35 | 36 | DDC {X} x₀ g = ∃-intro α (∧-intro reflexivity (λ n → ∃-elim(g n (α n)))) 37 | where α : (n : ℕ) → X n 38 | α = induction x₀ (λ k x → ∃-witness(g k x)) 39 | -------------------------------------------------------------------------------- /source/InfinitePigeon/DataStructures.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module InfinitePigeon.DataStructures where 6 | 7 | -- Some definitions of standard things 8 | -- (sorry for not using libraries). 9 | 10 | open import InfinitePigeon.Addition 11 | open import InfinitePigeon.Finite 12 | open import InfinitePigeon.LogicalFacts 13 | open import InfinitePigeon.Naturals 14 | 15 | 16 | data List (X : Set) : Set where 17 | [] : List X 18 | _::_ : X → List X → List X 19 | 20 | infixr 30 _::_ 21 | 22 | 23 | -- Transforms a finite list given as a map to an enumerated finite 24 | -- list: 25 | 26 | list : {m : ℕ} {X : Set} → (smaller m → X) → List X 27 | list {0} s = [] 28 | list {succ m} s = s fzero :: list {m} (s ∘ fsucc) 29 | 30 | 31 | -- Binary products: 32 | 33 | data _×_ (X Y : Set) : Set where 34 | _,_ : X → Y → X × Y 35 | 36 | 37 | infixr 20 _,_ 38 | 39 | 40 | -- The cons operation for the Cantor space: 41 | 42 | open import InfinitePigeon.Cantor 43 | open import InfinitePigeon.Two 44 | 45 | _^_ : ℕ → ₂ℕ → ₂ℕ 46 | (O ^ α) O = ₀ 47 | (O ^ α) (succ i) = α i 48 | (succ n ^ α) O = ₁ 49 | (succ n ^ α) (succ i) = α i 50 | 51 | infixr 30 _^_ 52 | 53 | 54 | -- Take a finite initial sublist of an infinite sequence. 55 | 56 | take : (m : ℕ) {X : Set} → (ℕ → X) → List X 57 | take 0 α = [] 58 | take (succ m) α = α 0 :: take m (α ∘ succ) 59 | 60 | -- Index a finite sequence: 61 | 62 | _!_ : {m : ℕ} → (smaller(m + 1) → ℕ) → ℕ → ℕ 63 | _!_ {m} s n = s(fmin m n) 64 | -------------------------------------------------------------------------------- /source/InfinitePigeon/Equality.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module InfinitePigeon.Equality where 6 | 7 | open import InfinitePigeon.Logic 8 | 9 | data _≡_ {X : Set} : X → X → Ω where 10 | reflexivity : {x : X} → x ≡ x 11 | 12 | infix 29 _≡_ 13 | 14 | two-things-equal-to-a-third-are-equal : {X : Set} → 15 | ∀{x y z : X} → x ≡ y → x ≡ z → y ≡ z 16 | 17 | two-things-equal-to-a-third-are-equal reflexivity reflexivity = reflexivity 18 | 19 | 20 | transitivity : {X : Set} → {x y z : X} → x ≡ y → y ≡ z → x ≡ z 21 | transitivity reflexivity reflexivity = reflexivity 22 | 23 | 24 | symmetry : {X : Set} → {x y : X} → x ≡ y → y ≡ x 25 | symmetry reflexivity = reflexivity 26 | 27 | 28 | compositionality : {X Y : Set} → ∀(f : X → Y) → {x₀ x₁ : X} → 29 | 30 | x₀ ≡ x₁ → f x₀ ≡ f x₁ 31 | 32 | compositionality f reflexivity = reflexivity 33 | 34 | 35 | predicate-compositionality : {X : Set} (A : X → Ω) {x y : X} → 36 | 37 | x ≡ y → A x → A y 38 | 39 | predicate-compositionality A reflexivity a = a 40 | 41 | 42 | binary-predicate-compositionality : 43 | 44 | {X Y : Set} {A : X → Y → Ω} {x x' : X} {y y' : Y} → 45 | 46 | x ≡ x' → y ≡ y' → A x y → A x' y' 47 | 48 | binary-predicate-compositionality reflexivity reflexivity a = a 49 | 50 | 51 | set-compositionality : {I : Set} (X : I → Set) → {i j : I} → i ≡ j → X i → X j 52 | set-compositionality X reflexivity x = x 53 | -------------------------------------------------------------------------------- /source/InfinitePigeon/J-AC-N.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.J-AC-N where 6 | 7 | open import InfinitePigeon.Addition 8 | open import InfinitePigeon.Choice 9 | open import InfinitePigeon.Equality 10 | open import InfinitePigeon.J-Shift 11 | open import InfinitePigeon.JK-LogicalFacts 12 | open import InfinitePigeon.JK-Monads 13 | open import InfinitePigeon.Logic 14 | open import InfinitePigeon.LogicalFacts 15 | open import InfinitePigeon.Naturals 16 | 17 | ------------------------------------------------------------------------ 18 | -- Proof of the J translation of the axiom of countable choice -- 19 | -- from the proof of the axiom of choice using J-∀-shift as a lemma. -- 20 | ------------------------------------------------------------------------ 21 | 22 | J-AC-ℕ : {R : Ω} {X : ℕ → Set} {P : (n : ℕ) → X n → Ω} → 23 | ------- 24 | (∀(n : ℕ) → J∃ \(x : X n) → P n x) 25 | → J∃ \(f : ((n : ℕ) → X n)) → ∀(n : ℕ) → P n (f n) 26 | 27 | J-AC-ℕ {R} = (J-functor {R} AC) ∘ J-∀-shift 28 | 29 | 30 | ---------------------------------------------- 31 | -- -- 32 | -- Now the translations of dependent choice -- 33 | -- -- 34 | ---------------------------------------------- 35 | 36 | 37 | J-∀-double-shift : {R : Ω} {P : ℕ → ℕ → ℕ → Ω} → 38 | --------------- 39 | (∀(n : ℕ) → ∀(x : ℕ) → J∃ \(y : ℕ) → P n x y) → 40 | J(∀(n : ℕ) → ∀(x : ℕ) → ∃ \(y : ℕ) → P n x y) 41 | 42 | J-∀-double-shift {R} f = J-∀-shift {R} (λ n → J-∀-shift (f n)) 43 | 44 | 45 | J-DC-ℕ : {R : Ω} {P : ℕ → ℕ → ℕ → Ω} → 46 | ------- 47 | ∀(x₀ : ℕ) → 48 | (∀(n : ℕ) → ∀(x : ℕ) → J∃ \(y : ℕ) → P n x y) → 49 | J∃ \(α : ℕ → ℕ) → α O ≡ x₀ ∧ (∀(n : ℕ) → P n (α n) (α(n + 1))) 50 | 51 | J-DC-ℕ {R} x₀ f = (J-functor {R} (DC x₀)) (J-∀-double-shift f) 52 | -------------------------------------------------------------------------------- /source/InfinitePigeon/J-DC.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.J-DC where 6 | 7 | open import InfinitePigeon.Addition 8 | open import InfinitePigeon.Choice 9 | open import InfinitePigeon.Equality 10 | open import InfinitePigeon.J-Shift 11 | open import InfinitePigeon.JK-LogicalFacts 12 | open import InfinitePigeon.JK-Monads 13 | open import InfinitePigeon.Logic 14 | open import InfinitePigeon.LogicalFacts 15 | open import InfinitePigeon.Naturals 16 | 17 | ----------------------------------------------------------- 18 | -- -- 19 | -- Translation of dependent choice for a particular case -- 20 | -- -- 21 | ----------------------------------------------------------- 22 | 23 | J-∀-double-shift : {R : Ω} {P : ℕ → ℕ → ℕ → Ω} → 24 | --------------- 25 | (∀(n : ℕ) → ∀(x : ℕ) → J∃ \(y : ℕ) → P n x y) → 26 | J(∀(n : ℕ) → ∀(x : ℕ) → ∃ \(y : ℕ) → P n x y) 27 | 28 | J-∀-double-shift {R} f = J-∀-shift {R} (λ n → J-∀-shift (f n)) 29 | 30 | 31 | J-DC-ℕ : {R : Ω} {P : ℕ → ℕ → ℕ → Ω} → 32 | ------- 33 | ∀(x₀ : ℕ) → 34 | (∀(n : ℕ) → ∀(x : ℕ) → J∃ \(y : ℕ) → P n x y) → 35 | J∃ \(α : ℕ → ℕ) → α O ≡ x₀ ∧ (∀(n : ℕ) → P n (α n) (α(n + 1))) 36 | 37 | J-DC-ℕ {R} x₀ f = (J-functor {R} (DC x₀)) (J-∀-double-shift f) 38 | -------------------------------------------------------------------------------- /source/InfinitePigeon/J-Examples.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.J-Examples where 6 | 7 | -- To perform experiments, evaluate "example1" or "example2" to normal 8 | -- form. It is easy to create your own examples. 9 | 10 | -- Also, if you wish, choose another implementation of the K-shift in 11 | -- the wrapper module K-Shift following the instructions, and which 12 | -- proof of the infinite pigeonhole theorem is used in the module 13 | -- FinitePigeon, by importing a different module. 14 | 15 | open import InfinitePigeon.J-PigeonProgram 16 | open import InfinitePigeon.Naturals 17 | open import InfinitePigeon.Two 18 | open import InfinitePigeon.Cantor 19 | open import InfinitePigeon.DataStructures 20 | 21 | -- Some randomly chosen examples of elements of the Cantor space to 22 | -- play with: 23 | 24 | α¹ : ₂ℕ 25 | α¹ 0 = ₁ 26 | α¹(succ n) = not(α¹ n) 27 | 28 | α² : ₂ℕ 29 | α² = 0 ^ 0 ^ 0 ^ 1 ^ 1 ^ 1 ^ 1 ^ 1 ^ α¹ 30 | 31 | α³ : ₂ℕ 32 | α³ i = not(α² i) 33 | 34 | α⁴ : ₂ℕ 35 | α⁴ = 0 ^ 1 ^ 0 ^ 1 ^ 1 ^ 0 ^ 1 ^ 1 ^ 1 ^ α³ 36 | 37 | α⁵ : ₂ℕ 38 | α⁵ = 0 ^ 0 ^ 0 ^ 0 ^ 0 ^ 0 ^ 0 ^ 1 ^ α⁴ 39 | 40 | α⁶ : ₂ℕ 41 | α⁶ = 0 ^ 1 ^ 1 ^ 0 ^ 0 ^ 0 ^ 1 ^ 0 ^ 1 ^ 0 ^ 0 ^ 0 ^ 0 ^ α⁵ 42 | 43 | 44 | -- To run an experiment, normalize the term "pigeon-program α m" for 45 | -- suitable α and m: 46 | 47 | example1 : ₂ × List ℕ 48 | example1 = pigeon-program α⁵ 6 49 | 50 | example2 : ₂ × List ℕ 51 | example2 = pigeon-program α⁵ 12 52 | 53 | 54 | -- Alternatively, calculate b and s using the Theorem: 55 | 56 | {-- 57 | open import InfinitePigeon.FinitePigeon 58 | 59 | b : ₂ 60 | b = ∃-witness(Theorem α m) 61 | 62 | s : smaller(m + 1) → ℕ 63 | s = ∃-witness(∃-elim(Theorem α m)) 64 | --} 65 | 66 | -- Warning: depending on the example you build, and on the chosen 67 | -- proof term for the K-shift, this module will take a long time to 68 | -- compile (and then to run) when this alternative code is 69 | -- enabled. The term "pigeon-program" defined in the module 70 | -- PigeonProgram avoids the long compilation time. 71 | -------------------------------------------------------------------------------- /source/InfinitePigeon/J-PigeonProgram.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.J-PigeonProgram where 6 | 7 | open import InfinitePigeon.Cantor 8 | open import InfinitePigeon.DataStructures 9 | open import InfinitePigeon.J-FinitePigeon 10 | open import InfinitePigeon.Logic 11 | open import InfinitePigeon.Naturals 12 | open import InfinitePigeon.Two 13 | 14 | -- Given an infinite boolean sequence α and a natural number m, find a 15 | -- boolean b and a finite list of length n with the indices of a 16 | -- finite constant subsequence of α with value b at all 17 | -- positions. 18 | -- 19 | -- This is usually how such programs are specified in functional 20 | -- programming (if they are at all). Here Theorem (defined in the 21 | -- module FinitePigeon) is the program with the formal specification, 22 | -- also formally checked. Once this is done we can erase the 23 | -- specification. 24 | 25 | pigeon-program : ₂ℕ → ℕ → ₂ × List ℕ 26 | pigeon-program α m = f(Theorem α m) 27 | where f : Finite-Pigeonhole α m → ₂ × List ℕ 28 | f(∃-intro b (∃-intro s proof)) = (b , list s) 29 | -------------------------------------------------------------------------------- /source/InfinitePigeon/J-Shift-BBC.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --no-termination-check --without-K #-} 4 | 5 | -- We use the Berardi-Bezem-Coquand functional to realize the J-Shift 6 | -- (and hence the K-Shift in another module). 7 | 8 | module InfinitePigeon.J-Shift-BBC where 9 | 10 | open import InfinitePigeon.JK-Monads 11 | open import InfinitePigeon.Logic 12 | open import InfinitePigeon.LogicalFacts 13 | open import InfinitePigeon.Naturals 14 | 15 | 16 | J-∀-shift-bbc : {R : Ω} {A : ℕ → Ω} → 17 | ------------- 18 | 19 | (∀(n : ℕ) → J(A n)) → J(∀(n : ℕ) → A n) 20 | 21 | J-∀-shift-bbc {R} {A} ε = bbc 22 | where 23 | bbc : J {R} (∀(n : ℕ) → A n) 24 | bbc p i = ε i (λ x → J-K bbc (p ∘ mapsto {A} i x)) 25 | -------------------------------------------------------------------------------- /source/InfinitePigeon/J-Shift-Selection.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K --no-termination-check #-} 4 | 5 | -- Termination is proved externally, using bar induction and 6 | -- continuity in the case of this module (Escardo-Oliva 2010). 7 | 8 | module InfinitePigeon.J-Shift-Selection where 9 | 10 | open import InfinitePigeon.Finite-JK-Shifts 11 | open import InfinitePigeon.JK-Monads 12 | open import InfinitePigeon.Logic 13 | open import InfinitePigeon.LogicalFacts 14 | open import InfinitePigeon.Naturals 15 | 16 | -- Definition given by Escardo and Oliva MSCS2010 17 | -- (infinite iteration of the J-∧-shift'): 18 | 19 | 20 | J-∀-shift-selection : {R : Ω} {A : ℕ → Ω} → 21 | ------------------- 22 | 23 | (∀(n : ℕ) → J {R} (A n)) → J {R} (∀(n : ℕ) → A n) 24 | 25 | J-∀-shift-selection εs = 26 | J-∧-shift'(∧-intro (head εs) (J-∀-shift-selection(tail εs))) 27 | 28 | 29 | 30 | -- That's it. What follows is for information only. 31 | 32 | 33 | 34 | -- This is one of definitions given in both LICS2007 and LMCS2008 35 | -- (Section 8.1, called Π): 36 | 37 | 38 | prod : {R : Ω} {A : ℕ → Ω} → 39 | ---- 40 | (∀ (n : ℕ) → J {R} (A n)) → J {R} (∀ (n : ℕ) → A n) 41 | 42 | prod {R} {A} εs p = cons (∧-intro a₀ ((prod {R} (tail εs)) (prefix a₀ p))) 43 | where a₀ : A O 44 | a₀ = head εs (λ a → prefix a p ((prod {R} (tail εs))(prefix a p))) 45 | 46 | 47 | -- It is equivalent after we expand the definitions (both satisfy the 48 | -- same recursive equation in normal form). 49 | -------------------------------------------------------------------------------- /source/InfinitePigeon/J-Shift.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.J-Shift where 6 | 7 | -- Import Pigeon.one of J-Shift-BBC or J-Shift-Selection. 8 | 9 | open import InfinitePigeon.J-Shift-Selection -- Choose here... 10 | open import InfinitePigeon.JK-Monads 11 | open import InfinitePigeon.Logic 12 | open import InfinitePigeon.Naturals 13 | 14 | -- Use one of K-∀-shift-bbc or K-∀-shift-mbr or K-∀-shift-selection: 15 | 16 | J-∀-shift : {R : Ω} {A : ℕ → Ω} → 17 | --------- 18 | 19 | (∀(n : ℕ) → J(A n)) → J {R} (∀(n : ℕ) → A n) 20 | 21 | J-∀-shift = J-∀-shift-selection -- ... and here accordingly. 22 | -------------------------------------------------------------------------------- /source/InfinitePigeon/K-AC-N.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.K-AC-N where 6 | 7 | open import InfinitePigeon.Choice 8 | open import InfinitePigeon.JK-LogicalFacts 9 | open import InfinitePigeon.JK-Monads 10 | open import InfinitePigeon.K-Shift 11 | open import InfinitePigeon.Logic 12 | open import InfinitePigeon.LogicalFacts 13 | open import InfinitePigeon.Naturals 14 | 15 | ----------------------------------------------------------------------- 16 | -- The K-translation of countable choice AC-N can be proved only for -- 17 | -- certain formulas, including those that are in the image of the -- 18 | -- K-translation. -- 19 | -- -- 20 | -- Hence we have a restriction efq (ex falso quadlibet). -- 21 | -- -- 22 | -- This is because there is no general K-∀-shift. -- 23 | ----------------------------------------------------------------------- 24 | 25 | 26 | K-AC-ℕ : {R : Ω} {X : ℕ → Set} {P : (n : ℕ) → X n → Ω} → 27 | ------- 28 | (∀(n : ℕ) → R → ∃ \(m : X n) → P n m) -- efqs, 29 | → (∀(n : ℕ) → K∃ \(m : X n) → P n m) -- premise, 30 | → K∃ \(f : ((n : ℕ) → X n)) → ∀(n : ℕ) → P n (f n) -- conclusion. 31 | 32 | K-AC-ℕ efqs = (K-functor AC) ∘ (K-∀-shift efqs) 33 | -------------------------------------------------------------------------------- /source/InfinitePigeon/K-DC.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.K-DC where 6 | 7 | open import InfinitePigeon.Addition 8 | open import InfinitePigeon.Choice 9 | open import InfinitePigeon.Equality 10 | open import InfinitePigeon.JK-LogicalFacts 11 | open import InfinitePigeon.JK-Monads 12 | open import InfinitePigeon.K-Shift 13 | open import InfinitePigeon.Logic 14 | open import InfinitePigeon.Naturals 15 | 16 | ------------------------------------------------------------- 17 | -- -- 18 | -- The K-translation of dependent choice of ground type. -- 19 | -- -- 20 | ------------------------------------------------------------- 21 | 22 | K-∀-double-shift : {R : Ω} {P : ℕ → ℕ → ℕ → Ω} → 23 | --------------- 24 | (∀(n : ℕ) → ∀(x : ℕ) → R → ∃ \(y : ℕ) → P n x y) → -- efqs 25 | (∀(n : ℕ) → ∀(x : ℕ) → K∃ \(y : ℕ) → P n x y) → -- premise 26 | K(∀(n : ℕ) → ∀(x : ℕ) → ∃ \(y : ℕ) → P n x y) -- conclusion 27 | 28 | K-∀-double-shift {R} {P} efqs f 29 | = K-∀-shift {R} efqs' (λ n → K-∀-shift (efqs n) (f n)) 30 | where 31 | efqs' : (∀(n : ℕ) → R → ∀(x : ℕ) → ∃ \(y : ℕ) → P n x y) 32 | efqs' n r x = efqs n x r 33 | 34 | 35 | K-DC-ℕ : {R : Ω} {P : ℕ → ℕ → ℕ → Ω} → 36 | ------- 37 | (∀(n : ℕ) → ∀(x : ℕ) → R → ∃ \(y : ℕ) → P n x y) 38 | → ∀(x₀ : ℕ) 39 | → (∀(n : ℕ) → ∀(x : ℕ) → K∃ \(y : ℕ) → P n x y) 40 | → K∃ \(α : ℕ → ℕ) → α O ≡ x₀ ∧ (∀(n : ℕ) → P n (α n) (α(n + 1))) 41 | 42 | K-DC-ℕ efqs x₀ f = (K-functor (DC x₀)) (K-∀-double-shift efqs f) 43 | -------------------------------------------------------------------------------- /source/InfinitePigeon/K-Shift-BBC.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.K-Shift-BBC where 6 | 7 | open import InfinitePigeon.J-Shift-BBC 8 | open import InfinitePigeon.JK-Monads 9 | open import InfinitePigeon.Logic 10 | open import InfinitePigeon.Naturals 11 | 12 | 13 | K-∀-shift-bbc : {R : Ω} {A : ℕ → Ω} → 14 | ------------- 15 | 16 | (∀(n : ℕ) → R → A n) → -- efqs, 17 | (∀(n : ℕ) → K(A n)) → K(∀(n : ℕ) → A n) -- shift. 18 | 19 | K-∀-shift-bbc efqs φs = J-K(J-∀-shift-bbc(λ n → K-J(efqs n) (φs n))) 20 | -------------------------------------------------------------------------------- /source/InfinitePigeon/K-Shift-MBR.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K --no-termination-check #-} 4 | 5 | -- We use Berger's modified bar recursion functional to realize the 6 | -- K-Shift. 7 | 8 | module InfinitePigeon.K-Shift-MBR where 9 | 10 | open import InfinitePigeon.Finite 11 | open import InfinitePigeon.JK-Monads 12 | open import InfinitePigeon.Logic 13 | open import InfinitePigeon.LogicalFacts 14 | open import InfinitePigeon.Naturals 15 | 16 | K-∀-shift-mbr : {R : Ω} {A : ℕ → Ω} → 17 | ------------- 18 | (∀(n : ℕ) → R → A n) → -- efqs, 19 | (∀(n : ℕ) → K(A n)) → K(∀(n : ℕ) → A n) -- shift. 20 | 21 | K-∀-shift-mbr {R} {A} efqs φs p = mbr {0} (λ ()) 22 | where 23 | mbr : {m : ℕ} → (∀(i : smaller m) → A(embed i)) → R 24 | mbr {m} s = p(override s (λ n → efqs n (φs m (λ x → mbr(append {A} s x))))) 25 | -------------------------------------------------------------------------------- /source/InfinitePigeon/K-Shift-Selection.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.K-Shift-Selection where 6 | 7 | open import InfinitePigeon.J-Shift-Selection 8 | open import InfinitePigeon.JK-Monads 9 | open import InfinitePigeon.Logic 10 | open import InfinitePigeon.Naturals 11 | 12 | 13 | K-∀-shift-selection : {R : Ω} {A : ℕ → Ω} → 14 | ------------------- 15 | 16 | (∀(n : ℕ) → R → A n) → -- efqs, 17 | (∀(n : ℕ) → K(A n)) → K(∀(n : ℕ) → A n) -- shift. 18 | 19 | K-∀-shift-selection efqs φs = J-K(J-∀-shift-selection(λ n → K-J(efqs n) (φs n))) 20 | -------------------------------------------------------------------------------- /source/InfinitePigeon/K-Shift-from-J-Shift.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.K-Shift-from-J-Shift where 6 | 7 | open import InfinitePigeon.J-Shift 8 | open import InfinitePigeon.JK-Monads 9 | open import InfinitePigeon.Logic 10 | open import InfinitePigeon.LogicalFacts 11 | open import InfinitePigeon.Naturals 12 | 13 | K-∀-shift : {R : Ω} {A : ℕ → Ω} → 14 | --------- 15 | (∀(n : ℕ) → R → A n) → -- efqs, 16 | (∀(n : ℕ) → K(A n)) → K(∀(n : ℕ) → A n) -- shift. 17 | 18 | K-∀-shift efqs φs = J-K(J-∀-shift(λ n → K-J(efqs n) (φs n))) 19 | -------------------------------------------------------------------------------- /source/InfinitePigeon/K-Shift.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.K-Shift where 6 | 7 | -- This is a wrapper module. Perform a choice below. 8 | 9 | open import InfinitePigeon.JK-Monads 10 | open import InfinitePigeon.K-Shift-BBC 11 | open import InfinitePigeon.K-Shift-MBR 12 | open import InfinitePigeon.K-Shift-Selection 13 | open import InfinitePigeon.Logic 14 | open import InfinitePigeon.Naturals 15 | 16 | 17 | K-∀-shift : {R : Ω} {A : ℕ → Ω} → 18 | --------- 19 | 20 | (∀(n : ℕ) → R → A n) → -- efqs, 21 | (∀(n : ℕ) → K {R} (A n)) → K {R} (∀(n : ℕ) → A n) -- shift. 22 | 23 | 24 | -- Choose here: 25 | 26 | K-∀-shift = K-∀-shift-selection 27 | -- K-∀-shift = K-∀-shift-mbr 28 | -- K-∀-shift = K-∀-shift-bbc 29 | -------------------------------------------------------------------------------- /source/InfinitePigeon/Logic.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module InfinitePigeon.Logic where 6 | 7 | -- Type of propositions denoted by Ω, like in a topos: 8 | 9 | Ω = Set 10 | 11 | data ⊥ : Ω where 12 | -- nothing defined here: there are no constructors of this type. 13 | 14 | ⊥-elim : {A : Ω} → ⊥ → A 15 | ⊥-elim = λ () 16 | 17 | 18 | ¬_ : Ω → Ω 19 | ¬ A = (A → ⊥) 20 | 21 | infix 50 ¬_ 22 | 23 | 24 | data ⊤ : Ω where 25 | * : ⊤ 26 | 27 | 28 | data _∧_ (A₀ A₁ : Ω) : Ω where 29 | ∧-intro : A₀ → A₁ → A₀ ∧ A₁ 30 | 31 | infixr 10 _∧_ 32 | 33 | 34 | ∧-elim₀ : {A₀ A₁ : Ω} → A₀ ∧ A₁ → A₀ 35 | ∧-elim₀ (∧-intro a₀ a₁) = a₀ 36 | 37 | 38 | ∧-elim₁ : {A₀ A₁ : Ω} → A₀ ∧ A₁ → A₁ 39 | ∧-elim₁ (∧-intro a₀ a₁) = a₁ 40 | 41 | _↔_ : Ω → Ω → Ω 42 | A ↔ B = (A → B) ∧ (B → A) 43 | 44 | 45 | data _∨_ (A₀ A₁ : Ω) : Ω where 46 | ∨-intro₀ : A₀ → A₀ ∨ A₁ 47 | ∨-intro₁ : A₁ → A₀ ∨ A₁ 48 | 49 | infixr 20 _∨_ 50 | 51 | 52 | ∨-elim : {A₀ A₁ B : Ω} → (A₀ → B) → (A₁ → B) → A₀ ∨ A₁ → B 53 | ∨-elim f₀ f₁ (∨-intro₀ a₀) = f₀ a₀ 54 | ∨-elim f₀ f₁ (∨-intro₁ a₁) = f₁ a₁ 55 | 56 | 57 | dependent-∨-elim : {A₀ A₁ : Ω} → {B : A₀ ∨ A₁ → Ω} → 58 | ((a₀ : A₀) → B(∨-intro₀ a₀)) → ((a₁ : A₁) → B(∨-intro₁ a₁)) → 59 | (a : A₀ ∨ A₁) → B a 60 | dependent-∨-elim f₀ f₁ (∨-intro₀ a₀) = f₀ a₀ 61 | dependent-∨-elim f₀ f₁ (∨-intro₁ a₁) = f₁ a₁ 62 | 63 | 64 | decidable : Ω → Ω 65 | decidable A = A ∨ ¬ A 66 | 67 | 68 | data ∃ {X : Set} (A : X → Ω) : Ω where 69 | ∃-intro : (x₀ : X) → A x₀ → ∃ \(x : X) → A x 70 | 71 | 72 | ∃-witness : {X : Set} {A : X → Ω} → (∃ \(x : X) → A x) → X 73 | ∃-witness (∃-intro x a) = x 74 | 75 | 76 | ∃-elim : {X : Set} {A : X → Ω} → 77 | 78 | (proof : ∃ \(x : X) → A x) → A (∃-witness proof) 79 | 80 | ∃-elim (∃-intro x a) = a 81 | 82 | 83 | inhabited : Set → Ω 84 | inhabited X = ∃ \(x : X) → ⊤ 85 | -------------------------------------------------------------------------------- /source/InfinitePigeon/LogicalFacts.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module InfinitePigeon.LogicalFacts where 6 | 7 | infixl 30 _∘_ 8 | 9 | open import InfinitePigeon.Logic 10 | 11 | _∘_ : {A B : Ω} {C : B → Ω} → 12 | (∀(b : B) → C b) → ∀(f : A → B) → ∀(a : A) → C(f a) 13 | 14 | g ∘ f = λ x → g(f x) 15 | 16 | 17 | id : {A : Ω} → A → A 18 | id x = x 19 | 20 | 21 | uncurry : {A B C : Ω} → 22 | (A → B → C) → A ∧ B → C 23 | 24 | uncurry f (∧-intro a b) = f a b 25 | 26 | 27 | curry : {A B C : Ω} → 28 | (A ∧ B → C) → A → B → C 29 | 30 | curry f a b = f(∧-intro a b) 31 | 32 | 33 | double-negation-intro : {R A : Ω} → 34 | A → ((A → R) → R) 35 | 36 | double-negation-intro a p = p a 37 | 38 | 39 | contra-positive : {R A B : Ω} → 40 | (A → B) → (B → R) → (A → R) 41 | 42 | contra-positive f p = p ∘ f 43 | 44 | 45 | three-negations-imply-one : {R A : Ω} → 46 | (((A → R) → R) → R) → (A → R) 47 | 48 | three-negations-imply-one = contra-positive double-negation-intro 49 | 50 | 51 | not-exists-implies-forall-not : {R : Ω} → {X : Set} → {A : X → Ω} → 52 | ((∃ \(x : X) → A x) → R) → ∀(x : X) → A x → R 53 | 54 | not-exists-implies-forall-not f x a = f(∃-intro x a) 55 | 56 | 57 | forall-not-implies-not-exists : {R : Ω} → {X : Set} → {A : X → Ω} → 58 | (∀(x : X) → A x → R) → (∃ \(x : X) → A x) → R 59 | 60 | forall-not-implies-not-exists f (∃-intro x a) = f x a 61 | 62 | 63 | ∃-functor : {X : Set} {A B : X → Ω} → 64 | ({x : X} → A x → B x) → 65 | (∃ \(x : X) → A x) → ∃ \(x : X) → B x 66 | 67 | ∃-functor f (∃-intro x a) = ∃-intro x (f a) 68 | 69 | 70 | ∃-nested-functor : {X Y : Set} {A B : X → Y → Ω} → 71 | ({x : X} → {y : Y} → A x y → B x y) → 72 | (∃ \(x : X) → ∃ \(y : Y) → A x y) → ∃ \(x : X) → ∃ \(y : Y) → B x y 73 | 74 | ∃-nested-functor f = ∃-functor (λ a → ∃-functor f a) 75 | -------------------------------------------------------------------------------- /source/InfinitePigeon/Naturals.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module InfinitePigeon.Naturals where 6 | 7 | open import InfinitePigeon.Logic 8 | 9 | open import MLTT.Natural-Numbers-Type public renaming (zero to O) 10 | 11 | induction : {A : ℕ → Ω} → 12 | --------- 13 | A 0 → (∀(k : ℕ) → A k → A(succ k)) → ∀(n : ℕ) → A n 14 | 15 | induction base step 0 = base 16 | induction base step (succ n) = step n (induction base step n) 17 | 18 | 19 | head : {A : ℕ → Ω} → 20 | ---- 21 | (∀(n : ℕ) → A n) → A 0 22 | 23 | head α = α 0 24 | 25 | 26 | tail : {A : ℕ → Ω} → 27 | ---- 28 | (∀(n : ℕ) → A n) → ∀(n : ℕ) → A(succ n) 29 | 30 | tail α n = α(succ n) 31 | 32 | 33 | cons : {A : ℕ → Ω} → 34 | ---- 35 | A 0 ∧ (∀(n : ℕ) → A(succ n)) → ∀(n : ℕ) → A n 36 | 37 | cons (∧-intro a α) 0 = a 38 | cons (∧-intro a α) (succ n) = α n 39 | 40 | 41 | prefix : {R : Ω} {A : ℕ → Ω} → 42 | ------ 43 | A 0 → ((∀(n : ℕ) → A n) → R) → (∀(n : ℕ) → A(succ n)) → R 44 | 45 | 46 | prefix α₀ p α' = p(cons (∧-intro α₀ α')) 47 | 48 | 49 | eq-cases : {X : ℕ → Set} → (i j : ℕ) → X i → X j → X j 50 | eq-cases 0 0 x y = x 51 | eq-cases 0 (succ j) x y = y 52 | eq-cases (succ i) 0 x y = y 53 | eq-cases {X} (succ i) (succ j) x y = eq-cases {λ n → X(succ n)} i j x y 54 | 55 | 56 | mapsto : {X : ℕ → Set} → 57 | (i : ℕ) → X i → ((j : ℕ) → X j) → (j : ℕ) → X j 58 | mapsto {X} i x α j = eq-cases {X} i j x (α j) 59 | -------------------------------------------------------------------------------- /source/InfinitePigeon/Order.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module InfinitePigeon.Order where 6 | 7 | open import InfinitePigeon.Addition 8 | open import InfinitePigeon.Equality 9 | open import InfinitePigeon.Logic 10 | open import InfinitePigeon.Naturals 11 | 12 | _≤_ : ℕ → ℕ → Ω 13 | x ≤ y = ∃ \(n : ℕ) → x + n ≡ y 14 | 15 | _<_ : ℕ → ℕ → Ω 16 | x < y = ∃ \(n : ℕ) → x + n + 1 ≡ y 17 | 18 | infix 29 _<_ 19 | infix 29 _≤_ 20 | 21 | -- This is how we are going to write inequality proofs (when possible): 22 | 23 | less-proof : {x : ℕ} → (n : ℕ) → x < x + n + 1 24 | less-proof n = ∃-intro n reflexivity 25 | -------------------------------------------------------------------------------- /source/InfinitePigeon/PigeonProgram.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.PigeonProgram where 6 | 7 | open import InfinitePigeon.Cantor 8 | open import InfinitePigeon.DataStructures 9 | open import InfinitePigeon.FinitePigeon 10 | open import InfinitePigeon.Logic 11 | open import InfinitePigeon.Naturals 12 | open import InfinitePigeon.Two 13 | 14 | -- Given an infinite boolean sequence α and a natural number m, find a 15 | -- boolean b and a finite list of length n with the indices of a 16 | -- finite constant subsequence of α with value b at all 17 | -- positions. 18 | -- 19 | -- This is usually how such programs are specified in functional 20 | -- programming (if they are at all). Here Theorem (defined in the 21 | -- module FinitePigeon) is the program with the formal specification, 22 | -- also formally checked. Once this is done we can erase the 23 | -- specification. 24 | 25 | pigeon-program : ₂ℕ → ℕ → ₂ × List ℕ 26 | pigeon-program α m = f(Theorem α m) 27 | where f : Finite-Pigeonhole α m → ₂ × List ℕ 28 | f(∃-intro b (∃-intro s proof)) = (b , list s) 29 | -------------------------------------------------------------------------------- /source/InfinitePigeon/ProgramsWithoutSpecification.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.ProgramsWithoutSpecification where 6 | 7 | open import InfinitePigeon.Addition 8 | open import InfinitePigeon.Cantor 9 | open import InfinitePigeon.Finite 10 | open import InfinitePigeon.FinitePigeon 11 | open import InfinitePigeon.Logic 12 | open import InfinitePigeon.Naturals 13 | open import InfinitePigeon.Two 14 | 15 | program₁ : ₂ℕ → ℕ → ₂ 16 | program₁ α m = ∃-witness(Theorem α m) 17 | 18 | program₂ : ₂ℕ → (m : ℕ) → (smaller(m + 1) → ℕ) 19 | program₂ α m = ∃-witness(∃-elim (Theorem α m)) 20 | -------------------------------------------------------------------------------- /source/InfinitePigeon/ProgramsWithoutSpecificationBis.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --without-K #-} 4 | 5 | module InfinitePigeon.ProgramsWithoutSpecificationBis where 6 | 7 | open import InfinitePigeon.Addition 8 | open import InfinitePigeon.Cantor 9 | open import InfinitePigeon.Finite 10 | open import InfinitePigeon.FinitePigeon 11 | open import InfinitePigeon.Logic 12 | open import InfinitePigeon.Naturals 13 | open import InfinitePigeon.Two 14 | 15 | program₁ : ₂ℕ → ℕ → ₂ 16 | program₁ α m = f(Theorem α m) 17 | where f : Finite-Pigeonhole α m → ₂ 18 | f(∃-intro b proof) = b 19 | 20 | program₂ : ₂ℕ → (m : ℕ) → (smaller(m + 1) → ℕ) 21 | program₂ α m = f(Theorem α m) 22 | where f : Finite-Pigeonhole α m → (smaller(m + 1) → ℕ) 23 | f(∃-intro b (∃-intro s proof)) = s 24 | -------------------------------------------------------------------------------- /source/InfinitePigeon/Two.agda: -------------------------------------------------------------------------------- 1 | -- Martin Escardo and Paulo Oliva 2011 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module InfinitePigeon.Two where 6 | 7 | data ₂ : Set where 8 | ₀ : ₂ 9 | ₁ : ₂ 10 | 11 | not : ₂ → ₂ 12 | not ₀ = ₁ 13 | not ₁ = ₀ 14 | 15 | open import InfinitePigeon.Equality 16 | open import InfinitePigeon.Logic 17 | 18 | two-equality-cases : {R : Ω} → 19 | ∀(b : ₂) → (b ≡ ₀ → R) → (b ≡ ₁ → R) → R 20 | 21 | two-equality-cases ₀ f₀ f₁ = f₀ reflexivity 22 | two-equality-cases ₁ f₀ f₁ = f₁ reflexivity 23 | -------------------------------------------------------------------------------- /source/InjectiveTypes/PointedDcpos.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong and Martín Escardó, 18 January 2024. 2 | 3 | The carrier of a pointed dcpo is an algebraically injective type. 4 | 5 | More precisely, if 𝓓 is a poset with a least element and suprema for directed 6 | families indexed by types in a universe 𝓥, then the carrier of 𝓓 is 7 | algebraically injective with respect to embeddings of types in 𝓥. 8 | 9 | \begin{code} 10 | 11 | {-# OPTIONS --safe --without-K #-} 12 | 13 | open import MLTT.Spartan 14 | 15 | open import UF.FunExt 16 | open import UF.PropTrunc 17 | 18 | module InjectiveTypes.PointedDcpos 19 | (fe : FunExt) 20 | (pt : propositional-truncations-exist) 21 | (𝓥 : Universe) 22 | where 23 | 24 | private 25 | fe' : Fun-Ext 26 | fe' {𝓤} {𝓥} = fe 𝓤 𝓥 27 | 28 | open import DomainTheory.Basics.Pointed pt fe' 𝓥 29 | open import InjectiveTypes.Blackboard fe 30 | 31 | pointed-dcpos-are-aflabby-types : (𝓓 : DCPO⊥ {𝓤} {𝓣}) → aflabby ⟪ 𝓓 ⟫ 𝓥 32 | pointed-dcpos-are-aflabby-types 𝓓 P P-is-prop f = I , II 33 | where 34 | I : ⟪ 𝓓 ⟫ 35 | I = ∐ˢˢ 𝓓 f P-is-prop 36 | II : (p : P) → I = f p 37 | II p = ∐ˢˢ-=-if-domain-holds 𝓓 P-is-prop p 38 | 39 | pointed-dcpos-are-ainjective-types : 40 | (𝓓 : DCPO⊥ {𝓤} {𝓣}) → ainjective-type ⟪ 𝓓 ⟫ 𝓥 𝓥 41 | pointed-dcpos-are-ainjective-types 𝓓 = 42 | aflabby-types-are-ainjective ⟪ 𝓓 ⟫ (pointed-dcpos-are-aflabby-types 𝓓) 43 | 44 | \end{code} 45 | -------------------------------------------------------------------------------- /source/Integers/Negation.lagda: -------------------------------------------------------------------------------- 1 | Andrew Sneap, 26 November 2021 2 | 3 | This file defines negation of integers. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | open import MLTT.Spartan renaming (_+_ to _∔_) 10 | 11 | open import Integers.Type 12 | 13 | module Integers.Negation where 14 | 15 | -_ : ℤ → ℤ 16 | -_ (pos 0) = pos 0 17 | -_ (pos (succ x)) = negsucc x 18 | -_ (negsucc x) = pos (succ x) 19 | 20 | infix 31 -_ 21 | 22 | \end{code} 23 | 24 | These proofs are all by definition, however we must consider each case 25 | seperately. 26 | 27 | \begin{code} 28 | 29 | predminus : (x : ℤ) → predℤ (- x) = (- succℤ x) 30 | predminus (pos 0) = refl 31 | predminus (pos (succ x)) = refl 32 | predminus (negsucc 0) = refl 33 | predminus (negsucc (succ x)) = refl 34 | 35 | negsucctopredℤ : (k : ℕ) → negsucc k = predℤ (- pos k) 36 | negsucctopredℤ 0 = refl 37 | negsucctopredℤ (succ k) = refl 38 | 39 | succℤtominuspredℤ : (x : ℤ) → succℤ (- x) = (- predℤ x) 40 | succℤtominuspredℤ (pos 0) = refl 41 | succℤtominuspredℤ (pos (succ 0)) = refl 42 | succℤtominuspredℤ (pos (succ (succ x))) = refl 43 | succℤtominuspredℤ (negsucc x) = refl 44 | 45 | minus-minus-is-plus : (x : ℤ) → - (- x) = x 46 | minus-minus-is-plus (pos 0) = refl 47 | minus-minus-is-plus (pos (succ x)) = refl 48 | minus-minus-is-plus (negsucc x) = refl 49 | 50 | \end{code} 51 | -------------------------------------------------------------------------------- /source/Integers/index.lagda: -------------------------------------------------------------------------------- 1 | Andrew Sneap 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module Integers.index where 8 | 9 | import Integers.Abs 10 | import Integers.Addition 11 | import Integers.Division 12 | import Integers.Exponentiation 13 | import Integers.HCF 14 | import Integers.Type 15 | import Integers.Multiplication 16 | import Integers.Negation 17 | import Integers.Order 18 | import Integers.Parity 19 | 20 | \end{code} 21 | -------------------------------------------------------------------------------- /source/Iterative/Multisets-IdentificationExample.lagda: -------------------------------------------------------------------------------- 1 | Alice Laroche, 27th September 2023 2 | 3 | We show the identification of two alternative definition of 𝟚ᴹ, 4 | and their equality under univalence. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | open import MLTT.Spartan 11 | open import UF.Sets-Properties 12 | open import UF.Univalence 13 | open import UF.Universes 14 | 15 | module Iterative.Multisets-IdentificationExample 16 | (ua : Univalence) 17 | where 18 | 19 | open import Iterative.Multisets 𝓤₀ 20 | open import Iterative.Multisets-Addendum ua 𝓤₀ 21 | open import MLTT.Two 22 | open import UF.Equiv 23 | open import UF.EquivalenceExamples 24 | open import W.Type 25 | 26 | 𝟚ᴹ : 𝕄 27 | 𝟚ᴹ = ssup 𝟚 (𝟚-cases 𝟘ᴹ 𝟙ᴹ) 28 | 29 | 𝟚ᴹ' : 𝕄 30 | 𝟚ᴹ' = ssup 𝟚 (𝟚-cases 𝟙ᴹ 𝟘ᴹ) 31 | 32 | 𝟚ᴹ≃ᴹ𝟚ᴹ' : 𝟚ᴹ ≃ᴹ 𝟚ᴹ' 33 | 𝟚ᴹ≃ᴹ𝟚ᴹ' = complement-≃ , I 34 | where 35 | I : (x : 𝟚) → 𝟚-cases 𝟘ᴹ 𝟙ᴹ x ≃ᴹ 𝟚-cases 𝟙ᴹ 𝟘ᴹ (⌜ complement-≃ ⌝ x) 36 | I ₀ = ≃ᴹ-refl 𝟘ᴹ 37 | I ₁ = ≃ᴹ-refl 𝟙ᴹ 38 | 39 | 𝟚ᴹ=𝟚ᴹ' : 𝟚ᴹ = 𝟚ᴹ' 40 | 𝟚ᴹ=𝟚ᴹ' = ⌜ 𝕄-=-≃ ua 𝟚ᴹ 𝟚ᴹ' ⌝⁻¹ 𝟚ᴹ≃ᴹ𝟚ᴹ' 41 | 42 | \end{code} 43 | -------------------------------------------------------------------------------- /source/Lifting/Construction.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 25th October 2018. 2 | 3 | The type of partial elements of a type (or lifting). 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | open import MLTT.Spartan 10 | 11 | module Lifting.Construction (𝓣 : Universe) where 12 | 13 | open import UF.Subsingletons 14 | 15 | 𝓛 : 𝓤 ̇ → 𝓣 ⁺ ⊔ 𝓤 ̇ 16 | 𝓛 X = Σ P ꞉ 𝓣 ̇ , (P → X) × is-prop P 17 | 18 | is-defined : {X : 𝓤 ̇ } → 𝓛 X → 𝓣 ̇ 19 | 20 | is-defined (P , φ , i) = P 21 | 22 | being-defined-is-prop : {X : 𝓤 ̇ } (l : 𝓛 X) → is-prop (is-defined l) 23 | being-defined-is-prop (P , φ , i) = i 24 | 25 | value : {X : 𝓤 ̇ } (l : 𝓛 X) → is-defined l → X 26 | value (P , φ , i) = φ 27 | 28 | \end{code} 29 | 30 | The "total" elements of 𝓛 X: 31 | 32 | \begin{code} 33 | 34 | η : {X : 𝓤 ̇ } → X → 𝓛 X 35 | η x = 𝟙 , (λ _ → x) , 𝟙-is-prop 36 | 37 | \end{code} 38 | 39 | Its "undefined" element: 40 | 41 | \begin{code} 42 | 43 | ⊥ : {X : 𝓤 ̇ } → 𝓛 X 44 | ⊥ = 𝟘 , unique-from-𝟘 , 𝟘-is-prop 45 | 46 | \end{code} 47 | -------------------------------------------------------------------------------- /source/Lifting/EmbeddingViaSIP.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 7th December 2018. 2 | 3 | We show that the natural map into the lifting is an embedding using 4 | the structure identity principle. A more direct, but longer, proof 5 | is in the module Lifting.EmbeddingDirectly. 6 | 7 | \begin{code} 8 | 9 | {-# OPTIONS --safe --without-K #-} 10 | 11 | open import MLTT.Spartan 12 | 13 | module Lifting.EmbeddingViaSIP 14 | (𝓣 𝓤 : Universe) 15 | (X : 𝓤 ̇ ) 16 | where 17 | 18 | open import UF.Subsingletons 19 | open import UF.Embeddings 20 | open import UF.Equiv 21 | open import UF.EquivalenceExamples 22 | open import UF.FunExt 23 | open import UF.Univalence 24 | open import UF.UA-FunExt 25 | 26 | open import Lifting.Construction 𝓣 27 | open import Lifting.IdentityViaSIP 𝓣 28 | 29 | \end{code} 30 | 31 | The crucial point the use the characterization of identity via the 32 | structure identity principle: 33 | 34 | \begin{code} 35 | 36 | η-is-embedding' : is-univalent 𝓣 → funext 𝓣 𝓤 → is-embedding (η {𝓤} {X}) 37 | η-is-embedding' ua fe = embedding-criterion' η c 38 | where 39 | a = (𝟙 ≃ 𝟙) ≃⟨ ≃-sym (univalence-≃ ua 𝟙 𝟙) ⟩ 40 | (𝟙 = 𝟙) ≃⟨ 𝟙-=-≃ 𝟙 (univalence-gives-funext ua) 41 | (univalence-gives-propext ua) 𝟙-is-prop ⟩ 42 | 𝟙 ■ 43 | 44 | b = λ x y → ((λ _ → x) = (λ _ → y)) ≃⟨ ≃-funext fe (λ _ → x) (λ _ → y) ⟩ 45 | (𝟙 → x = y) ≃⟨ ≃-sym (𝟙→ fe) ⟩ 46 | (x = y) ■ 47 | 48 | c = λ x y → (η x = η y) ≃⟨ 𝓛-Id ua (η x) (η y) ⟩ 49 | (𝟙 ≃ 𝟙) × ((λ _ → x) = (λ _ → y)) ≃⟨ ×-cong a (b x y) ⟩ 50 | 𝟙 × (x = y) ≃⟨ 𝟙-lneutral ⟩ 51 | (x = y) ■ 52 | 53 | \end{code} 54 | -------------------------------------------------------------------------------- /source/Lifting/Miscelanea.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong 22nd May 2019 2 | 3 | A few basic lemmas for working with partial elements of a type. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | open import MLTT.Spartan 10 | 11 | module Lifting.Miscelanea (𝓣 : Universe) where 12 | 13 | open import Lifting.Construction 𝓣 14 | open import UF.Equiv 15 | open import UF.EquivalenceExamples 16 | 17 | module _ {𝓤 : Universe} 18 | {X : 𝓤 ̇ } 19 | where 20 | 21 | value-is-constant : (l : 𝓛 X) (d e : is-defined l) → value l d = value l e 22 | value-is-constant l d e = ap (value l) (being-defined-is-prop l d e) 23 | 24 | =-of-values-from-= : {l m : 𝓛 X} {d : is-defined l} {e : is-defined m} 25 | → l = m → value l d = value m e 26 | =-of-values-from-= {l} {m} {d} {e} refl = value-is-constant l d e 27 | 28 | =-to-is-defined : {l m : 𝓛 X} → l = m → is-defined l → is-defined m 29 | =-to-is-defined e d = transport is-defined e d 30 | 31 | ⊥-is-not-η : (x : X) → ⊥ ≠ η x 32 | ⊥-is-not-η x e = ⌜ one-𝟘-only ⌝ (=-to-is-defined (e ⁻¹) ⋆) 33 | 34 | \end{code} 35 | -------------------------------------------------------------------------------- /source/Lifting/MonadVariation.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 7th November 2018. 2 | 3 | Remark. Another equivalent way to define the multiplication, which has 4 | a different universe level: 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | open import MLTT.Spartan 11 | 12 | module Lifting.MonadVariation where 13 | 14 | open import UF.Subsingletons 15 | open import UF.Embeddings 16 | open import UF.FunExt 17 | 18 | open import Lifting.Construction 19 | open import Lifting.EmbeddingDirectly 20 | 21 | 𝓛* : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } (f : X → Y) → is-embedding f → 𝓛 𝓣 Y → 𝓛 (𝓤 ⊔ 𝓥 ⊔ 𝓣) X 22 | 𝓛* f e (Q , ψ , j) = (Σ q ꞉ Q , fiber f (ψ q)) , 23 | (λ p → pr₁ (pr₂ p)) , 24 | Σ-is-prop j (e ∘ ψ) 25 | 26 | μ* : (𝓣 𝓣' : Universe) {X : 𝓤 ̇ } 27 | → funext 𝓣 𝓣 28 | → funext 𝓣' 𝓣' 29 | → funext 𝓣' 𝓤 30 | → funext 𝓤 (𝓤 ⊔ (𝓣' ⁺)) 31 | → propext 𝓣' 32 | → 𝓛 𝓣 (𝓛 𝓣' X) → 𝓛 (𝓤 ⊔ 𝓣 ⊔ (𝓣' ⁺)) X 33 | μ* {𝓤} 𝓣 𝓣' {X} fe fe' fe'' fe''' pe = 𝓛* (η 𝓣') (η-is-embedding 𝓣' pe fe' fe'' fe''') 34 | 35 | \end{code} 36 | -------------------------------------------------------------------------------- /source/Lifting/Set.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong 22nd May 2019 2 | 3 | The lifting of a set is a set. 4 | 5 | We need to assume propositional extensionality for the fixed universe 𝓣 of 6 | propositions and two instances of function extensionality. 7 | 8 | \begin{code} 9 | 10 | {-# OPTIONS --safe --without-K #-} 11 | 12 | open import MLTT.Spartan 13 | 14 | module Lifting.Set 15 | (𝓣 : Universe) -- fix a universe for the propositions 16 | where 17 | 18 | open import Lifting.Construction 𝓣 19 | open import UF.Base 20 | open import UF.FunExt 21 | open import UF.Retracts 22 | open import UF.Sets 23 | open import UF.Sets-Properties 24 | open import UF.Subsingletons 25 | open import UF.Subsingletons-FunExt 26 | open import UF.Subsingletons-Properties 27 | 28 | lifting-of-set-is-set : funext 𝓣 𝓤 29 | → funext 𝓣 𝓣 30 | → propext 𝓣 31 | → (X : 𝓤 ̇ ) 32 | → is-set X 33 | → is-set (𝓛 X) 34 | lifting-of-set-is-set fe' fe pe X i {l} {m} p q = retract-of-prop r j p q 35 | where 36 | r : Σ has-section 37 | r = (to-Σ-= , from-Σ-= , tofrom-Σ-=) 38 | 39 | j : is-prop (Σ (λ p₁ → transport (λ P → (P → X) × is-prop P) 40 | p₁ (pr₂ l) = pr₂ m)) 41 | j = Σ-is-prop 42 | (identifications-with-props-are-props pe fe (is-defined m) 43 | (being-defined-is-prop m) (is-defined l)) 44 | (λ d → ×-is-set (Π-is-set fe' λ _ → i) 45 | (props-are-sets (being-prop-is-prop fe))) 46 | 47 | \end{code} 48 | -------------------------------------------------------------------------------- /source/Lifting/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, 2018-2019 2 | 3 | The lifting (aka partial-map classifier) monad. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | module Lifting.index where 10 | 11 | import Lifting.Algebras 12 | import Lifting.Construction 13 | import Lifting.EmbeddingDirectly 14 | import Lifting.EmbeddingViaSIP 15 | import Lifting.IdentityViaSIP 16 | import Lifting.Miscelanea -- By Tom de Jong 2019 17 | import Lifting.Miscelanea-PropExt-FunExt -- By Tom de Jong 2019 18 | import Lifting.Monad 19 | import Lifting.MonadVariation 20 | import Lifting.Set 21 | import Lifting.Size 22 | import Lifting.UnivalentPrecategory 23 | 24 | \end{code} 25 | -------------------------------------------------------------------------------- /source/Locales/ContinuousMap/Homeomorphism-Definition.lagda: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | title: Homeomorphisms of locales 3 | author: Ayberk Tosun 4 | date-started: 2024-04-11 5 | date-completed: 2024-04-18 6 | -------------------------------------------------------------------------------- 7 | 8 | A homeomorphism of locales is the same thing as an isomorphism of their 9 | underlying frames. As we maintain a careful distinction between locales and 10 | their defining frames, however, we give a different name to this notion. 11 | 12 | \begin{code}[hide] 13 | 14 | {-# OPTIONS --safe --without-K #-} 15 | 16 | open import MLTT.Spartan hiding (𝟚; ₀; ₁) 17 | open import UF.FunExt 18 | open import UF.PropTrunc 19 | 20 | module Locales.ContinuousMap.Homeomorphism-Definition 21 | (pt : propositional-truncations-exist) 22 | (fe : Fun-Ext) 23 | where 24 | 25 | open import Locales.ContinuousMap.FrameIsomorphism-Definition pt fe 26 | open import Locales.Frame pt fe 27 | open import UF.Logic 28 | 29 | open AllCombinators pt fe 30 | open Locale 31 | 32 | \end{code} 33 | 34 | A homeomorphism between locales `X` and `Y` is an isomorphism between their 35 | defining frames. 36 | 37 | \begin{code} 38 | 39 | Homeomorphism : Locale 𝓤 𝓥 𝓦 → Locale 𝓤' 𝓥' 𝓦 → 𝓤' ⊔ 𝓤 ⊔ 𝓥 ⊔ 𝓥' ⊔ 𝓦 ⁺ ̇ 40 | Homeomorphism X Y = Isomorphismᵣ (𝒪 Y) (𝒪 X) 41 | where 42 | open FrameIsomorphisms 43 | 44 | \end{code} 45 | 46 | Declare syntax for homeomorphisms. 47 | 48 | \begin{code} 49 | 50 | Homeomorphism-Syntax : Locale 𝓤 𝓥 𝓦 → Locale 𝓤' 𝓥' 𝓦 → 𝓤 ⊔ 𝓤' ⊔ 𝓥 ⊔ 𝓥' ⊔ 𝓦 ⁺ ̇ 51 | Homeomorphism-Syntax = Homeomorphism 52 | 53 | infix 0 Homeomorphism-Syntax 54 | syntax Homeomorphism-Syntax X Y = X ≅c≅ Y 55 | 56 | \end{code} 57 | -------------------------------------------------------------------------------- /source/Locales/ContinuousMap/Properties.lagda: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | title: Properties of continuous maps 3 | author: Ayberk Tosun 4 | date-started: 2024-04-10 5 | -------------------------------------------------------------------------------- 6 | 7 | Factored out from the `Locales.Frame` module on 2024-04-10. 8 | 9 | \begin{code}[hide] 10 | 11 | {-# OPTIONS --safe --without-K #-} 12 | 13 | open import MLTT.Spartan hiding (𝟚; ₀; ₁) 14 | open import UF.FunExt 15 | open import UF.PropTrunc 16 | 17 | module Locales.ContinuousMap.Properties 18 | (pt : propositional-truncations-exist) 19 | (fe : Fun-Ext) 20 | where 21 | 22 | open import Locales.Frame pt fe 23 | open import Locales.ContinuousMap.FrameHomomorphism-Properties pt fe 24 | open import Locales.ContinuousMap.Definition pt fe 25 | open import UF.Logic 26 | 27 | open AllCombinators pt fe 28 | open ContinuousMaps 29 | open FrameHomomorphismProperties 30 | open Locale 31 | 32 | \end{code} 33 | 34 | Lemma for showing equality of continuous maps. 35 | 36 | \begin{code} 37 | 38 | to-continuous-map-= : (X : Locale 𝓤 𝓥 𝓦) (Y : Locale 𝓤' 𝓥' 𝓦) (f g : X ─c→ Y) 39 | → 40 | let 41 | open ContinuousMapNotation X Y 42 | in 43 | ((V : ⟨ 𝒪 Y ⟩) → f ⋆∙ V = g ⋆∙ V) 44 | → f = g 45 | to-continuous-map-= X Y f g φ = 46 | to-frame-homomorphism-= (𝒪 Y) (𝒪 X) (_⋆ f) (_⋆ g) φ 47 | where 48 | open ContinuousMapNotation X Y 49 | 50 | \end{code} 51 | -------------------------------------------------------------------------------- /source/Locales/DiscreteLocale/Two.lagda: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | title: Two 3 | author: Ayberk Tosun 4 | date-started: 2024-03-04 5 | date-completed: 2024-03-04 6 | -------------------------------------------------------------------------------- 7 | 8 | We define the locale corresponding to the two-point discrete space. 9 | 10 | \begin{code} 11 | 12 | {-# OPTIONS --safe --without-K #-} 13 | 14 | open import UF.PropTrunc 15 | open import UF.FunExt 16 | open import UF.Subsingletons 17 | 18 | module Locales.DiscreteLocale.Two 19 | (fe : Fun-Ext) 20 | (pe : Prop-Ext) 21 | (pt : propositional-truncations-exist) 22 | where 23 | 24 | open import Locales.DiscreteLocale.Definition fe pe pt 25 | open import Locales.Frame pt fe 26 | open import MLTT.Spartan hiding (𝟚) 27 | open import UF.Logic 28 | open import UF.Sets 29 | open import UF.DiscreteAndSeparated hiding (𝟚-is-set) 30 | open import UF.Powerset 31 | 32 | open AllCombinators pt fe renaming (_∧_ to _∧ₚ_; _∨_ to _∨ₚ_) 33 | open PropositionalSubsetInclusionNotation fe 34 | open PropositionalTruncation pt hiding (_∨_) 35 | 36 | \end{code} 37 | 38 | \begin{code} 39 | 40 | module _ (𝓤 : Universe) where 41 | 42 | 𝟚-is-set : {𝓤 : Universe} → is-set (𝟚 𝓤) 43 | 𝟚-is-set {𝓤} = +-is-set (𝟙 {𝓤}) (𝟙 {𝓤}) 𝟙-is-set 𝟙-is-set 44 | 45 | 𝟚-loc : Locale (𝓤 ⁺) 𝓤 𝓤 46 | 𝟚-loc = discrete-locale (𝟚 𝓤) 𝟚-is-set 47 | 48 | \end{code} 49 | -------------------------------------------------------------------------------- /source/Locales/NotationalConventions.lagda: -------------------------------------------------------------------------------- 1 | 2 | Ayberk Tosun, 13 September 2023 3 | 4 | \begin{code}[hide] 5 | 6 | {-# OPTIONS --safe --without-K #-} 7 | 8 | open import UF.PropTrunc 9 | open import UF.FunExt 10 | 11 | module Locales.NotationalConventions (pt : propositional-truncations-exist) 12 | (fe : Fun-Ext) where 13 | 14 | open import Locales.SmallBasis pt fe 15 | open import Locales.Spectrality.SpectralLocale pt fe 16 | 17 | \end{code} 18 | 19 | \section{Data vs. property distinction} 20 | 21 | As we work in Univalent Foundations, we maintain a careful distinction between 22 | structures and properties. 23 | 24 | To emphasise that we are working with the structural version of a definition 25 | that has a version that is a property, we use the superscript `_ᴰ` (for "data"). 26 | 27 | For example, we have `spectralᴰ` which denotes the structure involved in 28 | spectrality. 29 | 30 | \begin{code} 31 | 32 | _ = spectralᴰ 33 | 34 | \end{code} 35 | 36 | The version that is a property is called `is-spectral`. 37 | 38 | \begin{code} 39 | 40 | _ = is-spectral 41 | 42 | \end{code} 43 | 44 | \section{Locales vs. frames} 45 | 46 | TODO 47 | -------------------------------------------------------------------------------- /source/Locales/PatchOfOmega.lagda: -------------------------------------------------------------------------------- 1 | Ayberk Tosun, 17 August 2023. 2 | 3 | \begin{code}[hide] 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | open import MLTT.Spartan 8 | open import UF.PropTrunc 9 | open import UF.FunExt 10 | open import UF.Subsingletons 11 | open import UF.SubtypeClassifier 12 | open import UF.Size 13 | 14 | module Locales.PatchOfOmega (pt : propositional-truncations-exist) 15 | (fe : Fun-Ext) 16 | (sr : Set-Replacement pt) 17 | (𝓤 : Universe) 18 | (pe : propext 𝓤) 19 | where 20 | 21 | open import Locales.Frame pt fe 22 | open import Locales.Spectrality.SpectralLocale pt fe 23 | open import Locales.Spectrality.SpectralityOfOmega pt fe sr 24 | open import Locales.PatchLocale pt fe sr 25 | open import Locales.InitialFrame pt fe 26 | 27 | \end{code} 28 | 29 | This is the terminal locale which I denote by `𝟏-loc` 30 | 31 | \begin{code} 32 | 33 | 𝟏L : Locale (𝓤 ⁺) 𝓤 𝓤 34 | 𝟏L = 𝟏-loc 𝓤 pe 35 | 36 | \end{code} 37 | 38 | We know that `Ω-Frm` is spectral. 39 | 40 | \begin{code} 41 | 42 | open Spectrality-of-𝟎 𝓤 pe 43 | 44 | Ω-is-spectral : is-spectral 𝟏L holds 45 | Ω-is-spectral = 𝟎-𝔽𝕣𝕞-is-spectral 𝓤 pe 46 | 47 | \end{code} 48 | 49 | This means that we can easily compute the patch of `Ω`. 50 | 51 | \begin{code} 52 | 53 | open PatchConstruction 𝟏L Ω-is-spectral renaming (Patch to patch-Ω) 54 | 55 | patch-of-Ω : Locale (𝓤 ⁺) (𝓤 ⁺) 𝓤 56 | patch-of-Ω = patch-Ω 57 | 58 | \end{code} 59 | -------------------------------------------------------------------------------- /source/Locales/Sierpinski.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K --lossy-unification #-} 4 | 5 | open import UF.FunExt 6 | open import MLTT.Spartan hiding (𝟚) 7 | open import UF.PropTrunc 8 | open import UF.Subsingletons 9 | 10 | module Locales.Sierpinski 11 | (𝓤 : Universe) 12 | (pe : Prop-Ext) 13 | (pt : propositional-truncations-exist) 14 | (fe : Fun-Ext) where 15 | 16 | open import DomainTheory.BasesAndContinuity.Continuity pt fe 𝓤 17 | open import DomainTheory.Basics.Dcpo pt fe 𝓤 hiding (⟨_⟩) 18 | open import DomainTheory.Basics.Pointed pt fe 𝓤 19 | open import DomainTheory.Lifting.LiftingSet pt fe 20 | open import DomainTheory.Lifting.LiftingSetAlgebraic pt pe fe 21 | open import Locales.Frame pt fe hiding (𝟚) 22 | 23 | open import UF.Subsingletons-Properties 24 | 25 | \end{code} 26 | 27 | We first define the Sierpinski domain. 28 | 29 | \begin{code} 30 | 31 | 𝕊-dcpo⁻ : DCPO {𝓤 ⁺} {𝓤 ⁺} 32 | 𝕊-dcpo⁻ = 𝓛-DCPO 𝓤 pe (props-are-sets {X = 𝟙 {𝓤}} 𝟙-is-prop) 33 | 34 | 𝕊-dcpo : DCPO⊥ {𝓤 ⁺} {𝓤 ⁺} 35 | 𝕊-dcpo = 𝓛-DCPO⊥ 𝓤 pe (props-are-sets {X = 𝟙 {𝓤}} 𝟙-is-prop) 36 | 37 | \end{code} 38 | 39 | We then define the Sierpinski locale as the Scott locale of the Sierpinski 40 | domain. 41 | 42 | \begin{code} 43 | 44 | open import Locales.ScottLocale.Definition pt fe 𝓤 45 | 46 | open DefnOfScottLocale (𝕊-dcpo ⁻) 𝓤 pe 47 | open Locale 48 | 49 | 𝕊 : Locale (𝓤 ⁺) (𝓤 ⁺) 𝓤 50 | 𝕊 = ScottLocale 51 | 52 | ⊤𝕊 : ⟨ 𝒪 𝕊 ⟩ 53 | ⊤𝕊 = ⊤ₛ 54 | 55 | 𝕊𝓓-is-algebraic : is-algebraic-dcpo 𝕊-dcpo⁻ 56 | 𝕊𝓓-is-algebraic = 𝓛-is-algebraic-dcpo 𝓤 (props-are-sets {X = 𝟙 {𝓤}} 𝟙-is-prop) 57 | 58 | \end{code} 59 | -------------------------------------------------------------------------------- /source/Locales/Stone.lagda: -------------------------------------------------------------------------------- 1 | Ayberk Tosun, 11 September 2023 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K --lossy-unification #-} 6 | 7 | open import MLTT.Spartan hiding (𝟚) 8 | open import UF.PropTrunc 9 | open import UF.FunExt 10 | open import UF.Size 11 | 12 | module Locales.Stone (pt : propositional-truncations-exist) 13 | (fe : Fun-Ext) 14 | (sr : Set-Replacement pt) where 15 | 16 | \end{code} 17 | 18 | Importation of foundational UF stuff. 19 | 20 | \begin{code} 21 | 22 | open import UF.SubtypeClassifier 23 | open import UF.Logic 24 | 25 | open AllCombinators pt fe 26 | open PropositionalTruncation pt 27 | 28 | \end{code} 29 | 30 | Importations of other locale theory modules. 31 | 32 | \begin{code} 33 | 34 | open import Locales.Frame pt fe 35 | open import Locales.WayBelowRelation.Definition pt fe 36 | open import Locales.Compactness.Definition pt fe 37 | open import Locales.Complements pt fe 38 | open import Locales.GaloisConnection pt fe 39 | open import Locales.InitialFrame pt fe 40 | open import Locales.ZeroDimensionality pt fe sr 41 | 42 | open Locale 43 | 44 | \end{code} 45 | 46 | \begin{code} 47 | 48 | stoneᴰ : (X : Locale 𝓤 𝓥 𝓦) → 𝓤 ⊔ 𝓥 ⊔ 𝓦 ⁺ ̇ 49 | stoneᴰ X = is-compact X holds × zero-dimensionalᴰ (𝒪 X) 50 | 51 | \end{code} 52 | 53 | \begin{code} 54 | 55 | is-stone : (X : Locale 𝓤 𝓥 𝓦) → Ω (𝓤 ⊔ 𝓥 ⊔ 𝓦 ⁺) 56 | is-stone X = is-compact X ∧ is-zero-dimensional (𝒪 X) 57 | 58 | \end{code} 59 | 60 | \begin{code} 61 | 62 | stoneᴰ-implies-stone : (X : Locale 𝓤 𝓥 𝓦) → stoneᴰ X → is-stone X holds 63 | stoneᴰ-implies-stone X σᴰ@(κ , zd) = κ , ∣ zd ∣ 64 | 65 | \end{code} 66 | -------------------------------------------------------------------------------- /source/Locales/WayBelowRelation/Definition.lagda: -------------------------------------------------------------------------------- 1 | Ayberk Tosun, 19 August 2023 2 | 3 | The module contains the definition of the way below relation. 4 | 5 | This used to live in the `CompactRegular` module which is now deprecated and 6 | will be broken down into smaller modules. 7 | 8 | \begin{code}[hide] 9 | 10 | {-# OPTIONS --safe --without-K #-} 11 | 12 | open import UF.PropTrunc 13 | open import UF.FunExt 14 | open import MLTT.Spartan 15 | open import UF.Logic 16 | open import UF.SubtypeClassifier 17 | open import Slice.Family 18 | 19 | module Locales.WayBelowRelation.Definition (pt : propositional-truncations-exist) 20 | (fe : Fun-Ext) where 21 | 22 | open import Locales.Frame pt fe 23 | 24 | open AllCombinators pt fe 25 | 26 | \end{code} 27 | 28 | The way below relation. 29 | 30 | \begin{code} 31 | 32 | way-below : (F : Frame 𝓤 𝓥 𝓦) → ⟨ F ⟩ → ⟨ F ⟩ → Ω (𝓤 ⊔ 𝓥 ⊔ 𝓦 ⁺) 33 | way-below {𝓤 = 𝓤} {𝓦 = 𝓦} F U V = 34 | Ɐ S ꞉ Fam 𝓦 ⟨ F ⟩ , is-directed F S ⇒ 35 | V ≤ (⋁[ F ] S) ⇒ (Ǝ i ꞉ index S , (U ≤ S [ i ]) holds) 36 | where 37 | open PosetNotation (poset-of F) using (_≤_) 38 | 39 | \end{code} 40 | 41 | Given a frame `F`, `_≪[ F ]_` denotes its way below relation. 42 | 43 | \begin{code} 44 | 45 | infix 5 way-below 46 | 47 | syntax way-below F U V = U ≪[ F ] V 48 | 49 | \end{code} 50 | -------------------------------------------------------------------------------- /source/MGS/TypeTopology-Interface.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo. 13th January 2021 2 | 3 | This is to be be able to call the MGS lectures notes code from 4 | TypeTopology. This will grow as the need arises. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module MGS.TypeTopology-Interface where 11 | 12 | open import MLTT.Spartan 13 | open import UF.Base 14 | open import UF.Equiv 15 | 16 | import MGS.Equivalences 17 | import MGS.FunExt-from-Univalence 18 | 19 | MGS-equivs-are-equivs : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } (f : X → Y) 20 | → MGS.Equivalences.is-equiv f 21 | → is-equiv f 22 | MGS-equivs-are-equivs = vv-equivs-are-equivs 23 | 24 | equivs-are-MGS-equivs : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } (f : X → Y) 25 | → is-equiv f 26 | → MGS.Equivalences.is-equiv f 27 | equivs-are-MGS-equivs = equivs-are-vv-equivs 28 | 29 | happly'-is-MGS-happly : {X : 𝓤 ̇ } {A : X → 𝓥 ̇ } (f g : Π A) 30 | → happly' f g ∼ MGS.FunExt-from-Univalence.happly f g 31 | happly'-is-MGS-happly f g refl = refl 32 | 33 | \end{code} 34 | -------------------------------------------------------------------------------- /source/MGS/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 2 | 3 | Modular version of https://github.com/martinescardo/HoTT-UF-Agda-Lecture-Notes 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | module MGS.index where 10 | 11 | import MGS.Basic-UF 12 | import MGS.Choice 13 | import MGS.Classifiers 14 | import MGS.Embeddings 15 | import MGS.Equivalence-Constructions 16 | import MGS.Equivalence-Induction 17 | import MGS.Equivalences 18 | import MGS.FunExt-from-Univalence 19 | import MGS.Function-Graphs 20 | import MGS.HAE 21 | import MGS.MLTT 22 | import MGS.Map-Classifiers 23 | import MGS.More-Exercise-Solutions 24 | import MGS.More-FunExt-Consequences 25 | import MGS.Partial-Functions 26 | import MGS.Powerset 27 | import MGS.Quotient 28 | import MGS.Retracts 29 | import MGS.SIP 30 | import MGS.Size 31 | import MGS.Solved-Exercises 32 | import MGS.Subsingleton-Theorems 33 | import MGS.Subsingleton-Truncation 34 | import MGS.TypeTopology-Interface 35 | import MGS.Unique-Existence 36 | import MGS.Univalence 37 | import MGS.Universe-Lifting 38 | import MGS.Yoneda 39 | import MGS.hlevels 40 | 41 | \end{code} 42 | -------------------------------------------------------------------------------- /source/MLTT/AlternativePlus.lagda: -------------------------------------------------------------------------------- 1 | Alternative of _+_: 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module MLTT.AlternativePlus where 8 | 9 | open import MLTT.Universes 10 | open import MLTT.Two 11 | open import MLTT.Sigma 12 | 13 | _+'_ : 𝓤 ̇ → 𝓤 ̇ → 𝓤 ̇ 14 | X₀ +' X₁ = Σ i ꞉ 𝟚 , 𝟚-cases X₀ X₁ i 15 | 16 | \end{code} 17 | -------------------------------------------------------------------------------- /source/MLTT/Athenian.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} -- 4 | 5 | module MLTT.Athenian where 6 | 7 | open import MLTT.Bool public 8 | open import MLTT.List public 9 | open import MLTT.Maybe public 10 | open import MLTT.Vector public 11 | 12 | \end{code} 13 | -------------------------------------------------------------------------------- /source/MLTT/Empty-Type.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module MLTT.Empty-Type where 6 | 7 | open import MLTT.Universes public 8 | 9 | data 𝟘 {𝓤} : 𝓤 ̇ where 10 | 11 | \end{code} 12 | -------------------------------------------------------------------------------- /source/MLTT/Empty.lagda: -------------------------------------------------------------------------------- 1 | Empty type. 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module MLTT.Empty where 8 | 9 | open import MLTT.Empty-Type public 10 | 11 | \end{code} 12 | 13 | This should be the only use of the () pattern in this development: 14 | 15 | \begin{code} 16 | 17 | 𝟘-induction : {A : 𝟘 {𝓤} → 𝓥 ̇ } → (x : 𝟘) → A x 18 | 𝟘-induction = λ () 19 | 20 | unique-from-𝟘 : {A : 𝓥 ̇ } → 𝟘 {𝓤} → A 21 | unique-from-𝟘 = 𝟘-induction 22 | 23 | 𝟘-elim = unique-from-𝟘 24 | 25 | \end{code} 26 | -------------------------------------------------------------------------------- /source/MLTT/Fin.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} -- 4 | 5 | module MLTT.Fin where 6 | 7 | open import MLTT.Spartan 8 | open import MLTT.List 9 | open import MLTT.Bool 10 | 11 | 12 | data Fin : ℕ → 𝓤₀ ̇ where 13 | 𝟎 : {n : ℕ} → Fin (succ n) 14 | suc : {n : ℕ} → Fin n → Fin (succ n) 15 | 16 | ℕ-to-Fin : (n : ℕ) → Fin (succ n) 17 | ℕ-to-Fin 0 = 𝟎 18 | ℕ-to-Fin (succ n) = suc (ℕ-to-Fin n) 19 | 20 | pattern 𝟏 = suc 𝟎 21 | pattern 𝟐 = suc 𝟏 22 | pattern 𝟑 = suc 𝟐 23 | pattern 𝟒 = suc 𝟑 24 | pattern 𝟓 = suc 𝟒 25 | pattern 𝟔 = suc 𝟓 26 | pattern 𝟕 = suc 𝟔 27 | pattern 𝟖 = suc 𝟕 28 | pattern 𝟗 = suc 𝟖 29 | 30 | list-Fin : (n : ℕ) → List (Fin n) 31 | list-Fin 0 = [] 32 | list-Fin (succ n) = 𝟎 ∷ map suc (list-Fin n) 33 | 34 | list-Fin-correct : (n : ℕ) (i : Fin n) → member i (list-Fin n) 35 | list-Fin-correct (succ n) 𝟎 = in-head 36 | list-Fin-correct (succ n) (suc i) = in-tail g 37 | where 38 | IH : member i (list-Fin n) 39 | IH = list-Fin-correct n i 40 | 41 | g : member (suc i) (map suc (list-Fin n)) 42 | g = member-map suc i (list-Fin n) IH 43 | 44 | Fin-listed : (n : ℕ) → listed (Fin n) 45 | Fin-listed n = list-Fin n , list-Fin-correct n 46 | 47 | Fin-listed⁺ : (n : ℕ) → listed⁺ (Fin (succ n)) 48 | Fin-listed⁺ n = 𝟎 , Fin-listed (succ n) 49 | 50 | Fin-== : {n : ℕ} → Fin n → Fin n → Bool 51 | Fin-== {succ n} (suc x) (suc y) = Fin-== {n} x y 52 | Fin-== {succ n} (suc x) 𝟎 = false 53 | Fin-== {succ n} 𝟎 (suc y) = false 54 | Fin-== {succ n} 𝟎 𝟎 = true 55 | 56 | Fin-refl : {n : ℕ} (x : Fin n) → (Fin-== x x) = true 57 | Fin-refl {succ n} (suc x) = Fin-refl {n} x 58 | Fin-refl {succ n} 𝟎 = refl 59 | 60 | module _ {n : ℕ} where 61 | instance 62 | eqFin : Eq (Fin n) 63 | _==_ {{eqFin}} = Fin-== {n} 64 | ==-refl {{eqFin}} = Fin-refl {n} 65 | 66 | \end{code} 67 | -------------------------------------------------------------------------------- /source/MLTT/Identity-Type.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module MLTT.Identity-Type where 6 | 7 | open import MLTT.Universes 8 | 9 | data _=_ {𝓤} {X : 𝓤 ̇ } : X → X → 𝓤 ̇ where 10 | refl : {x : X} → x = x 11 | 12 | -Id : (X : 𝓤 ̇ ) → X → X → 𝓤 ̇ 13 | -Id X x y = x = y 14 | 15 | syntax -Id X x y = x =[ X ] y 16 | 17 | \end{code} 18 | -------------------------------------------------------------------------------- /source/MLTT/Maybe.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} -- 4 | 5 | module MLTT.Maybe where 6 | 7 | open import MLTT.Spartan 8 | 9 | data Maybe {𝓤 : Universe} (A : 𝓤 ̇ ) : 𝓤 ̇ where 10 | Nothing : Maybe A 11 | Just : A → Maybe A 12 | 13 | {-# BUILTIN MAYBE Maybe #-} 14 | 15 | Just-is-not-Nothing : {A : 𝓤 ̇ } {a : A} → Just a ≠ Nothing 16 | Just-is-not-Nothing () 17 | 18 | Nothing-is-isolated : {A : 𝓤 ̇ } (x : Maybe A) → is-decidable (Nothing = x) 19 | Nothing-is-isolated Nothing = inl refl 20 | Nothing-is-isolated (Just a) = inr (λ (p : Nothing = Just a) → Just-is-not-Nothing (p ⁻¹)) 21 | 22 | Nothing-is-isolated' : {A : 𝓤 ̇ } (x : Maybe A) → is-decidable (x = Nothing) 23 | Nothing-is-isolated' Nothing = inl refl 24 | Nothing-is-isolated' (Just a) = inr Just-is-not-Nothing 25 | 26 | open import UF.DiscreteAndSeparated 27 | open import UF.Equiv 28 | open import UF.EquivalenceExamples 29 | open import UF.Subsingletons 30 | 31 | Nothing-is-h-isolated : {A : 𝓤 ̇ } (x : Maybe A) → is-prop (Nothing = x) 32 | Nothing-is-h-isolated x = isolated-points-are-h-isolated Nothing Nothing-is-isolated 33 | 34 | Nothing-is-h-isolated' : {A : 𝓤 ̇ } (x : Maybe A) → is-prop (x = Nothing) 35 | Nothing-is-h-isolated' x = equiv-to-prop =-flip (Nothing-is-h-isolated x) 36 | 37 | \end{code} 38 | -------------------------------------------------------------------------------- /source/MLTT/Natural-Numbers-Type.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module MLTT.Natural-Numbers-Type where 6 | 7 | data ℕ : Set₀ where 8 | zero : ℕ 9 | succ : ℕ → ℕ 10 | 11 | {-# BUILTIN NATURAL ℕ #-} 12 | 13 | \end{code} 14 | -------------------------------------------------------------------------------- /source/MLTT/NaturalNumbers.lagda: -------------------------------------------------------------------------------- 1 | Natural numbers 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module MLTT.NaturalNumbers where 8 | 9 | open import MLTT.Universes 10 | open import MLTT.Natural-Numbers-Type public 11 | 12 | rec : {X : 𝓤 ̇ } → X → (X → X) → (ℕ → X) 13 | rec x f zero = x 14 | rec x f (succ n) = f(rec x f n) 15 | 16 | _^_ : {X : 𝓤 ̇ } → (X → X) → ℕ → (X → X) 17 | (f ^ n) x = rec x f n 18 | 19 | ℕ-induction : {A : ℕ → 𝓤 ̇ } → A 0 → ((k : ℕ) → A k → A(succ k)) → (n : ℕ) → A n 20 | ℕ-induction base step 0 = base 21 | ℕ-induction base step (succ n) = step n (ℕ-induction base step n) 22 | 23 | \end{code} 24 | -------------------------------------------------------------------------------- /source/MLTT/Pi.lagda: -------------------------------------------------------------------------------- 1 | Pi types. 2 | 3 | Built-in, with the notation (x : X) → A x for Π A. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | module MLTT.Pi where 10 | 11 | open import MLTT.Universes 12 | 13 | Π : {X : 𝓤 ̇ } (Y : X → 𝓥 ̇ ) → 𝓤 ⊔ 𝓥 ̇ 14 | Π {𝓤} {𝓥} {X} Y = (x : X) → Y x 15 | 16 | \end{code} 17 | 18 | We often write Π x ꞉ X , A x for Π A to make X explicit. 19 | 20 | \begin{code} 21 | 22 | Pi : {𝓤 𝓥 : Universe} (X : 𝓤 ̇ ) (Y : X → 𝓥 ̇ ) → 𝓤 ⊔ 𝓥 ̇ 23 | Pi X Y = Π Y 24 | 25 | syntax Pi A (λ x → b) = Π x ꞉ A , b 26 | 27 | infixr -1 Pi 28 | 29 | id : {X : 𝓤 ̇ } → X → X 30 | id x = x 31 | 32 | 𝑖𝑑 : (X : 𝓤 ̇ ) → X → X 33 | 𝑖𝑑 X = id 34 | 35 | _∘_ : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {Z : Y → 𝓦 ̇ } 36 | → ((y : Y) → Z y) 37 | → (f : X → Y) (x : X) → Z (f x) 38 | g ∘ f = λ x → g (f x) 39 | 40 | S-combinator : {X : 𝓤 ̇ } {Y : X → 𝓥 ̇ } {Z : (x : X) → Y x → 𝓦 ̇ } 41 | → ((x : X) (y : Y x) → Z x y) 42 | → (f : (x : X) → Y x) (x : X) → Z x (f x) 43 | S-combinator g f = λ x → g x (f x) 44 | 45 | \end{code} 46 | 47 | The domain and codomain of a function, mainly to avoid implicit 48 | arguments: 49 | 50 | \begin{code} 51 | 52 | domain : {X : 𝓤 ̇ } {Y : X → 𝓥 ̇ } → Π Y → 𝓤 ̇ 53 | domain {𝓤} {𝓥} {X} {Y} f = X 54 | 55 | codomain : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } → (X → Y) → 𝓥 ̇ 56 | codomain {𝓤} {𝓥} {X} {Y} f = Y 57 | 58 | \end{code} 59 | 60 | Fixities: 61 | 62 | \begin{code} 63 | 64 | infixl 5 _∘_ 65 | 66 | \end{code} 67 | -------------------------------------------------------------------------------- /source/MLTT/Plus-Type.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module MLTT.Plus-Type where 6 | 7 | open import MLTT.Universes public 8 | 9 | data _+_ {𝓤 𝓥} (X : 𝓤 ̇ ) (Y : 𝓥 ̇ ) : 𝓤 ⊔ 𝓥 ̇ where 10 | inl : X → X + Y 11 | inr : Y → X + Y 12 | 13 | \end{code} 14 | -------------------------------------------------------------------------------- /source/MLTT/Plus.lagda: -------------------------------------------------------------------------------- 1 | The disjoint sum X + Y of two types X and Y. 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module MLTT.Plus where 8 | 9 | open import MLTT.Plus-Type renaming (_+_ to infixr 1 _+_) public 10 | 11 | dep-cases : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {A : X + Y → 𝓦 ̇ } 12 | → ((x : X) → A (inl x)) 13 | → ((y : Y) → A (inr y)) 14 | → ((z : X + Y) → A z) 15 | dep-cases f g (inl x) = f x 16 | dep-cases f g (inr y) = g y 17 | 18 | cases : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {A : 𝓦 ̇ } → (X → A) → (Y → A) → X + Y → A 19 | cases = dep-cases 20 | 21 | \end{code} 22 | 23 | Sometimes it is useful to have the arguments in a different order: 24 | 25 | \begin{code} 26 | 27 | Cases : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {A : 𝓦 ̇ } → X + Y → (X → A) → (Y → A) → A 28 | Cases z f g = cases f g z 29 | 30 | dep-Cases : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } (A : X + Y → 𝓦 ̇ ) 31 | → (z : X + Y) 32 | → ((x : X) → A (inl x)) 33 | → ((y : Y) → A (inr y)) 34 | → A z 35 | dep-Cases {𝓤} {𝓥} {𝓦} {X} {Y} A z f g = dep-cases {𝓤} {𝓥} {𝓦} {X} {Y} {A} f g z 36 | 37 | \end{code} 38 | 39 | Added 4 March 2020 by Tom de Jong. 40 | 41 | \begin{code} 42 | 43 | dep-cases₃ : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {Z : 𝓦 ̇ } {A : X + Y + Z → 𝓣 ̇ } 44 | → ((x : X) → A (inl x)) 45 | → ((y : Y) → A (inr (inl y))) 46 | → ((z : Z) → A (inr (inr z))) 47 | → ((p : X + Y + Z) → A p) 48 | dep-cases₃ f g h (inl x) = f x 49 | dep-cases₃ f g h (inr (inl y)) = g y 50 | dep-cases₃ f g h (inr (inr z)) = h z 51 | 52 | cases₃ : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {Z : 𝓦 ̇ } {A : 𝓣 ̇ } 53 | → (X → A) → (Y → A) → (Z → A) → X + Y + Z → A 54 | cases₃ = dep-cases₃ 55 | 56 | \end{code} 57 | -------------------------------------------------------------------------------- /source/MLTT/Sigma-Type.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module MLTT.Sigma-Type where 6 | 7 | open import MLTT.Universes 8 | 9 | record Σ {𝓤 𝓥} {X : 𝓤 ̇ } (Y : X → 𝓥 ̇ ) : 𝓤 ⊔ 𝓥 ̇ where 10 | constructor 11 | _,_ 12 | field 13 | pr₁ : X 14 | pr₂ : Y pr₁ 15 | 16 | infixr 50 _,_ 17 | 18 | \end{code} 19 | -------------------------------------------------------------------------------- /source/MLTT/Sigma.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module MLTT.Sigma where 6 | 7 | open import MLTT.Universes 8 | 9 | \end{code} 10 | 11 | Using our conventions below, a sum can be written Σ {X} Y or as 12 | Σ x ꞉ X , Y x, or even Σ λ x → Y x when Agda can infer the type of 13 | the element x from the context. I prefer to use \ rather than λ in 14 | such cases. 15 | 16 | \begin{code} 17 | 18 | open import MLTT.Sigma-Type renaming (_,_ to infixr 4 _,_) public 19 | 20 | open Σ public 21 | 22 | Sigma : {𝓤 𝓥 : Universe} (X : 𝓤 ̇ ) (Y : X → 𝓥 ̇ ) → 𝓤 ⊔ 𝓥 ̇ 23 | Sigma _ Y = Σ Y 24 | 25 | syntax Sigma A (λ x → b) = Σ x ꞉ A , b 26 | 27 | infixr -1 Sigma 28 | 29 | _×_ : 𝓤 ̇ → 𝓥 ̇ → 𝓤 ⊔ 𝓥 ̇ 30 | X × Y = Σ x ꞉ X , Y 31 | 32 | uncurry : {X : 𝓤 ̇ } {Y : X → 𝓥 ̇ } {Z : 𝓦 ̇ } 33 | → ((x : X) → Y x → Z) → Σ Y → Z 34 | uncurry f (x , y) = f x y 35 | 36 | curry : {X : 𝓤 ̇ } {Y : X → 𝓥 ̇ } {Z : 𝓦 ̇ } 37 | → (Σ Y → Z) → ((x : X) → Y x → Z) 38 | curry f x y = f (x , y) 39 | 40 | ×functor : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {A : 𝓦 ̇ } {B : 𝓣 ̇ } 41 | → (X → A) → (Y → B) → X × Y → A × B 42 | ×functor f g (x , y) = f x , g y 43 | 44 | \end{code} 45 | 46 | As usual in type theory, binary products are particular cases of 47 | dependent sums. 48 | 49 | 50 | Fixities: 51 | 52 | \begin{code} 53 | 54 | infixr 2 _×_ 55 | 56 | \end{code} 57 | -------------------------------------------------------------------------------- /source/MLTT/Spartan.lagda: -------------------------------------------------------------------------------- 1 | Our Spartan (intensional) Martin-Löf type theory has the empty type ∅, 2 | the unit type 𝟙, two-point-type 𝟚, natural numbers ℕ, product types Π, 3 | sum types Σ (and hence binary product types _×_), sum types _+_, 4 | identity types _=_, and universes 𝓤, 𝓥, 𝓦, .... 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module MLTT.Spartan where 11 | 12 | open import MLTT.Empty public 13 | open import MLTT.Unit public 14 | open import MLTT.Two public 15 | open import MLTT.NaturalNumbers public 16 | open import MLTT.Plus public 17 | open import MLTT.Pi public 18 | open import MLTT.Sigma public 19 | open import MLTT.Universes public 20 | open import MLTT.Id public 21 | 22 | open import Notation.General public 23 | 24 | \end{code} 25 | -------------------------------------------------------------------------------- /source/MLTT/Two.lagda: -------------------------------------------------------------------------------- 1 | Two-point type. 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module MLTT.Two where 8 | 9 | open import MLTT.Universes 10 | 11 | data 𝟚 : 𝓤₀ ̇ where 12 | ₀ : 𝟚 13 | ₁ : 𝟚 14 | 15 | 𝟚-induction : {A : 𝟚 → 𝓤 ̇ } → A ₀ → A ₁ → (x : 𝟚) → A x 16 | 𝟚-induction r s ₀ = r 17 | 𝟚-induction r s ₁ = s 18 | 19 | 𝟚-cases : {A : 𝓤 ̇ } → A → A → 𝟚 → A 20 | 𝟚-cases = 𝟚-induction 21 | 22 | \end{code} 23 | -------------------------------------------------------------------------------- /source/MLTT/Unit-Properties.lagda: -------------------------------------------------------------------------------- 1 | One-element type properties. 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module MLTT.Unit-Properties where 8 | 9 | open import MLTT.Unit 10 | open import MLTT.Empty 11 | open import MLTT.Id 12 | open import MLTT.Negation 13 | 14 | 𝟙-all-⋆ : (x : 𝟙 {𝓤}) → x = ⋆ 15 | 𝟙-all-⋆ {𝓤} ⋆ = refl {𝓤} 16 | 𝟙-is-not-𝟘 : 𝟙 ≠ 𝟘 17 | 𝟙-is-not-𝟘 p = transport (λ X → X) p ⋆ 18 | 19 | \end{code} 20 | -------------------------------------------------------------------------------- /source/MLTT/Unit-Type.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module MLTT.Unit-Type where 6 | 7 | open import MLTT.Universes public 8 | 9 | data 𝟙 {𝓤} : 𝓤 ̇ where 10 | ⋆ : 𝟙 11 | 12 | \end{code} 13 | -------------------------------------------------------------------------------- /source/MLTT/Unit.lagda: -------------------------------------------------------------------------------- 1 | One element type. 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module MLTT.Unit where 8 | 9 | open import MLTT.Universes 10 | 11 | record 𝟙 {𝓤} : 𝓤 ̇ where 12 | constructor 13 | ⋆ 14 | 15 | open 𝟙 public 16 | 17 | unique-to-𝟙 : {A : 𝓤 ̇ } → A → 𝟙 {𝓥} 18 | unique-to-𝟙 {𝓤} {𝓥} a = ⋆ {𝓥} 19 | 20 | \end{code} 21 | -------------------------------------------------------------------------------- /source/MLTT/Vector.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module MLTT.Vector where 6 | 7 | open import MLTT.Spartan 8 | open import MLTT.Fin 9 | open import MLTT.Bool 10 | 11 | data Vector (A : 𝓤 ̇ ) : ℕ → 𝓤 ̇ where 12 | [] : Vector A 0 13 | _∷_ : {n : ℕ} → A → Vector A n → Vector A (succ n) 14 | 15 | head : {A : 𝓤 ̇ } {n : ℕ} → Vector A (succ n) → A 16 | head (x ∷ xs) = x 17 | 18 | tail : {A : 𝓤 ̇ } {n : ℕ} → Vector A (succ n) → Vector A n 19 | tail (x ∷ xs) = xs 20 | 21 | _!!_ : {X : 𝓤 ̇ } {n : ℕ} → Vector X n → Fin n → X 22 | (x ∷ xs) !! 𝟎 = x 23 | (x ∷ xs) !! suc n = xs !! n 24 | 25 | vmap : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } 26 | → (X → Y) 27 | → {n : ℕ} → Vector X n → Vector Y n 28 | vmap f [] = [] 29 | vmap f (x ∷ xs) = f x ∷ vmap f xs 30 | 31 | 32 | module vector-util 33 | {𝓤 : Universe} 34 | {X : 𝓤 ̇ } 35 | {{_ : Eq X}} 36 | where 37 | 38 | data _is-in_ : X → {n : ℕ} → Vector X n → 𝓤 ̇ where 39 | in-head : {x : X} {n : ℕ} {xs : Vector X n} → x is-in (x ∷ xs) 40 | in-tail : {x y : X} {n : ℕ} {xs : Vector X n} → x is-in xs → x is-in (y ∷ xs) 41 | 42 | insert : X → {n : ℕ} → Vector X n → Vector X (succ n) 43 | insert x xs = x ∷ xs 44 | 45 | remove : (x : X) {n : ℕ} 46 | (xs : Vector X (succ n)) 47 | → x is-in xs 48 | → Vector X n 49 | remove x {0} (_ ∷ []) in-head = [] 50 | remove x {succ n} (_ ∷ xs) in-head = xs 51 | remove x {succ n} (y ∷ xs) (in-tail p) = y ∷ remove x {n} xs p 52 | 53 | has-no-repetitions : {n : ℕ} → Vector X n → 𝓤 ̇ 54 | has-no-repetitions [] = 𝟙 55 | has-no-repetitions (x ∷ xs) = ¬ (x is-in xs) × has-no-repetitions xs 56 | 57 | \end{code} 58 | -------------------------------------------------------------------------------- /source/MLTT/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module MLTT.index where 8 | 9 | import MLTT.AlternativePlus 10 | import MLTT.Athenian 11 | import MLTT.Bool 12 | import MLTT.Empty 13 | import MLTT.Empty-Type 14 | import MLTT.Fin 15 | import MLTT.Id 16 | import MLTT.Identity-Type 17 | import MLTT.List 18 | import MLTT.List-Properties 19 | import MLTT.Natural-Numbers-Type 20 | import MLTT.NaturalNumbers 21 | import MLTT.Negation 22 | import MLTT.Pi 23 | import MLTT.Plus 24 | import MLTT.Plus-Properties 25 | import MLTT.Plus-Type 26 | import MLTT.Sigma 27 | import MLTT.Sigma-Type 28 | import MLTT.Spartan 29 | import MLTT.SpartanList 30 | import MLTT.Two 31 | import MLTT.Two-Properties 32 | import MLTT.Unit 33 | import MLTT.Unit-Properties 34 | import MLTT.Unit-Type 35 | import MLTT.Universes 36 | import MLTT.Vector 37 | 38 | \end{code} 39 | -------------------------------------------------------------------------------- /source/MetricSpaces/index.lagda: -------------------------------------------------------------------------------- 1 | Andrew Sneap 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module MetricSpaces.index where 8 | 9 | import MetricSpaces.Type 10 | import MetricSpaces.DedekindReals 11 | import MetricSpaces.Rationals 12 | 13 | \end{code} 14 | -------------------------------------------------------------------------------- /source/Modal/index.lagda: -------------------------------------------------------------------------------- 1 | Jon Sterling, 6 Oct 2022 2 | 3 | The following modules develop the theory of reflective subuniverses, roughly 4 | following the following papers: 5 | 6 | - Rijke, Shulman, and Spitters. "Modalities in homotopy type theory". https://doi.org/10.23638/LMCS-16(1:2)2020 7 | - Rijke. "Classifying Types: Topics in synthetic homotopy theory". PhD thesis. https://arxiv.org/abs/1906.09435 8 | 9 | \begin{code} 10 | 11 | {-# OPTIONS --safe --without-K #-} 12 | 13 | module Modal.index where 14 | 15 | import Modal.Open 16 | import Modal.Subuniverse 17 | import Modal.ReflectiveSubuniverse 18 | import Modal.SigmaClosedReflectiveSubuniverse 19 | import Modal.Homotopy 20 | 21 | \end{code} 22 | -------------------------------------------------------------------------------- /source/MonadOnTypes/J.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, Paulo Oliva, 2023 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | open import MLTT.Spartan hiding (J) 8 | 9 | module MonadOnTypes.J where 10 | 11 | open import UF.FunExt 12 | open import MonadOnTypes.Monad 13 | 14 | 𝕁 : Type → Monad 15 | 𝕁 R = record { 16 | functor = λ X → (X → R) → X ; 17 | η = λ x p → x ; 18 | ext = λ f ε p → f (ε (λ x → p (f x p))) p ; 19 | ext-η = λ ε → refl ; 20 | unit = λ f x → refl ; 21 | assoc = λ g f x → refl 22 | } 23 | 24 | module J-definitions (R : Type) where 25 | 26 | J : Type → Type 27 | J = functor (𝕁 R) 28 | 29 | _⊗ᴶ_ : {X : Type} {Y : X → Type} 30 | → J X 31 | → ((x : X) → J (Y x)) 32 | → J (Σ x ꞉ X , Y x) 33 | _⊗ᴶ_ = _⊗_ (𝕁 R) 34 | 35 | ⊗ᴶ-direct-definition : {X : Type} {Y : X → Type} 36 | (ε : J X) 37 | (δ : (x : X) → J (Y x)) 38 | → ε ⊗ᴶ δ ∼ (λ q → let 39 | ν = λ x → δ x (curry q x) 40 | x₀ = ε (λ x → curry q x (ν x)) 41 | in (x₀ , ν x₀)) 42 | ⊗ᴶ-direct-definition ε δ q = refl 43 | 44 | ηᴶ : {X : Type} → X → J X 45 | ηᴶ = η (𝕁 R) 46 | 47 | extᴶ : {X Y : Type} → (X → J Y) → J X → J Y 48 | extᴶ = ext (𝕁 R) 49 | 50 | mapᴶ : {X Y : Type} → (X → Y) → J X → J Y 51 | mapᴶ = map (𝕁 R) 52 | -------------------------------------------------------------------------------- /source/MonadOnTypes/JK.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, Paulo Oliva, 2023 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | open import MLTT.Spartan hiding (J) 8 | 9 | module MonadOnTypes.JK where 10 | 11 | open import MonadOnTypes.J 12 | open import MonadOnTypes.K 13 | 14 | module JK (R : Type) where 15 | 16 | open J-definitions R 17 | open K-definitions R 18 | 19 | overline : {X : Type} → J X → K X 20 | overline ε = λ p → p (ε p) 21 | 22 | overline-theorem : {X : Type} {Y : X → Type} 23 | (ε : J X) (δ : (x : X) → J (Y x)) 24 | → overline (ε ⊗ᴶ δ) ∼ overline ε ⊗ᴷ (λ x → overline (δ x)) 25 | overline-theorem ε δ q = refl 26 | 27 | _attains_ : {X : Type} → J X → K X → Type 28 | ε attains ϕ = overline ε ∼ ϕ 29 | 30 | \end{code} 31 | 32 | TODO. Show that overline is a monad morphism. 33 | 34 | TODO. Define also the above for the J and K monad transformers, maybe 35 | in this file, maybe in another file. 36 | -------------------------------------------------------------------------------- /source/MonadOnTypes/K.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, Paulo Oliva, 2023 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | open import MLTT.Spartan hiding (J) 8 | 9 | module MonadOnTypes.K where 10 | 11 | open import MonadOnTypes.Monad 12 | 13 | 𝕂 : Type → Monad 14 | 𝕂 R = record { 15 | functor = λ X → (X → R) → R ; 16 | η = λ x p → p x ; 17 | ext = λ f ϕ p → ϕ (λ x → f x p) ; 18 | ext-η = λ x → refl ; 19 | unit = λ f x → refl ; 20 | assoc = λ g f x → refl 21 | } 22 | 23 | module K-definitions (R : Type) where 24 | 25 | K : Type → Type 26 | K = functor (𝕂 R) 27 | 28 | _⊗ᴷ_ : {X : Type} {Y : X → Type} 29 | → K X 30 | → ((x : X) → K (Y x)) 31 | → K (Σ x ꞉ X , Y x) 32 | _⊗ᴷ_ = _⊗_ (𝕂 R) 33 | 34 | ⊗ᴷ-direct-definition : {X : Type} {Y : X → Type} 35 | (ϕ : K X) 36 | (γ : (x : X) → K (Y x)) 37 | → ϕ ⊗ᴷ γ ∼ (λ q → ϕ (λ x → γ x (curry q x))) 38 | ⊗ᴷ-direct-definition ϕ γ q = refl 39 | 40 | ηᴷ : {X : Type} → X → K X 41 | ηᴷ = η (𝕂 R) 42 | 43 | extᴷ : {X Y : Type} → (X → K Y) → K X → K Y 44 | extᴷ = ext (𝕂 R) 45 | 46 | mapᴷ : {X Y : Type} → (X → Y) → K X → K Y 47 | mapᴷ = map (𝕂 R) 48 | 49 | \end{code} 50 | -------------------------------------------------------------------------------- /source/MonadOnTypes/List.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, Paulo Oliva, 2024 2 | 3 | The list monad. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | module MonadOnTypes.List where 10 | 11 | open import MonadOnTypes.Monad 12 | open import MLTT.Spartan hiding (J) 13 | open import MLTT.List hiding (map) 14 | 15 | 𝕃 : Monad 16 | 𝕃 = record { 17 | functor = List ; 18 | η = [_] ; 19 | ext = List-ext ; 20 | ext-η = concat-singletons ; 21 | unit = List-ext-unit ; 22 | assoc = List-ext-assoc 23 | } 24 | 25 | module List-definitions where 26 | 27 | _⊗ᴸ_ : {X : Type} {Y : X → Type} 28 | → List X 29 | → ((x : X) → List (Y x)) 30 | → List (Σ x ꞉ X , Y x) 31 | _⊗ᴸ_ = _⊗_ 𝕃 32 | 33 | ηᴸ : {X : Type} → X → List X 34 | ηᴸ = η 𝕃 35 | 36 | extᴸ : {X Y : Type} → (X → List Y) → List X → List Y 37 | extᴸ = ext 𝕃 38 | 39 | mapᴸ : {X Y : Type} → (X → Y) → List X → List Y 40 | mapᴸ = map 𝕃 41 | 42 | \end{code} 43 | -------------------------------------------------------------------------------- /source/MonadOnTypes/Reader.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, Paulo Oliva, 2023 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | open import MLTT.Spartan hiding (J) 8 | 9 | module MonadOnTypes.Reader where 10 | 11 | open import MonadOnTypes.Monad 12 | 13 | Reader : Type → Monad 14 | Reader A = record { 15 | functor = λ X → A → X ; 16 | η = λ x _ → x ; 17 | ext = λ f ρ a → f (ρ a) a ; 18 | ext-η = λ x → refl ; 19 | unit = λ f x → refl ; 20 | assoc = λ g f x → refl 21 | } 22 | 23 | \end{code} 24 | -------------------------------------------------------------------------------- /source/MonadOnTypes/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo and Paulo Oliva, 2023-2024 2 | 3 | 4 | \begin{code} 5 | 6 | {-# OPTIONS --safe --without-K #-} 7 | 8 | module MonadOnTypes.index where 9 | 10 | import MonadOnTypes.J -- Selection monad. 11 | import MonadOnTypes.J-transf -- A selection monad transformer. 12 | import MonadOnTypes.J-transf-variation -- Another selection monad transformer. 13 | import MonadOnTypes.K -- Continuation (or quantifier) monad. 14 | import MonadOnTypes.JK -- Relationship between the two mondas. 15 | import MonadOnTypes.Monad -- (Automatically strong, wild) monads on types. 16 | import MonadOnTypes.Reader -- Reader monad. 17 | import MonadOnTypes.List -- List monad. 18 | import MonadOnTypes.NonEmptyList -- Non-empty list monad. 19 | import MonadOnTypes.NonEmptyListOriginal -- Non-empty list monad, original version. 20 | 21 | \end{code} 22 | -------------------------------------------------------------------------------- /source/MonadOnTypesMGU/JK.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, Paulo Oliva, originally 2023, with universes 2 | generalized in March 2024. 3 | 4 | \begin{code} 5 | 6 | {-# OPTIONS --safe --without-K --no-level-universe #-} 7 | 8 | open import MLTT.Spartan hiding (J) 9 | 10 | module MonadOnTypesMGU.JK where 11 | 12 | open import MonadOnTypesMGU.J 13 | open import MonadOnTypesMGU.K 14 | 15 | private 16 | variable 17 | 𝓦₀ : Universe 18 | 19 | module JK (R : 𝓦₀ ̇ ) where 20 | 21 | open J-definitions R 22 | open K-definitions R 23 | 24 | overline : {X : 𝓤 ̇ } → J X → K X 25 | overline ε = λ p → p (ε p) 26 | 27 | overline-theorem : {X : 𝓤 ̇ } {Y : X → 𝓥 ̇ } 28 | (ε : J X) (δ : (x : X) → J (Y x)) 29 | → overline (ε ⊗ᴶ δ) ∼ overline ε ⊗ᴷ (λ x → overline (δ x)) 30 | overline-theorem ε δ q = refl 31 | 32 | _attains_ : {X : 𝓤 ̇ } → J X → K X → 𝓦₀ ⊔ 𝓤 ̇ 33 | ε attains ϕ = overline ε ∼ ϕ 34 | 35 | \end{code} 36 | 37 | TODO. Show that overline is a monad morphism. 38 | 39 | TODO. Define also the above for the J and K monad transformers, maybe 40 | in this file, maybe in another file. 41 | -------------------------------------------------------------------------------- /source/MonadOnTypesMGU/K.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, Paulo Oliva, originally 2023, with universes 2 | generalized in March 2024. 3 | 4 | \begin{code} 5 | 6 | {-# OPTIONS --safe --without-K --no-level-universe #-} 7 | 8 | open import MLTT.Spartan hiding (J) 9 | 10 | module MonadOnTypesMGU.K where 11 | 12 | open import MonadOnTypesMGU.Monad 13 | 14 | private 15 | variable 16 | 𝓦₀ : Universe 17 | 18 | 𝕂 : 𝓦₀ ̇ → Monad 19 | 𝕂 {𝓦₀} R = record { 20 | ℓ = λ 𝓤 → 𝓤 ⊔ 𝓦₀ ; 21 | functor = λ X → (X → R) → R ; 22 | η = λ x p → p x ; 23 | ext = λ f ϕ p → ϕ (λ x → f x p) ; 24 | ext-η = λ x → refl ; 25 | unit = λ f x → refl ; 26 | assoc = λ g f x → refl 27 | } 28 | 29 | module K-definitions (R : 𝓦₀ ̇ ) where 30 | 31 | K : 𝓤 ̇ → 𝓦₀ ⊔ 𝓤 ̇ 32 | K = functor (𝕂 R) 33 | 34 | _⊗ᴷ_ : {X : 𝓤 ̇ } {Y : X → 𝓥 ̇ } 35 | → K X 36 | → ((x : X) → K (Y x)) 37 | → K (Σ x ꞉ X , Y x) 38 | _⊗ᴷ_ = _⊗_ (𝕂 R) 39 | 40 | ⊗ᴷ-direct-definition : {X : 𝓤 ̇ } {Y : X → 𝓥 ̇ } 41 | (ϕ : K X) 42 | (γ : (x : X) → K (Y x)) 43 | → ϕ ⊗ᴷ γ ∼ (λ q → ϕ (λ x → γ x (curry q x))) 44 | ⊗ᴷ-direct-definition ϕ γ q = refl 45 | 46 | ηᴷ : {X : 𝓤 ̇ } → X → K X 47 | ηᴷ = η (𝕂 R) 48 | 49 | extᴷ : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } → (X → K Y) → K X → K Y 50 | extᴷ = ext (𝕂 R) 51 | 52 | mapᴷ : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } → (X → Y) → K X → K Y 53 | mapᴷ = map (𝕂 R) 54 | 55 | \end{code} 56 | -------------------------------------------------------------------------------- /source/MonadOnTypesMGU/Reader.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, Paulo Oliva, originally 2023, with universes 2 | generalized in March 2024. 3 | 4 | \begin{code} 5 | 6 | {-# OPTIONS --safe --without-K --no-level-universe #-} 7 | 8 | open import MLTT.Spartan hiding (J) 9 | 10 | module MonadOnTypesMGU.Reader where 11 | 12 | open import MonadOnTypesMGU.Monad 13 | 14 | Reader : {𝓦₀ : Universe} → 𝓦₀ ̇ → Monad 15 | Reader {𝓦₀} A = record { 16 | ℓ = λ 𝓤 → 𝓤 ⊔ 𝓦₀ ; 17 | functor = λ X → A → X ; 18 | η = λ x _ → x ; 19 | ext = λ f ρ a → f (ρ a) a ; 20 | ext-η = λ x → refl ; 21 | unit = λ f x → refl ; 22 | assoc = λ g f x → refl 23 | } 24 | 25 | \end{code} 26 | -------------------------------------------------------------------------------- /source/MonadOnTypesMGU/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo and Paulo Oliva, originally 2-27 July 2021, with the 2 | generalization performed in March 2024. 3 | 4 | Same as MonadOnTypes but with more general universes (MGU), and also 5 | using the flag no-level-universe, so that we can have a type X in a 6 | universe 𝓤 with T X in a universe ℓ 𝓤. For example, for the list 7 | monad, we have ℓ 𝓤 = 𝓤, but for the powerset monad we have ℓ 𝓤 = 𝓤⁺. 8 | 9 | \begin{code} 10 | 11 | {-# OPTIONS --safe --without-K --no-level-universe #-} 12 | 13 | module MonadOnTypesMGU.index where 14 | 15 | import MonadOnTypesMGU.J -- Selection monad. 16 | import MonadOnTypesMGU.K -- Continuation (or quantifier) monad. 17 | import MonadOnTypesMGU.JK -- Relationship between the two mondas. 18 | import MonadOnTypesMGU.Monad -- (Automatically strong, wild) monads on suitable types. 19 | import MonadOnTypesMGU.Reader 20 | import MonadOnTypesMGU.NonEmptyList 21 | 22 | \end{code} 23 | -------------------------------------------------------------------------------- /source/Naturals/Exponentiation.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | open import MLTT.Spartan renaming (_+_ to _∔_) 6 | open import Naturals.Addition 7 | open import Naturals.Properties 8 | open import Naturals.Multiplication 9 | 10 | module Naturals.Exponentiation where 11 | 12 | _ℕ^_ : ℕ → ℕ → ℕ 13 | a ℕ^ b = ((a *_) ^ b) 1 14 | 15 | infixl 33 _ℕ^_ 16 | 17 | 2^ : ℕ → ℕ 18 | 2^ = 2 ℕ^_ 19 | 20 | zero-base : (a : ℕ) → a ℕ^ 0 = 1 21 | zero-base a = refl 22 | 23 | prod-of-powers : (n a b : ℕ) → (n ℕ^ a) * (n ℕ^ b) = n ℕ^ (a + b) 24 | prod-of-powers n a 0 = refl 25 | prod-of-powers n a (succ b) = I 26 | where 27 | I : (n ℕ^ a) * (n ℕ^ succ b) = (n ℕ^ (a + succ b)) 28 | I = (n ℕ^ a) * (n ℕ^ succ b) =⟨ refl ⟩ 29 | (n ℕ^ a) * (n * (n ℕ^ b)) =⟨ i ⟩ 30 | (n ℕ^ a) * n * (n ℕ^ b) =⟨ ii ⟩ 31 | n * n ℕ^ a * n ℕ^ b =⟨ iii ⟩ 32 | n * (n ℕ^ a * n ℕ^ b) =⟨ iv ⟩ 33 | n ℕ^ (a + succ b) ∎ 34 | where 35 | i = mult-associativity (n ℕ^ a) n (n ℕ^ b) ⁻¹ 36 | ii = ap (_* (n ℕ^ b)) (mult-commutativity (n ℕ^ a) n) 37 | iii = mult-associativity n (n ℕ^ a) (n ℕ^ b) 38 | iv = ap (n *_) (prod-of-powers n a b) 39 | 40 | power-of-power : (n a b : ℕ) → (n ℕ^ a) ℕ^ b = n ℕ^ (a * b) 41 | power-of-power n a 0 = refl 42 | power-of-power n a (succ b) = I 43 | where 44 | IH : n ℕ^ a ℕ^ b = n ℕ^ (a * b) 45 | IH = power-of-power n a b 46 | I : n ℕ^ a ℕ^ succ b = n ℕ^ (a * succ b) 47 | I = n ℕ^ a ℕ^ succ b =⟨ refl ⟩ 48 | n ℕ^ a * (n ℕ^ a) ℕ^ b =⟨ ap (n ℕ^ a *_) IH ⟩ 49 | n ℕ^ a * n ℕ^ (a * b) =⟨ prod-of-powers n a (a * b) ⟩ 50 | n ℕ^ (a + a * b) =⟨ refl ⟩ 51 | n ℕ^ (a * succ b) ∎ 52 | 53 | exponents-not-zero : (n : ℕ) → ¬ (2^ n = 0) 54 | exponents-not-zero 0 e = positive-not-zero 0 e 55 | exponents-not-zero (succ n) e = exponents-not-zero n I 56 | where 57 | I : 2^ n = 0 58 | I = mult-left-cancellable (2^ n) 0 1 e 59 | 60 | \end{code} 61 | -------------------------------------------------------------------------------- /source/Naturals/index.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module Naturals.index where 6 | 7 | import Naturals.AbsoluteDifference 8 | import Naturals.Addition 9 | import Naturals.Binary 10 | import Naturals.Division 11 | import Naturals.ExitTruncation 12 | import Naturals.Exponentiation 13 | import Naturals.HCF 14 | import Naturals.Multiplication 15 | import Naturals.Order 16 | import Naturals.Parity 17 | import Naturals.Properties 18 | import Naturals.RootsTruncation 19 | import Naturals.Sequence 20 | import Naturals.UniversalProperty 21 | 22 | \end{code} 23 | -------------------------------------------------------------------------------- /source/Notation/CanonicalMap.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 1st January 2022 2 | 3 | Type-class for notation for canonical maps. Our convention here is 4 | that a canonical map is something we decide to call a canonical map. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module Notation.CanonicalMap where 11 | 12 | open import MLTT.Spartan 13 | 14 | record Canonical-Map {𝓤} {𝓥} (X : 𝓤 ̇ ) (Y : 𝓥 ̇ ) : 𝓤 ⊔ 𝓥 ̇ where 15 | field 16 | ι : X → Y 17 | 18 | open Canonical-Map {{...}} public 19 | 20 | canonical-map : (X : 𝓤 ̇ ) (Y : 𝓥 ̇ ) → {{_ : Canonical-Map X Y}} → X → Y 21 | canonical-map X Y = ι 22 | 23 | [_] : {X : 𝓤 ̇ } {Y : 𝓥 ̇ } {{r : Canonical-Map X Y}} → X → Y 24 | [_] = ι 25 | 26 | \end{code} 27 | -------------------------------------------------------------------------------- /source/Notation/Decimal.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 12th September 2024 2 | 3 | This file provides an interface to implement automatic converscxion of 4 | decimal literals to types other than just the natural numbers. 5 | 6 | See https://agda.readthedocs.io/en/latest/language/literal-overloading.html 7 | 8 | \begin{code} 9 | 10 | {-# OPTIONS --safe --without-K #-} 11 | 12 | module Notation.Decimal where 13 | 14 | open import MLTT.Universes 15 | open import MLTT.NaturalNumbers 16 | 17 | record Decimal {𝓤 𝓥 : Universe} (A : 𝓤 ̇ ) : 𝓤 ⊔ 𝓥 ⁺ ̇ where 18 | field 19 | constraint : ℕ → 𝓥 ̇ 20 | fromℕ : (n : ℕ) {{_ : constraint n}} → A 21 | 22 | open Decimal {{...}} public using (fromℕ) 23 | 24 | {-# BUILTIN FROMNAT fromℕ #-} 25 | {-# DISPLAY Decimal.fromℕ _ n = fromℕ n #-} 26 | 27 | record Negative {𝓤 𝓥 : Universe} (A : 𝓤 ̇ ) : 𝓤 ⊔ 𝓥 ⁺ ̇ where 28 | field 29 | constraint : ℕ → 𝓥 ̇ 30 | fromNeg : (n : ℕ) {{_ : constraint n}} → A 31 | 32 | open Negative {{...}} public using (fromNeg) 33 | 34 | {-# BUILTIN FROMNEG fromNeg #-} 35 | {-# DISPLAY Negative.fromNeg _ n = fromNeg n #-} 36 | 37 | data No-Constraint : 𝓤₀ ̇ where 38 | no-constraint : No-Constraint 39 | 40 | instance 41 | really-no-constraint : No-Constraint 42 | really-no-constraint = no-constraint 43 | 44 | make-decimal-with-no-constraint 45 | : {A : 𝓤 ̇ } 46 | → ((n : ℕ) {{_ : No-Constraint}} → A) 47 | → Decimal A 48 | make-decimal-with-no-constraint f = 49 | record { 50 | constraint = λ _ → No-Constraint 51 | ; fromℕ = f 52 | } 53 | 54 | make-negative-with-no-constraint 55 | : {A : 𝓤 ̇ } 56 | → ((n : ℕ) {{_ : No-Constraint}} → A) 57 | → Negative A 58 | make-negative-with-no-constraint f = 59 | record { 60 | constraint = λ _ → No-Constraint 61 | ; fromNeg = f 62 | } 63 | 64 | \end{code} 65 | 66 | The natural place for this would be MLTT.NaturalNumbers, but then we 67 | would get a circular dependency. 68 | 69 | \begin{code} 70 | 71 | instance 72 | Decimal-ℕ-to-ℕ : Decimal ℕ 73 | Decimal-ℕ-to-ℕ = make-decimal-with-no-constraint (λ n → n) 74 | 75 | \end{code} 76 | -------------------------------------------------------------------------------- /source/Notation/UnderlyingType.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 6th May 2022 2 | 3 | Type-class for notation for underlying things. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | module Notation.UnderlyingType where 10 | 11 | open import MLTT.Spartan 12 | 13 | record Underlying-Type {𝓤} {𝓥} (X : 𝓤 ̇ ) (Y : 𝓥 ̇ ) : 𝓤 ⊔ 𝓥 ⁺ ̇ where 14 | field 15 | ⟨_⟩ : X → Y 16 | 17 | open Underlying-Type {{...}} public 18 | 19 | \end{code} 20 | -------------------------------------------------------------------------------- /source/Notation/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module Notation.index where 8 | 9 | import Notation.CanonicalMap 10 | import Notation.General 11 | import Notation.Order 12 | import Notation.UnderlyingType 13 | 14 | \end{code} 15 | -------------------------------------------------------------------------------- /source/NotionsOfDecidability/index.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module NotionsOfDecidability.index where 6 | 7 | import NotionsOfDecidability.Complemented -- by Martin Escardo 8 | import NotionsOfDecidability.Decidable -- by Martin Escardo 9 | import NotionsOfDecidability.DecidableClassifier -- by Tom de Jong 10 | import NotionsOfDecidability.Digression -- by Martin Escardo 11 | import NotionsOfDecidability.QuasiDecidable -- by Martin Escardo 12 | import NotionsOfDecidability.SemiDecidable -- by Tom de Jong 13 | 14 | \end{code} 15 | -------------------------------------------------------------------------------- /source/OrderedTypes/TwoElementPoset.lagda: -------------------------------------------------------------------------------- 1 | Ian Ray, 9 August 2023 updated 11 January 2024. 2 | 3 | Constructing the two element poset. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K --exact-split #-} 8 | 9 | open import MLTT.Spartan 10 | open import UF.FunExt 11 | open import UF.PropTrunc 12 | 13 | open import UF.Subsingletons 14 | open import UF.SubtypeClassifier 15 | 16 | module OrderedTypes.TwoElementPoset 17 | (pt : propositional-truncations-exist) 18 | (fe : Fun-Ext) 19 | where 20 | 21 | open import Locales.Frame pt fe hiding (𝟚; ₀; ₁) 22 | 23 | 2-Poset : Poset 𝓤₀ 𝓤₀ 24 | 2-Poset = (𝟚 , 2-ord , 2-ord-is-partial-order) 25 | where 26 | 2-ord : 𝟚 → 𝟚 → Ω 𝓤₀ 27 | 2-ord ₀ x = (𝟙 , 𝟙-is-prop) 28 | 2-ord ₁ ₀ = (𝟘 , 𝟘-is-prop) 29 | 2-ord ₁ ₁ = (𝟙 , 𝟙-is-prop) 30 | 31 | 2-ord-is-partial-order : is-partial-order 𝟚 2-ord 32 | 2-ord-is-partial-order = (2-ord-is-preorder , 2-ord-is-antisymmetric) 33 | where 34 | 2-ord-is-preorder : is-preorder 2-ord holds 35 | 2-ord-is-preorder = (2-ord-is-reflexive , 2-ord-is-transitive) 36 | where 37 | 2-ord-is-reflexive : is-reflexive 2-ord holds 38 | 2-ord-is-reflexive ₀ = ⋆ 39 | 2-ord-is-reflexive ₁ = ⋆ 40 | 41 | 2-ord-is-transitive : is-transitive 2-ord holds 42 | 2-ord-is-transitive ₀ y z p q = ⋆ 43 | 2-ord-is-transitive ₁ ₁ ₁ p q = ⋆ 44 | 45 | 2-ord-is-antisymmetric : is-antisymmetric 2-ord 46 | 2-ord-is-antisymmetric {₀} {₀} p q = refl 47 | 2-ord-is-antisymmetric {₁} {₁} p q = refl 48 | 49 | \end{code} 50 | -------------------------------------------------------------------------------- /source/OrderedTypes/index.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module OrderedTypes.index where 6 | 7 | import OrderedTypes.DeltaCompletePoset -- by Ian Ray 8 | import OrderedTypes.Frame -- by Martin Escardo 9 | import OrderedTypes.FreeJoinSemiLattice -- by Tom de Jong 10 | import OrderedTypes.FreeSupLattice -- by Tom de Jong 11 | import OrderedTypes.JoinSemiLattices -- by Tom de Jong 12 | import OrderedTypes.Poset -- by Tom de Jong 13 | import OrderedTypes.PosetReflection -- by Tom de Jong 14 | import OrderedTypes.PredicativeLFP -- by Ian Ray 15 | import OrderedTypes.sigma-frame -- by Martin Escardo 16 | import OrderedTypes.sigma-sup-lattice -- by Martin Escardo 17 | import OrderedTypes.SupLattice -- by Ian Ray 18 | import OrderedTypes.SupLattice-SmallBasis -- by Ian Ray 19 | import OrderedTypes.TwoElementPoset -- by Ian Ray 20 | import OrderedTypes.ZornsLemma -- by Kelton OBrien 21 | 22 | \end{code} 23 | -------------------------------------------------------------------------------- /source/Ordinals/Brouwer.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 2 | 3 | Brouwer ordinal codes. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | module Ordinals.Brouwer where 10 | 11 | open import MLTT.Spartan 12 | 13 | data B : 𝓤₀ ̇ where 14 | Z : B 15 | S : B → B 16 | L : (ℕ → B) → B 17 | 18 | \end{code} 19 | -------------------------------------------------------------------------------- /source/Ordinals/Fin.lagda: -------------------------------------------------------------------------------- 1 | Alice Laroche, 25th September 2023 2 | 3 | Fin n is an ordinal 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | module Ordinals.Fin where 10 | 11 | open import Fin.Embeddings 12 | open import Fin.Type 13 | open import MLTT.Spartan 14 | open import Notation.Order 15 | open import Ordinals.Type 16 | open import Ordinals.Notions 17 | 18 | import Naturals.Order as ℕ 19 | 20 | <-is-prop-valued : (n : ℕ) → is-prop-valued {X = Fin n} _<_ 21 | <-is-prop-valued n i j = ℕ.<-is-prop-valued ⟦ i ⟧ ⟦ j ⟧ 22 | 23 | <-is-well-founded : (n : ℕ) → is-well-founded {X = Fin n} _<_ 24 | <-is-well-founded n i = recurs (ℕ.<-is-well-founded (⟦ i ⟧)) 25 | where 26 | recurs : {i : Fin n} 27 | → is-accessible {X = ℕ} _<_ (⟦ i ⟧) 28 | → is-accessible {X = Fin n} _<_ i 29 | recurs (acc rec₁) = acc (λ j r → recurs (rec₁ ⟦ j ⟧ r)) 30 | 31 | <-is-extensional : (n : ℕ) → is-extensional {X = Fin n} _<_ 32 | <-is-extensional (succ n) 𝟎 𝟎 i≼j j≼i = refl 33 | <-is-extensional (succ n) 𝟎 (suc x) i≼j j≼i = 𝟘-elim (j≼i 𝟎 ⋆) 34 | <-is-extensional (succ n) (suc i) 𝟎 i≼j j≼i = 𝟘-elim (i≼j 𝟎 ⋆) 35 | <-is-extensional (succ n) (suc i) (suc j) i≼j j≼i = 36 | ap suc (<-is-extensional n i j (i≼j ∘ suc) (j≼i ∘ suc)) 37 | 38 | <-trans : (n : ℕ) → is-transitive {X = Fin n} _<_ 39 | <-trans n i j k = ℕ.<-trans ⟦ i ⟧ ⟦ j ⟧ ⟦ k ⟧ 40 | 41 | <-is-well-order : (n : ℕ) → is-well-order {X = Fin n} _<_ 42 | <-is-well-order n = <-is-prop-valued n 43 | , <-is-well-founded n 44 | , <-is-extensional n 45 | , <-trans n 46 | 47 | Fin-ordinal : (n : ℕ) → Ord 48 | Fin-ordinal n = Fin n , _<_ , <-is-well-order n 49 | 50 | \end{code} 51 | -------------------------------------------------------------------------------- /source/Ordinals/Indecomposable.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, 25th August 2022, with additions 31st July. 2 | 3 | Written down in Agda 27th August 2022 while travelling back from 4 | Thierry Coquand's 60th birthday celebration. 5 | 6 | The type of ordinals is decomposable as a disjoint union of two 7 | pointed types if and only if weak excluded middle holds (every negated 8 | proposition is decidable, which is equivalent to De Morgan's Law). 9 | 10 | This file has been moved to the following location: 11 | 12 | \begin{code} 13 | 14 | {-# OPTIONS --safe --without-K #-} 15 | 16 | module Ordinals.Indecomposable where 17 | 18 | import Taboos.Decomposability 19 | 20 | \end{code} 21 | -------------------------------------------------------------------------------- /source/Ordinals/InfProperty.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 20-21 December 2012 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | open import MLTT.Spartan 8 | open import MLTT.Two-Properties 9 | open import TypeTopology.CompactTypes 10 | 11 | module Ordinals.InfProperty {𝓤 𝓥} {X : 𝓤 ̇ } (_≤_ : X → X → 𝓥 ̇ ) where 12 | 13 | is-conditional-root : (X → 𝟚) → X → 𝓤 ̇ 14 | is-conditional-root p x₀ = (Σ x ꞉ X , p x = ₀) → p x₀ = ₀ 15 | 16 | is-roots-lower-bound : (X → 𝟚) → X → 𝓤 ⊔ 𝓥 ̇ 17 | is-roots-lower-bound p l = (x : X) → p x = ₀ → l ≤ x 18 | 19 | is-upper-bound-of-lower-bounds : (X → 𝟚) → X → 𝓤 ⊔ 𝓥 ̇ 20 | is-upper-bound-of-lower-bounds p u = (l : X) → is-roots-lower-bound p l → l ≤ u 21 | 22 | is-roots-infimum : (X → 𝟚) → X → 𝓤 ⊔ 𝓥 ̇ 23 | is-roots-infimum p x = is-roots-lower-bound p x 24 | × is-upper-bound-of-lower-bounds p x 25 | 26 | has-inf : 𝓤 ⊔ 𝓥 ̇ 27 | has-inf = (p : X → 𝟚) → Σ x ꞉ X , is-conditional-root p x × is-roots-infimum p x 28 | 29 | has-inf-gives-compact∙ : has-inf → is-compact∙ X 30 | has-inf-gives-compact∙ h p = f (h p) 31 | where 32 | f : (Σ x₀ ꞉ X , is-conditional-root p x₀ × is-roots-infimum p x₀) 33 | → (Σ x₀ ꞉ X , (p x₀ = ₁ → (x : X) → p x = ₁)) 34 | f (x₀ , g , _) = (x₀ , k) 35 | where 36 | g' : p x₀ ≠ ₀ → ¬ (Σ x ꞉ X , p x = ₀) 37 | g' = contrapositive g 38 | 39 | u : ¬ (Σ x ꞉ X , p x = ₀) → (x : X) → p x = ₁ 40 | u ν x = different-from-₀-equal-₁ (λ (e : p x = ₀) → ν (x , e)) 41 | 42 | k : p x₀ = ₁ → (x : X) → p x = ₁ 43 | k e = u (g' (equal-₁-different-from-₀ e)) 44 | 45 | has-inf-gives-compact : has-inf → is-compact X 46 | has-inf-gives-compact = compact∙-types-are-compact ∘ has-inf-gives-compact∙ 47 | 48 | has-inf-gives-Compact : {𝓦 : Universe} → has-inf → is-Compact X {𝓦} 49 | has-inf-gives-Compact = compact-types-are-Compact ∘ has-inf-gives-compact 50 | 51 | \end{code} 52 | -------------------------------------------------------------------------------- /source/Ordinals/NotationInterpretation.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, 2012, 2018, 2022. 2 | 3 | See the various imported files for discussion, starting from 4 | OrdinalNotationInterpretation1. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module Ordinals.NotationInterpretation where 11 | 12 | import Ordinals.NotationInterpretation0 -- Brouwer codes (2022) 13 | import Ordinals.NotationInterpretation1 -- Variation of Brouwer codes (2018) 14 | import Ordinals.NotationInterpretation2 -- Inductive-recursive extension of 1 (2022) 15 | 16 | \end{code} 17 | -------------------------------------------------------------------------------- /source/Ordinals/TrichotomousArithmetic.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, 6th May 2022 2 | 3 | Arithmetic for trichotomous ordinals. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | open import UF.FunExt 10 | 11 | module Ordinals.TrichotomousArithmetic 12 | (fe : FunExt) 13 | where 14 | 15 | 16 | open import MLTT.Spartan 17 | open import Notation.CanonicalMap 18 | open import Ordinals.Type 19 | open import Ordinals.Notions 20 | open import Ordinals.Arithmetic fe 21 | open import Ordinals.WellOrderArithmetic 22 | open import Ordinals.TrichotomousType fe 23 | open import Ordinals.Underlying 24 | 25 | _+₃_ : Ordinal₃ 𝓤 → Ordinal₃ 𝓤 → Ordinal₃ 𝓤 26 | τ +₃ υ = ([ τ ] +ₒ [ υ ]) , +ₒ-is-trichotomous [ τ ] [ υ ] 27 | (3is-trichotomous τ) 28 | (3is-trichotomous υ) 29 | 30 | 𝟘₃ 𝟙₃ 𝟚₃ : Ordinal₃ 𝓤 31 | 𝟘₃ = 𝟘ₒ , 𝟘ₒ-is-trichotomous 32 | 𝟙₃ = 𝟙ₒ , 𝟙ₒ-is-trichotomous 33 | 𝟚₃ = 𝟙₃ +₃ 𝟙₃ 34 | 35 | ω₃ : Ordinal₃ 𝓤₀ 36 | ω₃ = ω , ω-is-trichotomous 37 | 38 | ∑³ : (τ : Ordinal₃ 𝓤) → (⟨ τ ⟩ → Ordinal₃ 𝓤) → Ordinal₃ 𝓤 39 | ∑³ {𝓤} (α@(X , _<_ , o) , t) υ = ((Σ x ꞉ X , ⟨ υ x ⟩) , 40 | Sum.order , 41 | Sum.well-order o (λ x → 3is-well-ordered (υ x))) , 42 | sum.trichotomy-preservation _ _ t (λ x → 3is-trichotomous (υ x)) 43 | where 44 | _≺_ : {x : X} → ⟨ υ x ⟩ → ⟨ υ x ⟩ → 𝓤 ̇ 45 | y ≺ z = y ≺⟨ υ _ ⟩ z 46 | 47 | module Sum = sum-cotransitive fe _<_ _≺_ (tricho-gives-cotrans _<_ (Transitivity α) t) 48 | 49 | _×₃_ : Ordinal₃ 𝓤 → Ordinal₃ 𝓤 → Ordinal₃ 𝓤 50 | τ ×₃ υ = ∑³ τ (λ (_ : ⟨ τ ⟩) → υ) 51 | 52 | \end{code} 53 | -------------------------------------------------------------------------------- /source/Ordinals/TrichotomousType.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo, 3rd May 2022 2 | 3 | The subtype Ordinal₃ 𝓤 of Ordinal 𝓤 consisting of trichotomous ordinals. 4 | 5 | \begin{code} 6 | 7 | {-# OPTIONS --safe --without-K #-} 8 | 9 | open import UF.FunExt 10 | 11 | module Ordinals.TrichotomousType 12 | (fe : FunExt) 13 | where 14 | 15 | open import MLTT.Spartan 16 | open import Notation.CanonicalMap 17 | open import Ordinals.Notions 18 | open import Ordinals.Type 19 | open import Ordinals.Underlying 20 | open import UF.Sets 21 | open import UF.Subsingletons 22 | 23 | Ordinal₃ : ∀ 𝓤 → 𝓤 ⁺ ̇ 24 | Ordinal₃ 𝓤 = Σ α ꞉ Ordinal 𝓤 , is-trichotomous-order (underlying-order α) 25 | 26 | instance 27 | canonical-map-Ordinal₃-Ordinal : Canonical-Map (Ordinal₃ 𝓤) (Ordinal 𝓤) 28 | ι {{canonical-map-Ordinal₃-Ordinal}} (α , _) = α 29 | 30 | instance 31 | underlying-type-of-3-ordinal : Underlying (Ordinal₃ 𝓤) 32 | ⟨_⟩ {{underlying-type-of-3-ordinal}} (α , _) = ⟨ α ⟩ 33 | underlying-order {{underlying-type-of-3-ordinal}} (α , _) = underlying-order α 34 | 35 | 36 | underlying-type-is-set₃ : FunExt 37 | → (β : Ordinal₃ 𝓤) 38 | → is-set ⟨ β ⟩ 39 | underlying-type-is-set₃ fe (α , t) = underlying-type-is-set fe α 40 | 41 | \end{code} 42 | 43 | Topped ordinals are ranged over by τ,υ. 44 | 45 | \begin{code} 46 | 47 | ≼-prop-valued : (τ : Ordinal₃ 𝓤) (x y : ⟨ τ ⟩) → is-prop (x ≼⟨ τ ⟩ y) 48 | ≼-prop-valued {𝓤} τ = extensional-po-is-prop-valued (underlying-order τ) fe 49 | (Prop-valuedness [ τ ]) 50 | 51 | 3is-well-ordered : (τ : Ordinal₃ 𝓤) → is-well-order (underlying-order τ) 52 | 3is-well-ordered ((X , _<_ , o) , t) = o 53 | 54 | 3is-trichotomous : (τ : Ordinal₃ 𝓤) → is-trichotomous-order (underlying-order τ) 55 | 3is-trichotomous ((X , _<_ , o) , t) = t 56 | 57 | \end{code} 58 | -------------------------------------------------------------------------------- /source/Ordinals/Underlying.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 3rd January 2023 2 | 3 | Type-class for notation for underlying set and order of various kinds 4 | of ordinals. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module Ordinals.Underlying where 11 | 12 | open import MLTT.Spartan 13 | open import Ordinals.Notions 14 | 15 | record Underlying {𝓤} (O : 𝓤 ⁺ ̇ ) : 𝓤 ⁺ ̇ where 16 | field 17 | ⟨_⟩ : O → 𝓤 ̇ 18 | underlying-order : (α : O) → ⟨ α ⟩ → ⟨ α ⟩ → 𝓤 ̇ 19 | 20 | underlying-weak-order : (α : O) → ⟨ α ⟩ → ⟨ α ⟩ → 𝓤 ̇ 21 | underlying-weak-order α x y = ¬ (underlying-order α y x) 22 | 23 | underlying-porder : (α : O) → ⟨ α ⟩ → ⟨ α ⟩ → 𝓤 ̇ 24 | underlying-porder α = extensional-po (underlying-order α) 25 | 26 | syntax underlying-order α x y = x ≺⟨ α ⟩ y 27 | syntax underlying-weak-order α x y = x ≾⟨ α ⟩ y 28 | syntax underlying-porder α x y = x ≼⟨ α ⟩ y 29 | 30 | open Underlying {{...}} public 31 | 32 | \end{code} 33 | -------------------------------------------------------------------------------- /source/Ordinals/index.lagda: -------------------------------------------------------------------------------- 1 | Martin Escardo 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module Ordinals.index where 8 | 9 | import Ordinals.Arithmetic 10 | import Ordinals.AdditionProperties 11 | import Ordinals.Brouwer 12 | import Ordinals.BuraliForti -- by [1] 13 | import Ordinals.Closure 14 | import Ordinals.Codes 15 | import Ordinals.ConvergentSequence 16 | import Ordinals.CumulativeHierarchy -- by [2] 17 | import Ordinals.CumulativeHierarchy-Addendum -- by [2] 18 | import Ordinals.Equivalence 19 | import Ordinals.Exponentiation.index -- by [2] 20 | import Ordinals.Indecomposable 21 | import Ordinals.InfProperty 22 | import Ordinals.Injectivity 23 | import Ordinals.LexicographicCompactness 24 | import Ordinals.LexicographicOrder 25 | import Ordinals.Limit 26 | import Ordinals.Maps 27 | import Ordinals.MultiplicationProperties -- by [2] 28 | import Ordinals.NotationInterpretation 29 | import Ordinals.NotationInterpretation0 30 | import Ordinals.NotationInterpretation1 31 | import Ordinals.NotationInterpretation2 32 | import Ordinals.Notions 33 | import Ordinals.OrdinalOfOrdinals 34 | import Ordinals.OrdinalOfOrdinalsSuprema -- by [3] 35 | import Ordinals.OrdinalOfTruthValues 36 | import Ordinals.Propositions 37 | import Ordinals.ShulmanTaboo 38 | import Ordinals.SupSum 39 | import Ordinals.Taboos -- by [3] 40 | import Ordinals.ToppedArithmetic 41 | import Ordinals.ToppedType 42 | import Ordinals.TrichotomousArithmetic 43 | import Ordinals.TrichotomousType 44 | import Ordinals.Type 45 | import Ordinals.Underlying 46 | import Ordinals.WellOrderArithmetic 47 | import Ordinals.WellOrderTransport 48 | import Ordinals.WellOrderingPrinciple 49 | import Ordinals.WellOrderingTaboo -- by [4] 50 | 51 | \end{code} 52 | 53 | [1] Bezem, Coquand, Dybjer and Escardo. 54 | [2] de Jong, Kraus, Nordvall Forsberg, and Xu. 55 | [3] Tom de Jong 56 | [4] Tom de Jong (after Andrew Swan) 57 | -------------------------------------------------------------------------------- /source/PCF/Combinatory/index.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | module PCF.Combinatory.index where 8 | 9 | import PCF.Combinatory.PCF 10 | import PCF.Combinatory.PCFCombinators 11 | import PCF.Combinatory.ScottModelOfPCF 12 | 13 | \end{code} 14 | -------------------------------------------------------------------------------- /source/PCF/Lambda/ApplicativeApproximation.lagda: -------------------------------------------------------------------------------- 1 | Brendan Hart 2019-2020 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | open import MLTT.Spartan 8 | open import UF.PropTrunc 9 | 10 | module PCF.Lambda.ApplicativeApproximation 11 | (pt : propositional-truncations-exist) 12 | where 13 | 14 | open PropositionalTruncation pt 15 | 16 | open import PCF.Lambda.AbstractSyntax pt 17 | open import PCF.Lambda.BigStep pt 18 | 19 | _⊏̰_ : {σ : type} → PCF ⟨⟩ σ → PCF ⟨⟩ σ → 𝓤₀ ̇ 20 | _⊏̰_ {ι} M N = (n : ℕ) → M ⇓ numeral n → N ⇓ numeral n 21 | _⊏̰_ {σ ⇒ σ₁} M N = (P : PCF ⟨⟩ σ) → (M · P) ⊏̰ (N · P) 22 | 23 | ⊏̰-reflexive : {σ : type} → (M : PCF ⟨⟩ σ) → M ⊏̰ M 24 | ⊏̰-reflexive {ι} M = λ n x → x 25 | ⊏̰-reflexive {σ ⇒ σ₁} M = λ P → ⊏̰-reflexive (M · P) 26 | 27 | ⊏̰-transitive : {σ : type} {M N L : PCF ⟨⟩ σ} → M ⊏̰ N → N ⊏̰ L → M ⊏̰ L 28 | ⊏̰-transitive {ι} {M} {N} {L} p₁ p₂ n step = γ 29 | where 30 | γ : L ⇓ numeral n 31 | γ = p₂ n (p₁ n step) 32 | 33 | ⊏̰-transitive {σ ⇒ σ₁} {M} {N} {L} p₁ p₂ P = γ 34 | where 35 | γ : (M · P) ⊏̰ (L · P) 36 | γ = ⊏̰-transitive (p₁ P) (p₂ P) 37 | 38 | ⊏̰-lemma : {σ : type} (M M' : PCF ⟨⟩ σ) 39 | → ((V : PCF ⟨⟩ σ) → M ⇓' V → M' ⇓' V) 40 | → M ⊏̰ M' 41 | ⊏̰-lemma {ι} M M' f n x = ∥∥-functor (λ x₁ → f (numeral n) x₁) x 42 | ⊏̰-lemma {σ ⇒ τ} M M' f P = ⊏̰-lemma (M · P) (M' · P) γ 43 | where 44 | γ : (V : PCF ⟨⟩ τ) → (M · P) ⇓' V → (M' · P) ⇓' V 45 | γ V (·-step {_} {_} {_} {_} {_} {E} x x₁) = ·-step M'-step x₁ 46 | where 47 | M'-step : M' ⇓' ƛ E 48 | M'-step = f (ƛ E) x 49 | 50 | β-⊏̰ : {σ τ : type} {M : PCF (⟨⟩ ’ σ) τ} {N : PCF ⟨⟩ σ} 51 | → (M [ N ]) ⊏̰ (ƛ M · N) 52 | β-⊏̰ {σ} {τ} {M} {N} = ⊏̰-lemma (M [ N ]) (ƛ M · N) (λ V x → ·-step ƛ-id x) 53 | 54 | fix-⊏̰ : {σ : type} {M : PCF ⟨⟩ (σ ⇒ σ)} → (M · (Fix M)) ⊏̰ (Fix M) 55 | fix-⊏̰ {σ} {M} = ⊏̰-lemma (M · Fix M) (Fix M) (λ V x → Fix-step x) 56 | 57 | \end{code} 58 | -------------------------------------------------------------------------------- /source/PCF/Lambda/ScottModelOfIfZero.lagda: -------------------------------------------------------------------------------- 1 | Brendan Hart 2019-2020 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | open import MLTT.Spartan 8 | open import UF.FunExt 9 | open import UF.PropTrunc 10 | open import UF.Subsingletons 11 | 12 | module PCF.Lambda.ScottModelOfIfZero 13 | (pt : propositional-truncations-exist) 14 | (fe : ∀ {𝓤 𝓥} → funext 𝓤 𝓥) 15 | (pe : propext 𝓤₀) 16 | where 17 | 18 | open PropositionalTruncation pt 19 | 20 | open import DomainTheory.Basics.Curry pt fe 𝓤₀ 21 | open import DomainTheory.Basics.Exponential pt fe 𝓤₀ 22 | open import DomainTheory.Basics.FunctionComposition pt fe 𝓤₀ 23 | open import DomainTheory.Basics.Pointed pt fe 𝓤₀ 24 | open import DomainTheory.Basics.Products pt fe 25 | open import PCF.Combinatory.PCFCombinators pt fe 𝓤₀ 26 | open import PCF.Lambda.AbstractSyntax pt 27 | open import PCF.Lambda.ScottModelOfContexts pt fe pe 28 | 29 | open DcpoProductsGeneral 𝓤₀ 30 | open IfZeroDenotationalSemantics pe 31 | 32 | 33 | ⦅ifZero⦆-uncurried' : DCPO⊥[ 𝓛ᵈℕ ×ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ , 𝓛ᵈℕ ⟹ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ ] 34 | ⦅ifZero⦆-uncurried' = uncurryᵈᶜᵖᵒ⊥ 𝓛ᵈℕ 𝓛ᵈℕ (𝓛ᵈℕ ⟹ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ) ⦅ifZero⦆ 35 | 36 | ⦅ifZero⦆-uncurried : DCPO⊥[ (𝓛ᵈℕ ×ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ) ×ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ , 𝓛ᵈℕ ] 37 | ⦅ifZero⦆-uncurried = uncurryᵈᶜᵖᵒ⊥ (𝓛ᵈℕ ×ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ) 𝓛ᵈℕ 𝓛ᵈℕ ⦅ifZero⦆-uncurried' 38 | 39 | module _ {n : ℕ} (Γ : Context n) where 40 | 41 | ⦅ifZero⦆-arguments : DCPO⊥[ 【 Γ 】 , 𝓛ᵈℕ ] 42 | → DCPO⊥[ 【 Γ 】 , 𝓛ᵈℕ ] 43 | → DCPO⊥[ 【 Γ 】 , 𝓛ᵈℕ ] 44 | → DCPO⊥[ 【 Γ 】 , (𝓛ᵈℕ ×ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ) ×ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ ] 45 | ⦅ifZero⦆-arguments a b c = to-×-DCPO⊥ 【 Γ 】 (𝓛ᵈℕ ×ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ) 𝓛ᵈℕ f c 46 | where 47 | f : DCPO⊥[ 【 Γ 】 , 𝓛ᵈℕ ×ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ ] 48 | f = to-×-DCPO⊥ 【 Γ 】 𝓛ᵈℕ 𝓛ᵈℕ a b 49 | 50 | ⦅ifZero⦆Γ : DCPO⊥[ 【 Γ 】 , 𝓛ᵈℕ ] 51 | → DCPO⊥[ 【 Γ 】 , 𝓛ᵈℕ ] 52 | → DCPO⊥[ 【 Γ 】 , 𝓛ᵈℕ ] 53 | → DCPO⊥[ 【 Γ 】 , 𝓛ᵈℕ ] 54 | ⦅ifZero⦆Γ a b c = [ 【 Γ 】 , (𝓛ᵈℕ ×ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ) ×ᵈᶜᵖᵒ⊥ 𝓛ᵈℕ , 𝓛ᵈℕ ] 55 | ⦅ifZero⦆-uncurried ∘ᵈᶜᵖᵒ⊥ (⦅ifZero⦆-arguments a b c) 56 | \end{code} 57 | -------------------------------------------------------------------------------- /source/PCF/Lambda/ScottModelOfTypes.lagda: -------------------------------------------------------------------------------- 1 | Brendan Hart 2019-2020 2 | 3 | \begin{code} 4 | 5 | {-# OPTIONS --safe --without-K #-} 6 | 7 | open import MLTT.Spartan 8 | open import UF.FunExt 9 | open import UF.PropTrunc 10 | open import UF.Subsingletons 11 | 12 | module PCF.Lambda.ScottModelOfTypes 13 | (pt : propositional-truncations-exist) 14 | (fe : ∀ {𝓤 𝓥} → funext 𝓤 𝓥) 15 | (pe : propext 𝓤₀) 16 | where 17 | 18 | open import DomainTheory.Basics.Exponential pt fe 𝓤₀ 19 | open import DomainTheory.Basics.Pointed pt fe 𝓤₀ 20 | open import DomainTheory.Lifting.LiftingSet pt fe 𝓤₀ pe 21 | open import PCF.Lambda.AbstractSyntax pt 22 | open import UF.DiscreteAndSeparated 23 | 24 | ℕ⊥ : DCPO⊥ 25 | ℕ⊥ = 𝓛-DCPO⊥ ℕ-is-set 26 | 27 | ⟦_⟧ : type → DCPO⊥ {𝓤₁} {𝓤₁} 28 | ⟦ ι ⟧ = ℕ⊥ 29 | ⟦ σ ⇒ τ ⟧ = ⟦ σ ⟧ ⟹ᵈᶜᵖᵒ⊥ ⟦ τ ⟧ 30 | 31 | \end{code} 32 | -------------------------------------------------------------------------------- /source/PCF/Lambda/index.lagda: -------------------------------------------------------------------------------- 1 | Brendan Hart 2019-2020 2 | 3 | Ported from https://github.com/BrendanHart/Investigating-Properties-of-PCF/ 4 | by Martin Escardo, 17-18 May 2023. This is Brendan's final-year UG 5 | project at the School of Computer Science, University of Birmingham, 6 | UK, jointly supervised by Martin Escardo and Tom de Jong. 7 | 8 | Tom de Jong, in work reported in this repository, defines the Scott 9 | model of PCF in the combinary version of PCF. Brendan extends the 10 | work to the usual λ-calculus version of PCF. Moreover, Tom proved, in 11 | Unimath, that the Scott model of (combinatory) PCF is computationally 12 | adequate. Brendan's work also proves this, in Agda, here, for the 13 | λ-calculus version. In order to do all this, Brendan also had to 14 | extend Tom's work on domain theory. 15 | 16 | A full report in pdf is available in the above link. 17 | 18 | \begin{code} 19 | 20 | {-# OPTIONS --safe --without-K #-} 21 | 22 | module PCF.Lambda.index where 23 | 24 | import DomainTheory.Basics.Curry 25 | import DomainTheory.Basics.FunctionComposition 26 | import DomainTheory.Basics.Products 27 | import DomainTheory.Basics.ProductsContinuity 28 | import PCF.Lambda.AbstractSyntax 29 | import PCF.Lambda.Adequacy 30 | import PCF.Lambda.ApplicativeApproximation 31 | import PCF.Lambda.BigStep 32 | import PCF.Lambda.Correctness 33 | import PCF.Lambda.ScottModelOfContexts 34 | import PCF.Lambda.ScottModelOfIfZero 35 | import PCF.Lambda.ScottModelOfTerms 36 | import PCF.Lambda.ScottModelOfTypes 37 | import PCF.Lambda.Substitution 38 | import PCF.Lambda.SubstitutionDenotational 39 | 40 | \end{code} 41 | -------------------------------------------------------------------------------- /source/PCF/index.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module PCF.index where 6 | 7 | import PCF.Combinatory.index -- By Tom de Jong 8 | import PCF.Lambda.index -- By Brendan Hart 9 | 10 | \end{code} 11 | -------------------------------------------------------------------------------- /source/PathSequences/index.lagda: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | Path Sequences library 3 | 4 | Ettore Aldrovandi, ealdrovandi@fsu.edu 5 | 6 | Begun November 2022 7 | October 2023 8 | -------------------------------------------------------------------------------- 9 | 10 | This is a port of the PathSeq path manipulation library found in the 11 | HoTT-Agda library at https://github.com/HoTT/HoTT-Agda 12 | 13 | 14 | \begin{code} 15 | 16 | {-# OPTIONS --without-K --safe --auto-inline #-} 17 | 18 | module PathSequences.index where 19 | 20 | import PathSequences.Type 21 | import PathSequences.Concat 22 | import PathSequences.Split 23 | import PathSequences.Reasoning 24 | import PathSequences.Ap 25 | import PathSequences.Inversion 26 | import PathSequences.Rotations 27 | import PathSequences.Cancel 28 | 29 | \end{code} 30 | -------------------------------------------------------------------------------- /source/Quotient/GivesPropTrunc.lagda: -------------------------------------------------------------------------------- 1 | Tom de Jong, 4 & 5 April 2022. 2 | 3 | Assuming set quotients, we derive propositional truncations in the 4 | presence of function extensionality. 5 | 6 | \begin{code} 7 | 8 | {-# OPTIONS --safe --without-K #-} 9 | 10 | module Quotient.GivesPropTrunc where 11 | 12 | open import MLTT.Spartan 13 | 14 | open import Quotient.Type 15 | 16 | open import UF.FunExt 17 | open import UF.PropTrunc 18 | open import UF.Subsingletons 19 | open import UF.Subsingletons-FunExt 20 | open import UF.Subsingletons-Properties 21 | 22 | module _ (sq : set-quotients-exist) where 23 | 24 | open general-set-quotients-exist sq 25 | 26 | private 27 | module _ {X : 𝓤 ̇ } where 28 | _≈_ : X → X → 𝓤₀ ̇ 29 | x ≈ y = 𝟙 30 | ≋ : EqRel X 31 | ≋ = _≈_ , (λ x y → 𝟙-is-prop) , (λ x → ⋆) , (λ x y _ → ⋆) , (λ x y z _ _ → ⋆) 32 | 33 | ∥_∥ : 𝓤 ̇ → 𝓤 ̇ 34 | ∥_∥ X = X / ≋ 35 | 36 | ∣_∣ : {X : 𝓤 ̇ } → X → ∥ X ∥ 37 | ∣_∣ = η/ ≋ 38 | 39 | ∥∥-is-prop : {X : 𝓤 ̇ } → funext 𝓤 𝓤 → is-prop ∥ X ∥ 40 | ∥∥-is-prop {𝓤} {X} fe = /-induction ≋ (λ x' → Π-is-prop fe (λ y' → /-is-set ≋)) 41 | (λ x → /-induction ≋ (λ y' → /-is-set ≋) 42 | (λ y → η/-identifies-related-points ≋ ⋆)) 43 | 44 | ∥∥-rec : {X : 𝓤 ̇ } {P : 𝓥 ̇ } → is-prop P → (X → P) → ∥ X ∥ → P 45 | ∥∥-rec {𝓤} {𝓥} {X} {P} i f = 46 | ∃!-witness (/-universality ≋ (props-are-sets i) f 47 | (λ {x} {x'}_ → i (f x) (f x'))) 48 | 49 | abstract 50 | propositional-truncations-from-set-quotients : 51 | Fun-Ext → propositional-truncations-exist 52 | propositional-truncations-from-set-quotients fe = record 53 | { ∥_∥ = ∥_∥ 54 | ; ∥∥-is-prop = ∥∥-is-prop fe 55 | ; ∣_∣ = ∣_∣ 56 | ; ∥∥-rec = ∥∥-rec 57 | } 58 | 59 | \end{code} 60 | -------------------------------------------------------------------------------- /source/Quotient/index.lagda: -------------------------------------------------------------------------------- 1 | \begin{code} 2 | 3 | {-# OPTIONS --safe --without-K #-} 4 | 5 | module Quotient.index where 6 | 7 | import Quotient.Type 8 | import Quotient.Large 9 | import Quotient.FromSetReplacement 10 | import Quotient.GivesSetReplacement 11 | import Quotient.GivesPropTrunc 12 | import Quotient.Effectivity 13 | import Quotient.Large-Variation 14 | 15 | \end{code} 16 | 17 | * Type 18 | 19 | Defines the existence of small quotients type and its basic theory. 20 | 21 | * Large 22 | 23 | Constructs large, effective quotients from propositional 24 | truncations, function extensionality and propositional 25 | extensionality. 26 | 27 | * FromSetReplacement 28 | 29 | Resizes down the above large quotients using set replacement to 30 | construct an element of the above type. 31 | 32 | * GivesSetReplacement 33 | 34 | Derives set replacement from quotients. 35 | 36 | * GivesPropTrunc 37 | 38 | Constructs propositional truncations from quotients and function 39 | extensionality. 40 | 41 | * Effectivity 42 | 43 | Shows that all quotients are effective. 44 | 45 | * Large-Variation 46 | 47 | Adds a parameter to the large quotients module to control the 48 | universe where propositional truncation lives. 49 | -------------------------------------------------------------------------------- /source/Rationals/Positive.lagda: -------------------------------------------------------------------------------- 1 | Andrew Sneap 2 | 3 | This file defines positive rationals, which are useful for metric spaces. 4 | 5 | \begin{code} 6 | {-# OPTIONS --safe --without-K #-} 7 | 8 | open import MLTT.Spartan renaming (_+_ to _∔_) 9 | open import Notation.Order 10 | open import Rationals.Type 11 | open import Rationals.Addition renaming (_+_ to _ℚ+_) 12 | open import Rationals.Multiplication renaming (_*_ to _ℚ*_) 13 | open import Rationals.Order 14 | 15 | module Rationals.Positive where 16 | 17 | ℚ₊ : 𝓤₀ ̇ 18 | ℚ₊ = Σ q ꞉ ℚ , 0ℚ < q 19 | 20 | _<ℚ₊_ : (p q : ℚ₊) → 𝓤₀ ̇ 21 | (p , _) <ℚ₊ (q , _) = p < q 22 | 23 | _≤ℚ₊_ : (p q : ℚ₊) → 𝓤₀ ̇ 24 | (p , _) ≤ℚ₊ (q , _) = p ≤ q 25 | 26 | instance 27 | Strict-Order-ℚ₊-ℚ₊ : Strict-Order ℚ₊ ℚ₊ 28 | _<_ {{Strict-Order-ℚ₊-ℚ₊}} = _<ℚ₊_ 29 | 30 | Order-ℚ₊-ℚ₊ : Order ℚ₊ ℚ₊ 31 | _≤_ {{Order-ℚ₊-ℚ₊}} = _≤ℚ₊_ 32 | 33 | Strict-Order-ℚ₊-ℚ : Strict-Order ℚ₊ ℚ 34 | _<_ {{Strict-Order-ℚ₊-ℚ}} (p , _) q = p < q 35 | 36 | Strict-Order-ℚ-ℚ₊ : Strict-Order ℚ ℚ₊ 37 | _<_ {{Strict-Order-ℚ-ℚ₊}} p (q , _) = p < q 38 | 39 | _+_ : ℚ₊ → ℚ₊ → ℚ₊ 40 | (p , 0