<commit_before>(*  Title:      HOL/Library/Extended_Nat.thy
    Author:     <NAME>, TU Muenchen;  <NAME>, TU Muenchen
    Contributions: <NAME>, TU Muenchen
*)

header {* Extended natural numbers (i.e. with infinity) *}

theory Extended_Nat
imports Main Countable
begin

class infinity =
  fixes infinity :: "'a"

notation (xsymbols)
  infinity  ("\<infinity>")

notation (HTML output)
  infinity  ("\<infinity>")

subsection {* Type definition *}

text {*
  We extend the standard natural numbers by a special value indicating
  infinity.
*}

typedef enat = "UNIV :: nat option set" ..

text {* TODO: introduce enat as coinductive datatype, enat is just of_nat *}

definition enat :: "nat \<Rightarrow> enat" where
  "enat n = Abs_enat (Some n)"
 
instantiation enat :: infinity
begin
  definition "\<infinity> = Abs_enat None"
  instance proof qed
end

instance enat :: countable
proof
  show "\<exists>to_nat::enat \<Rightarrow> nat. inj to_nat"<commit_msg>fix document generation for Extended_Nat<commit_after>(*  Title:      HOL/Library/Extended_Nat.thy
    Author:     <NAME>, TU Muenchen;  <NAME>, TU Muenchen
    Contributions: <NAME>, TU Muenchen
*)

header {* Extended natural numbers (i.e. with infinity) *}

theory Extended_Nat
imports Main Countable
begin

class infinity =
  fixes infinity :: "'a"

notation (xsymbols)
  infinity  ("\<infinity>")

notation (HTML output)
  infinity  ("\<infinity>")

subsection {* Type definition *}

text {*
  We extend the standard natural numbers by a special value indicating
  infinity.
*}

typedef enat = "UNIV :: nat option set" ..

text {* TODO: introduce enat as coinductive datatype, enat is just @{const of_nat} *}

definition enat :: "nat \<Rightarrow> enat" where
  "enat n = Abs_enat (Some n)"
 
instantiation enat :: infinity
begin
  definition "\<infinity> = Abs_enat None"
  instance proof qed
end

instance enat :: countable
proof
  show "\<exists>to_nat::enat \<Rightarrow> nat. inj to_nat"
{'fraction_non_alphanumeric': 0.1140081799591002, 'fraction_numerical': 0.0, 'mean_word_length': 4.017948717948718, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '342434', 'n_tokens_mistral': 681, 'n_tokens_neox': 628, 'n_words': 218}