mirror of
https://git8.cs.fau.de/theses/bsc-leon-vatthauer.git
synced 2024-05-31 07:28:34 +02:00
72 lines
No EOL
13 KiB
HTML
72 lines
No EOL
13 KiB
HTML
<!DOCTYPE HTML>
|
||
<html><head><meta charset="utf-8"><title>Relation.Nullary</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 nullary relations (like negation and decidability)</a>
|
||
<a id="174" class="Comment">------------------------------------------------------------------------</a>
|
||
|
||
<a id="248" class="Comment">-- Some operations on/properties of nullary relations, i.e. sets.</a>
|
||
|
||
<a id="315" class="Symbol">{-#</a> <a id="319" class="Keyword">OPTIONS</a> <a id="327" class="Pragma">--cubical-compatible</a> <a id="348" class="Pragma">--safe</a> <a id="355" class="Symbol">#-}</a>
|
||
|
||
<a id="360" class="Keyword">module</a> <a id="367" href="Relation.Nullary.html" class="Module">Relation.Nullary</a> <a id="384" class="Keyword">where</a>
|
||
|
||
<a id="391" class="Keyword">open</a> <a id="396" class="Keyword">import</a> <a id="403" href="Agda.Builtin.Equality.html" class="Module">Agda.Builtin.Equality</a>
|
||
<a id="425" class="Keyword">open</a> <a id="430" class="Keyword">import</a> <a id="437" href="Agda.Builtin.Bool.html" class="Module">Agda.Builtin.Bool</a>
|
||
|
||
<a id="456" class="Keyword">open</a> <a id="461" class="Keyword">import</a> <a id="468" href="Data.Empty.html" class="Module">Data.Empty</a> <a id="479" class="Keyword">hiding</a> <a id="486" class="Symbol">(</a><a id="487" href="Data.Empty.html#637" class="Function">⊥-elim</a><a id="493" class="Symbol">)</a>
|
||
<a id="495" class="Keyword">open</a> <a id="500" class="Keyword">import</a> <a id="507" href="Data.Empty.Irrelevant.html" class="Module">Data.Empty.Irrelevant</a>
|
||
<a id="529" class="Keyword">open</a> <a id="534" class="Keyword">import</a> <a id="541" href="Level.html" class="Module">Level</a>
|
||
|
||
<a id="548" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="621" class="Comment">-- Negation.</a>
|
||
|
||
<a id="635" class="Keyword">infix</a> <a id="641" class="Number">3</a> <a id="643" href="Relation.Nullary.html#665" class="Function Operator">¬_</a>
|
||
<a id="646" class="Keyword">infix</a> <a id="652" class="Number">2</a> <a id="654" href="Relation.Nullary.html#1568" class="InductiveConstructor Operator">_because_</a>
|
||
|
||
<a id="¬_"></a><a id="665" href="Relation.Nullary.html#665" class="Function Operator">¬_</a> <a id="668" class="Symbol">:</a> <a id="670" class="Symbol">∀</a> <a id="672" class="Symbol">{</a><a id="673" href="Relation.Nullary.html#673" class="Bound">ℓ</a><a id="674" class="Symbol">}</a> <a id="676" class="Symbol">→</a> <a id="678" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="682" href="Relation.Nullary.html#673" class="Bound">ℓ</a> <a id="684" class="Symbol">→</a> <a id="686" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="690" href="Relation.Nullary.html#673" class="Bound">ℓ</a>
|
||
<a id="692" href="Relation.Nullary.html#665" class="Function Operator">¬</a> <a id="694" href="Relation.Nullary.html#694" class="Bound">P</a> <a id="696" class="Symbol">=</a> <a id="698" href="Relation.Nullary.html#694" class="Bound">P</a> <a id="700" class="Symbol">→</a> <a id="702" href="Data.Empty.html#535" class="Datatype">⊥</a>
|
||
|
||
<a id="705" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="778" class="Comment">-- `Reflects` idiom.</a>
|
||
|
||
<a id="800" class="Comment">-- The truth value of P is reflected by a boolean value.</a>
|
||
|
||
<a id="858" class="Keyword">data</a> <a id="Reflects"></a><a id="863" href="Relation.Nullary.html#863" class="Datatype">Reflects</a> <a id="872" class="Symbol">{</a><a id="873" href="Relation.Nullary.html#873" class="Bound">p</a><a id="874" class="Symbol">}</a> <a id="876" class="Symbol">(</a><a id="877" href="Relation.Nullary.html#877" class="Bound">P</a> <a id="879" class="Symbol">:</a> <a id="881" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="885" href="Relation.Nullary.html#873" class="Bound">p</a><a id="886" class="Symbol">)</a> <a id="888" class="Symbol">:</a> <a id="890" href="Agda.Builtin.Bool.html#156" class="Datatype">Bool</a> <a id="895" class="Symbol">→</a> <a id="897" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="901" href="Relation.Nullary.html#873" class="Bound">p</a> <a id="903" class="Keyword">where</a>
|
||
<a id="Reflects.ofʸ"></a><a id="911" href="Relation.Nullary.html#911" class="InductiveConstructor">ofʸ</a> <a id="915" class="Symbol">:</a> <a id="917" class="Symbol">(</a> <a id="919" href="Relation.Nullary.html#919" class="Bound">p</a> <a id="921" class="Symbol">:</a> <a id="925" href="Relation.Nullary.html#877" class="Bound">P</a><a id="926" class="Symbol">)</a> <a id="928" class="Symbol">→</a> <a id="930" href="Relation.Nullary.html#863" class="Datatype">Reflects</a> <a id="939" href="Relation.Nullary.html#877" class="Bound">P</a> <a id="941" href="Agda.Builtin.Bool.html#181" class="InductiveConstructor">true</a>
|
||
<a id="Reflects.ofⁿ"></a><a id="948" href="Relation.Nullary.html#948" class="InductiveConstructor">ofⁿ</a> <a id="952" class="Symbol">:</a> <a id="954" class="Symbol">(</a><a id="955" href="Relation.Nullary.html#955" class="Bound">¬p</a> <a id="958" class="Symbol">:</a> <a id="960" href="Relation.Nullary.html#665" class="Function Operator">¬</a> <a id="962" href="Relation.Nullary.html#877" class="Bound">P</a><a id="963" class="Symbol">)</a> <a id="965" class="Symbol">→</a> <a id="967" href="Relation.Nullary.html#863" class="Datatype">Reflects</a> <a id="976" href="Relation.Nullary.html#877" class="Bound">P</a> <a id="978" href="Agda.Builtin.Bool.html#175" class="InductiveConstructor">false</a>
|
||
|
||
<a id="985" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="1058" class="Comment">-- Decidability.</a>
|
||
|
||
<a id="1076" class="Comment">-- Decidability proofs have two parts: the `does` term which contains</a>
|
||
<a id="1146" class="Comment">-- the boolean result and the `proof` term which contains a proof that</a>
|
||
<a id="1217" class="Comment">-- reflects the boolean result. This definition allows the boolean</a>
|
||
<a id="1284" class="Comment">-- part of the decision procedure to compute independently from the</a>
|
||
<a id="1352" class="Comment">-- proof. This leads to better computational behaviour when we only care</a>
|
||
<a id="1425" class="Comment">-- about the result and not the proof. See README.Decidability for</a>
|
||
<a id="1492" class="Comment">-- further details.</a>
|
||
|
||
<a id="1513" class="Keyword">record</a> <a id="Dec"></a><a id="1520" href="Relation.Nullary.html#1520" class="Record">Dec</a> <a id="1524" class="Symbol">{</a><a id="1525" href="Relation.Nullary.html#1525" class="Bound">p</a><a id="1526" class="Symbol">}</a> <a id="1528" class="Symbol">(</a><a id="1529" href="Relation.Nullary.html#1529" class="Bound">P</a> <a id="1531" class="Symbol">:</a> <a id="1533" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="1537" href="Relation.Nullary.html#1525" class="Bound">p</a><a id="1538" class="Symbol">)</a> <a id="1540" class="Symbol">:</a> <a id="1542" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="1546" href="Relation.Nullary.html#1525" class="Bound">p</a> <a id="1548" class="Keyword">where</a>
|
||
<a id="1556" class="Keyword">constructor</a> <a id="_because_"></a><a id="1568" href="Relation.Nullary.html#1568" class="InductiveConstructor Operator">_because_</a>
|
||
<a id="1580" class="Keyword">field</a>
|
||
<a id="Dec.does"></a><a id="1590" href="Relation.Nullary.html#1590" class="Field">does</a> <a id="1596" class="Symbol">:</a> <a id="1598" href="Agda.Builtin.Bool.html#156" class="Datatype">Bool</a>
|
||
<a id="Dec.proof"></a><a id="1607" href="Relation.Nullary.html#1607" class="Field">proof</a> <a id="1613" class="Symbol">:</a> <a id="1615" href="Relation.Nullary.html#863" class="Datatype">Reflects</a> <a id="1624" href="Relation.Nullary.html#1529" class="Bound">P</a> <a id="1626" href="Relation.Nullary.html#1590" class="Field">does</a>
|
||
|
||
<a id="1632" class="Keyword">open</a> <a id="1637" href="Relation.Nullary.html#1520" class="Module">Dec</a> <a id="1641" class="Keyword">public</a>
|
||
|
||
<a id="1649" class="Keyword">pattern</a> <a id="yes"></a><a id="1657" href="Relation.Nullary.html#1657" class="InductiveConstructor">yes</a> <a id="1661" href="Relation.Nullary.html#1684" class="Bound">p</a> <a id="1663" class="Symbol">=</a> <a id="1666" href="Agda.Builtin.Bool.html#181" class="InductiveConstructor">true</a> <a id="1671" href="Relation.Nullary.html#1568" class="InductiveConstructor Operator">because</a> <a id="1679" href="Relation.Nullary.html#911" class="InductiveConstructor">ofʸ</a> <a id="1684" href="Relation.Nullary.html#1684" class="Bound">p</a>
|
||
<a id="1686" class="Keyword">pattern</a> <a id="no"></a><a id="1694" href="Relation.Nullary.html#1694" class="InductiveConstructor">no</a> <a id="1697" href="Relation.Nullary.html#1720" class="Bound">¬p</a> <a id="1700" class="Symbol">=</a> <a id="1702" href="Agda.Builtin.Bool.html#175" class="InductiveConstructor">false</a> <a id="1708" href="Relation.Nullary.html#1568" class="InductiveConstructor Operator">because</a> <a id="1716" href="Relation.Nullary.html#948" class="InductiveConstructor">ofⁿ</a> <a id="1720" href="Relation.Nullary.html#1720" class="Bound">¬p</a>
|
||
|
||
<a id="1724" class="Comment">-- Given an irrelevant proof of a decidable type, a proof can</a>
|
||
<a id="1786" class="Comment">-- be recomputed and subsequently used in relevant contexts.</a>
|
||
<a id="recompute"></a><a id="1847" href="Relation.Nullary.html#1847" class="Function">recompute</a> <a id="1857" class="Symbol">:</a> <a id="1859" class="Symbol">∀</a> <a id="1861" class="Symbol">{</a><a id="1862" href="Relation.Nullary.html#1862" class="Bound">a</a><a id="1863" class="Symbol">}</a> <a id="1865" class="Symbol">{</a><a id="1866" href="Relation.Nullary.html#1866" class="Bound">A</a> <a id="1868" class="Symbol">:</a> <a id="1870" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="1874" href="Relation.Nullary.html#1862" class="Bound">a</a><a id="1875" class="Symbol">}</a> <a id="1877" class="Symbol">→</a> <a id="1879" href="Relation.Nullary.html#1520" class="Record">Dec</a> <a id="1883" href="Relation.Nullary.html#1866" class="Bound">A</a> <a id="1885" class="Symbol">→</a> <a id="1887" class="Symbol">.</a><a id="1888" href="Relation.Nullary.html#1866" class="Bound">A</a> <a id="1890" class="Symbol">→</a> <a id="1892" href="Relation.Nullary.html#1866" class="Bound">A</a>
|
||
<a id="1894" href="Relation.Nullary.html#1847" class="Function">recompute</a> <a id="1904" class="Symbol">(</a><a id="1905" href="Relation.Nullary.html#1657" class="InductiveConstructor">yes</a> <a id="1909" href="Relation.Nullary.html#1909" class="Bound">x</a><a id="1910" class="Symbol">)</a> <a id="1912" class="Symbol">_</a> <a id="1914" class="Symbol">=</a> <a id="1916" href="Relation.Nullary.html#1909" class="Bound">x</a>
|
||
<a id="1918" href="Relation.Nullary.html#1847" class="Function">recompute</a> <a id="1928" class="Symbol">(</a><a id="1929" href="Relation.Nullary.html#1694" class="InductiveConstructor">no</a> <a id="1932" href="Relation.Nullary.html#1932" class="Bound">¬p</a><a id="1934" class="Symbol">)</a> <a id="1936" href="Relation.Nullary.html#1936" class="Bound">x</a> <a id="1938" class="Symbol">=</a> <a id="1940" href="Data.Empty.Irrelevant.html#336" class="Function">⊥-elim</a> <a id="1947" class="Symbol">(</a><a id="1948" href="Relation.Nullary.html#1932" class="Bound">¬p</a> <a id="1951" href="Relation.Nullary.html#1936" class="Bound">x</a><a id="1952" class="Symbol">)</a>
|
||
|
||
<a id="1955" class="Comment">------------------------------------------------------------------------</a>
|
||
<a id="2028" class="Comment">-- Irrelevant types</a>
|
||
|
||
<a id="Irrelevant"></a><a id="2049" href="Relation.Nullary.html#2049" class="Function">Irrelevant</a> <a id="2060" class="Symbol">:</a> <a id="2062" class="Symbol">∀</a> <a id="2064" class="Symbol">{</a><a id="2065" href="Relation.Nullary.html#2065" class="Bound">p</a><a id="2066" class="Symbol">}</a> <a id="2068" class="Symbol">→</a> <a id="2070" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="2074" href="Relation.Nullary.html#2065" class="Bound">p</a> <a id="2076" class="Symbol">→</a> <a id="2078" href="Agda.Primitive.html#320" class="Primitive">Set</a> <a id="2082" href="Relation.Nullary.html#2065" class="Bound">p</a>
|
||
<a id="2084" href="Relation.Nullary.html#2049" class="Function">Irrelevant</a> <a id="2095" href="Relation.Nullary.html#2095" class="Bound">P</a> <a id="2097" class="Symbol">=</a> <a id="2099" class="Symbol">∀</a> <a id="2101" class="Symbol">(</a><a id="2102" href="Relation.Nullary.html#2102" class="Bound">p₁</a> <a id="2105" href="Relation.Nullary.html#2105" class="Bound">p₂</a> <a id="2108" class="Symbol">:</a> <a id="2110" href="Relation.Nullary.html#2095" class="Bound">P</a><a id="2111" class="Symbol">)</a> <a id="2113" class="Symbol">→</a> <a id="2115" href="Relation.Nullary.html#2102" class="Bound">p₁</a> <a id="2118" href="Agda.Builtin.Equality.html#133" class="Datatype Operator">≡</a> <a id="2120" href="Relation.Nullary.html#2105" class="Bound">p₂</a>
|
||
</pre></body></html> |