bsc-leon-vatthauer/public/Relation.Nullary.Decidable.html

65 lines
No EOL
18 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML>
<html><head><meta charset="utf-8"><title>Relation.Nullary.Decidable</title><link rel="stylesheet" href="Agda.css"></head><body><pre class="Agda"><a id="1" class="Comment">------------------------------------------------------------------------</a>
<a id="74" class="Comment">-- The Agda standard library</a>
<a id="103" class="Comment">--</a>
<a id="106" class="Comment">-- Operations on and properties of decidable relations</a>
<a id="161" class="Comment">------------------------------------------------------------------------</a>
<a id="235" class="Symbol">{-#</a> <a id="239" class="Keyword">OPTIONS</a> <a id="247" class="Pragma">--cubical-compatible</a> <a id="268" class="Pragma">--safe</a> <a id="275" class="Symbol">#-}</a>
<a id="280" class="Keyword">module</a> <a id="287" href="Relation.Nullary.Decidable.html" class="Module">Relation.Nullary.Decidable</a> <a id="314" class="Keyword">where</a>
<a id="321" class="Keyword">open</a> <a id="326" class="Keyword">import</a> <a id="333" href="Level.html" class="Module">Level</a> <a id="339" class="Keyword">using</a> <a id="345" class="Symbol">(</a><a id="346" href="Agda.Primitive.html#591" class="Postulate">Level</a><a id="351" class="Symbol">)</a>
<a id="353" class="Keyword">open</a> <a id="358" class="Keyword">import</a> <a id="365" href="Data.Bool.Base.html" class="Module">Data.Bool.Base</a> <a id="380" class="Keyword">using</a> <a id="386" class="Symbol">(</a><a id="387" href="Agda.Builtin.Bool.html#181" class="InductiveConstructor">true</a><a id="391" class="Symbol">;</a> <a id="393" href="Agda.Builtin.Bool.html#175" class="InductiveConstructor">false</a><a id="398" class="Symbol">)</a>
<a id="400" class="Keyword">open</a> <a id="405" class="Keyword">import</a> <a id="412" href="Data.Empty.html" class="Module">Data.Empty</a> <a id="423" class="Keyword">using</a> <a id="429" class="Symbol">(</a><a id="430" href="Data.Empty.html#637" class="Function">⊥-elim</a><a id="436" class="Symbol">)</a>
<a id="438" class="Keyword">open</a> <a id="443" class="Keyword">import</a> <a id="450" href="Function.Base.html" class="Module">Function.Base</a>
<a id="464" class="Keyword">open</a> <a id="469" class="Keyword">import</a> <a id="476" href="Function.Equality.html" class="Module">Function.Equality</a> <a id="497" class="Keyword">using</a> <a id="503" class="Symbol">(</a><a id="504" href="Function.Equality.html#1073" class="Field Operator">_⟨$⟩_</a><a id="509" class="Symbol">;</a> <a id="511" class="Keyword">module</a> <a id="518" href="Function.Equality.html#898" class="Module">Π</a><a id="519" class="Symbol">)</a>
<a id="521" class="Keyword">open</a> <a id="526" class="Keyword">import</a> <a id="533" href="Function.html" class="Module">Function</a> <a id="542" class="Keyword">using</a> <a id="548" class="Symbol">(</a><a id="549" href="Function.Bundles.html#8819" class="Function Operator">_↔_</a><a id="552" class="Symbol">;</a> <a id="554" href="Function.Bundles.html#10775" class="Function">mk↔</a><a id="558" class="Symbol">)</a>
<a id="560" class="Keyword">open</a> <a id="565" class="Keyword">import</a> <a id="572" href="Function.Equivalence.html" class="Module">Function.Equivalence</a> <a id="593" class="Keyword">using</a> <a id="599" class="Symbol">(</a><a id="600" href="Function.Equivalence.html#1213" class="Function Operator">_⇔_</a><a id="603" class="Symbol">;</a> <a id="605" href="Function.Equivalence.html#1306" class="Function">equivalence</a><a id="616" class="Symbol">;</a> <a id="618" class="Keyword">module</a> <a id="625" href="Function.Equivalence.html#838" class="Module">Equivalence</a><a id="636" class="Symbol">)</a>
<a id="638" class="Keyword">open</a> <a id="643" class="Keyword">import</a> <a id="650" href="Function.Injection.html" class="Module">Function.Injection</a> <a id="671" class="Keyword">using</a> <a id="677" class="Symbol">(</a><a id="678" href="Function.Injection.html#1231" class="Record">Injection</a><a id="687" class="Symbol">;</a> <a id="689" class="Keyword">module</a> <a id="696" href="Function.Injection.html#1231" class="Module">Injection</a><a id="705" class="Symbol">)</a>
<a id="707" class="Keyword">open</a> <a id="712" class="Keyword">import</a> <a id="719" href="Relation.Binary.html" class="Module">Relation.Binary</a> <a id="740" class="Keyword">using</a> <a id="746" class="Symbol">(</a><a id="747" href="Relation.Binary.Bundles.html#1018" class="Record">Setoid</a><a id="753" class="Symbol">;</a> <a id="755" class="Keyword">module</a> <a id="762" href="Relation.Binary.Bundles.html#1018" class="Module">Setoid</a><a id="768" class="Symbol">;</a> <a id="770" href="Relation.Binary.Definitions.html#4584" class="Function">Decidable</a><a id="779" class="Symbol">)</a>
<a id="781" class="Keyword">open</a> <a id="786" class="Keyword">import</a> <a id="793" href="Relation.Nullary.html" class="Module">Relation.Nullary</a>
<a id="810" class="Keyword">open</a> <a id="815" class="Keyword">import</a> <a id="822" href="Relation.Nullary.Reflects.html" class="Module">Relation.Nullary.Reflects</a> <a id="848" class="Keyword">using</a> <a id="854" class="Symbol">(</a><a id="855" href="Relation.Nullary.Reflects.html#1040" class="Function">invert</a><a id="861" class="Symbol">)</a>
<a id="863" class="Keyword">open</a> <a id="868" class="Keyword">import</a> <a id="875" href="Relation.Binary.PropositionalEquality.html" class="Module">Relation.Binary.PropositionalEquality</a> <a id="913" class="Keyword">using</a> <a id="919" class="Symbol">(</a><a id="920" href="Relation.Binary.PropositionalEquality.Core.html#1206" class="Function">cong</a><a id="925" class="Symbol">)</a>
<a id="928" class="Keyword">private</a>
<a id="938" class="Keyword">variable</a>
<a id="951" href="Relation.Nullary.Decidable.html#951" class="Generalizable">p</a> <a id="953" href="Relation.Nullary.Decidable.html#953" class="Generalizable">q</a> <a id="955" class="Symbol">:</a> <a id="957" href="Agda.Primitive.html#591" class="Postulate">Level</a>
<a id="967" href="Relation.Nullary.Decidable.html#967" class="Generalizable">P</a> <a id="969" class="Symbol">:</a> <a id="971" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="975" href="Relation.Nullary.Decidable.html#951" class="Generalizable">p</a>
<a id="981" href="Relation.Nullary.Decidable.html#981" class="Generalizable">Q</a> <a id="983" class="Symbol">:</a> <a id="985" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="989" href="Relation.Nullary.Decidable.html#953" class="Generalizable">q</a>
<a id="992" class="Comment">------------------------------------------------------------------------</a>
<a id="1065" class="Comment">-- Re-exporting the core definitions</a>
<a id="1103" class="Keyword">open</a> <a id="1108" class="Keyword">import</a> <a id="1115" href="Relation.Nullary.Decidable.Core.html" class="Module">Relation.Nullary.Decidable.Core</a> <a id="1147" class="Keyword">public</a>
<a id="1155" class="Comment">------------------------------------------------------------------------</a>
<a id="1228" class="Comment">-- Maps</a>
<a id="map"></a><a id="1237" href="Relation.Nullary.Decidable.html#1237" class="Function">map</a> <a id="1241" class="Symbol">:</a> <a id="1243" href="Relation.Nullary.Decidable.html#967" class="Generalizable">P</a> <a id="1245" href="Function.Equivalence.html#1213" class="Function Operator"></a> <a id="1247" href="Relation.Nullary.Decidable.html#981" class="Generalizable">Q</a> <a id="1249" class="Symbol"></a> <a id="1251" href="Relation.Nullary.html#1520" class="Record">Dec</a> <a id="1255" href="Relation.Nullary.Decidable.html#967" class="Generalizable">P</a> <a id="1257" class="Symbol"></a> <a id="1259" href="Relation.Nullary.html#1520" class="Record">Dec</a> <a id="1263" href="Relation.Nullary.Decidable.html#981" class="Generalizable">Q</a>
<a id="1265" href="Relation.Nullary.Decidable.html#1237" class="Function">map</a> <a id="1269" href="Relation.Nullary.Decidable.html#1269" class="Bound">P⇔Q</a> <a id="1273" class="Symbol">=</a> <a id="1275" href="Relation.Nullary.Decidable.Core.html#3645" class="Function">map</a> <a id="1280" class="Symbol">(</a><a id="1281" href="Function.Equivalence.html#988" class="Field">to</a> <a id="1284" href="Function.Equality.html#1073" class="Field Operator">⟨$⟩_</a><a id="1288" class="Symbol">)</a> <a id="1290" class="Symbol">(</a><a id="1291" href="Function.Equivalence.html#1009" class="Field">from</a> <a id="1296" href="Function.Equality.html#1073" class="Field Operator">⟨$⟩_</a><a id="1300" class="Symbol">)</a>
<a id="1304" class="Keyword">where</a> <a id="1310" class="Keyword">open</a> <a id="1315" href="Function.Equivalence.html#838" class="Module">Equivalence</a> <a id="1327" href="Relation.Nullary.Decidable.html#1269" class="Bound">P⇔Q</a>
<a id="1332" class="Keyword">module</a> <a id="1339" href="Relation.Nullary.Decidable.html#1339" class="Module">_</a> <a id="1341" class="Symbol">{</a><a id="1342" href="Relation.Nullary.Decidable.html#1342" class="Bound">a₁</a> <a id="1345" href="Relation.Nullary.Decidable.html#1345" class="Bound">a₂</a> <a id="1348" href="Relation.Nullary.Decidable.html#1348" class="Bound">b₁</a> <a id="1351" href="Relation.Nullary.Decidable.html#1351" class="Bound">b₂</a><a id="1353" class="Symbol">}</a> <a id="1355" class="Symbol">{</a><a id="1356" href="Relation.Nullary.Decidable.html#1356" class="Bound">A</a> <a id="1358" class="Symbol">:</a> <a id="1360" href="Relation.Binary.Bundles.html#1018" class="Record">Setoid</a> <a id="1367" href="Relation.Nullary.Decidable.html#1342" class="Bound">a₁</a> <a id="1370" href="Relation.Nullary.Decidable.html#1345" class="Bound">a₂</a><a id="1372" class="Symbol">}</a> <a id="1374" class="Symbol">{</a><a id="1375" href="Relation.Nullary.Decidable.html#1375" class="Bound">B</a> <a id="1377" class="Symbol">:</a> <a id="1379" href="Relation.Binary.Bundles.html#1018" class="Record">Setoid</a> <a id="1386" href="Relation.Nullary.Decidable.html#1348" class="Bound">b₁</a> <a id="1389" href="Relation.Nullary.Decidable.html#1351" class="Bound">b₂</a><a id="1391" class="Symbol">}</a>
<a id="1402" class="Symbol">(</a><a id="1403" href="Relation.Nullary.Decidable.html#1403" class="Bound">inj</a> <a id="1407" class="Symbol">:</a> <a id="1409" href="Function.Injection.html#1231" class="Record">Injection</a> <a id="1419" href="Relation.Nullary.Decidable.html#1356" class="Bound">A</a> <a id="1421" href="Relation.Nullary.Decidable.html#1375" class="Bound">B</a><a id="1422" class="Symbol">)</a>
<a id="1426" class="Keyword">where</a>
<a id="1435" class="Keyword">open</a> <a id="1440" href="Function.Injection.html#1231" class="Module">Injection</a> <a id="1450" href="Relation.Nullary.Decidable.html#1403" class="Bound">inj</a>
<a id="1456" class="Keyword">open</a> <a id="1461" href="Relation.Binary.Bundles.html#1018" class="Module">Setoid</a> <a id="1468" href="Relation.Nullary.Decidable.html#1356" class="Bound">A</a> <a id="1470" class="Keyword">using</a> <a id="1476" class="Symbol">()</a> <a id="1479" class="Keyword">renaming</a> <a id="1488" class="Symbol">(</a><a id="1489" href="Relation.Binary.Bundles.html#1107" class="Field Operator">_≈_</a> <a id="1493" class="Symbol">to</a> <a id="1496" class="Field Operator">_≈A_</a><a id="1500" class="Symbol">)</a>
<a id="1504" class="Keyword">open</a> <a id="1509" href="Relation.Binary.Bundles.html#1018" class="Module">Setoid</a> <a id="1516" href="Relation.Nullary.Decidable.html#1375" class="Bound">B</a> <a id="1518" class="Keyword">using</a> <a id="1524" class="Symbol">()</a> <a id="1527" class="Keyword">renaming</a> <a id="1536" class="Symbol">(</a><a id="1537" href="Relation.Binary.Bundles.html#1107" class="Field Operator">_≈_</a> <a id="1541" class="Symbol">to</a> <a id="1544" class="Field Operator">_≈B_</a><a id="1548" class="Symbol">)</a>
<a id="1553" class="Comment">-- If there is an injection from one setoid to another, and the</a>
<a id="1619" class="Comment">-- latter&#39;s equivalence relation is decidable, then the former&#39;s</a>
<a id="1686" class="Comment">-- equivalence relation is also decidable.</a>
<a id="1732" href="Relation.Nullary.Decidable.html#1732" class="Function">via-injection</a> <a id="1746" class="Symbol">:</a> <a id="1748" href="Relation.Binary.Definitions.html#4584" class="Function">Decidable</a> <a id="1758" href="Relation.Nullary.Decidable.html#1544" class="Function Operator">_≈B_</a> <a id="1763" class="Symbol"></a> <a id="1765" href="Relation.Binary.Definitions.html#4584" class="Function">Decidable</a> <a id="1775" href="Relation.Nullary.Decidable.html#1496" class="Function Operator">_≈A_</a>
<a id="1782" href="Relation.Nullary.Decidable.html#1732" class="Function">via-injection</a> <a id="1796" href="Relation.Nullary.Decidable.html#1796" class="Bound">dec</a> <a id="1800" href="Relation.Nullary.Decidable.html#1800" class="Bound">x</a> <a id="1802" href="Relation.Nullary.Decidable.html#1802" class="Bound">y</a> <a id="1804" class="Symbol">=</a>
<a id="1810" href="Relation.Nullary.Decidable.Core.html#3645" class="Function">map</a> <a id="1815" href="Function.Injection.html#1401" class="Field">injective</a> <a id="1825" class="Symbol">(</a><a id="1826" href="Function.Equality.html#1140" class="Field">Π.cong</a> <a id="1833" href="Function.Injection.html#1375" class="Field">to</a><a id="1835" class="Symbol">)</a> <a id="1837" class="Symbol">(</a><a id="1838" href="Relation.Nullary.Decidable.html#1796" class="Bound">dec</a> <a id="1842" class="Symbol">(</a><a id="1843" href="Function.Injection.html#1375" class="Field">to</a> <a id="1846" href="Function.Equality.html#1073" class="Field Operator">⟨$⟩</a> <a id="1850" href="Relation.Nullary.Decidable.html#1800" class="Bound">x</a><a id="1851" class="Symbol">)</a> <a id="1853" class="Symbol">(</a><a id="1854" href="Function.Injection.html#1375" class="Field">to</a> <a id="1857" href="Function.Equality.html#1073" class="Field Operator">⟨$⟩</a> <a id="1861" href="Relation.Nullary.Decidable.html#1802" class="Bound">y</a><a id="1862" class="Symbol">))</a>
<a id="1866" class="Comment">------------------------------------------------------------------------</a>
<a id="1939" class="Comment">-- A lemma relating True and Dec</a>
<a id="True-↔"></a><a id="1973" href="Relation.Nullary.Decidable.html#1973" class="Function">True-↔</a> <a id="1980" class="Symbol">:</a> <a id="1982" class="Symbol">(</a><a id="1983" href="Relation.Nullary.Decidable.html#1983" class="Bound">dec</a> <a id="1987" class="Symbol">:</a> <a id="1989" href="Relation.Nullary.html#1520" class="Record">Dec</a> <a id="1993" href="Relation.Nullary.Decidable.html#967" class="Generalizable">P</a><a id="1994" class="Symbol">)</a> <a id="1996" class="Symbol"></a> <a id="1998" href="Relation.Nullary.html#2049" class="Function">Irrelevant</a> <a id="2009" href="Relation.Nullary.Decidable.html#967" class="Generalizable">P</a> <a id="2011" class="Symbol"></a> <a id="2013" href="Relation.Nullary.Decidable.Core.html#1374" class="Function">True</a> <a id="2018" href="Relation.Nullary.Decidable.html#1983" class="Bound">dec</a> <a id="2022" href="Function.Bundles.html#8819" class="Function Operator"></a> <a id="2024" href="Relation.Nullary.Decidable.html#967" class="Generalizable">P</a>
<a id="2026" href="Relation.Nullary.Decidable.html#1973" class="Function">True-↔</a> <a id="2033" class="Symbol">(</a><a id="2034" href="Agda.Builtin.Bool.html#181" class="InductiveConstructor">true</a> <a id="2040" href="Relation.Nullary.html#1568" class="InductiveConstructor Operator">because</a> <a id="2049" href="Relation.Nullary.Decidable.html#2049" class="Bound">[p]</a><a id="2052" class="Symbol">)</a> <a id="2054" href="Relation.Nullary.Decidable.html#2054" class="Bound">irr</a> <a id="2058" class="Symbol">=</a> <a id="2060" href="Function.Bundles.html#10775" class="Function">mk↔</a> <a id="2065" class="Symbol"></a> <a id="2068" href="Relation.Nullary.Decidable.html#2068" class="Bound">_</a> <a id="2070" class="Symbol"></a> <a id="2072" href="Relation.Nullary.Reflects.html#1040" class="Function">invert</a> <a id="2079" href="Relation.Nullary.Decidable.html#2049" class="Bound">[p]</a><a id="2082" class="Symbol">)</a> <a id="2084" class="Symbol">_</a> <a id="2086" class="Symbol">(</a><a id="2087" href="Relation.Nullary.Decidable.html#2054" class="Bound">irr</a> <a id="2091" class="Symbol">(</a><a id="2092" href="Relation.Nullary.Reflects.html#1040" class="Function">invert</a> <a id="2099" href="Relation.Nullary.Decidable.html#2049" class="Bound">[p]</a><a id="2102" class="Symbol">))</a> <a id="2105" href="Relation.Binary.PropositionalEquality.Core.html#1206" class="Function">cong</a>
<a id="2111" href="Relation.Nullary.Decidable.html#1973" class="Function">True-↔</a> <a id="2118" class="Symbol">(</a><a id="2119" href="Agda.Builtin.Bool.html#175" class="InductiveConstructor">false</a> <a id="2125" href="Relation.Nullary.html#1568" class="InductiveConstructor Operator">because</a> <a id="2133" href="Relation.Nullary.html#948" class="InductiveConstructor">ofⁿ</a> <a id="2137" href="Relation.Nullary.Decidable.html#2137" class="Bound">¬p</a><a id="2139" class="Symbol">)</a> <a id="2141" class="Symbol">_</a> <a id="2143" class="Symbol">=</a> <a id="2145" href="Function.Bundles.html#10775" class="Function">mk↔</a> <a id="2150" class="Symbol"></a> <a id="2153" class="Symbol">())</a> <a id="2157" class="Symbol">(</a><a id="2158" href="Relation.Nullary.Reflects.html#1040" class="Function">invert</a> <a id="2165" class="Symbol">(</a><a id="2166" href="Relation.Nullary.html#948" class="InductiveConstructor">ofⁿ</a> <a id="2170" href="Relation.Nullary.Decidable.html#2137" class="Bound">¬p</a><a id="2172" class="Symbol">))</a> <a id="2175" class="Symbol">(</a><a id="2176" href="Data.Empty.html#637" class="Function">⊥-elim</a> <a id="2183" href="Function.Base.html#1040" class="Function Operator"></a> <a id="2185" href="Relation.Nullary.Decidable.html#2137" class="Bound">¬p</a><a id="2187" class="Symbol">)</a> <a id="2189" class="Symbol">λ</a> <a id="2191" class="Symbol">()</a>
</pre></body></html>