Dataset Viewer
Auto-converted to Parquet
theory_file
stringlengths
5
95
lemma_name
stringlengths
5
250
lemma_command
stringlengths
17
21.3k
lemma_object
stringlengths
5
62.8k
template
stringlengths
7
63.6k
symbols
sequencelengths
0
89
defs
sequencelengths
0
63
Combinatorial_Enumeration_Algorithms/n_Sequences
n_Sequences.n_sequences_card
theorem n_sequences_card: assumes "finite A" shows "card (n_sequences A n) = card A ^ n"
finite ?A \<Longrightarrow> card (n_sequences ?A ?n) = card ?A ^ ?n
?H1 x_1 \<Longrightarrow> ?H2 (?H3 x_1 x_2) = ?H4 (?H5 x_1) x_2
[ "Finite_Set.finite", "n_Sequences.n_sequence_enum", "n_Sequences.n_sequences", "Power.power_class.power", "List.distinct", "Finite_Set.card" ]
[ "class finite =\n assumes finite_UNIV: \"finite (UNIV :: 'a set)\"\nbegin", "fun n_sequence_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_sequence_enum xs 0 = [[]]\"\n| \"n_sequence_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_sequence_enum xs n]\"", "definition n_sequences :: \"'a set \\<Rightarrow> nat \\<Rightarrow> 'a list set\" where\n \"n_sequences A n = {xs. set xs \\<subseteq> A \\<and> length xs = n}\"", "primrec power :: \"'a \\<Rightarrow> nat \\<Rightarrow> 'a\" (infixr \"^\" 80)\n where\n power_0: \"a ^ 0 = 1\"\n | power_Suc: \"a ^ Suc n = a * a ^ n\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"" ]
Combinatorial_Enumeration_Algorithms/n_Sequences
n_Sequences.n_sequence_enum_correct
theorem n_sequence_enum_correct: "set (n_sequence_enum xs n) = n_sequences (set xs) n"
set (n_sequence_enum ?xs ?n) = n_sequences (set ?xs) ?n
?H1 (?H2 x_1 x_2) = ?H3 (?H4 x_1) x_2
[ "n_Sequences.n_sequence_enum", "List.length", "n_Sequences.n_sequences", "Finite_Set.finite", "n_Sequences.n_sequence_enum_dom", "List.list.set" ]
[ "fun n_sequence_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_sequence_enum xs 0 = [[]]\"\n| \"n_sequence_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_sequence_enum xs n]\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "definition n_sequences :: \"'a set \\<Rightarrow> nat \\<Rightarrow> 'a list set\" where\n \"n_sequences A n = {xs. set xs \\<subseteq> A \\<and> length xs = n}\"", "class finite =\n assumes finite_UNIV: \"finite (UNIV :: 'a set)\"\nbegin", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/n_Sequences
n_Sequences.n_sequence_enum_length
lemma n_sequence_enum_length: "length (n_sequence_enum xs n) = (length xs) ^ n "
length (n_sequence_enum ?xs ?n) = length ?xs ^ ?n
?H1 (?H2 x_1 x_2) = ?H3 (?H4 x_1) x_2
[ "n_Sequences.n_sequence_enum", "List.list.map", "Power.power_class.power", "List.length" ]
[ "fun n_sequence_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_sequence_enum xs 0 = [[]]\"\n| \"n_sequence_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_sequence_enum xs n]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec power :: \"'a \\<Rightarrow> nat \\<Rightarrow> 'a\" (infixr \"^\" 80)\n where\n power_0: \"a ^ 0 = 1\"\n | power_Suc: \"a ^ Suc n = a * a ^ n\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"" ]
Combinatorial_Enumeration_Algorithms/n_Sequences
n_Sequences.n_sequence_enum_distinct
theorem n_sequence_enum_distinct: "distinct xs \<Longrightarrow> distinct (n_sequence_enum xs n)"
distinct ?xs \<Longrightarrow> distinct (n_sequence_enum ?xs ?n)
?H1 x_1 \<Longrightarrow> ?H2 (?H3 x_1 x_2)
[ "n_Sequences.n_sequence_enum_dom", "n_Sequences.n_sequence_enum", "Nat.Suc", "List.distinct" ]
[ "fun n_sequence_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_sequence_enum xs 0 = [[]]\"\n| \"n_sequence_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_sequence_enum xs n]\"", "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.derangement_enum_correct_aux1
lemma derangement_enum_correct_aux1: "\<lbrakk>distinct zs;length ys = length zs; length ys = length xs; set ys = set zs; no_overlap xs zs\<rbrakk> \<Longrightarrow> zs \<in> set (derangement_enum_aux xs ys)"
distinct ?zs \<Longrightarrow> length ?ys = length ?zs \<Longrightarrow> length ?ys = length ?xs \<Longrightarrow> set ?ys = set ?zs \<Longrightarrow> no_overlap ?xs ?zs \<Longrightarrow> ?zs \<in> set (derangement_enum_aux ?xs ?ys)
\<lbrakk>?H1 x_1; ?H2 x_2 = ?H2 x_1; ?H2 x_2 = ?H2 x_3; ?H3 x_2 = ?H3 x_1; ?H4 x_3 x_1\<rbrakk> \<Longrightarrow> x_1 \<in> ?H5 (?H6 x_3 x_2)
[ "List.list.set", "List.list.Cons", "Derangements_Enum.derangement_enum_aux", "Derangements_Enum.no_overlap", "List.distinct", "List.length" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun derangement_enum_aux :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> 'a list list\" where\n \"derangement_enum_aux [] ys = [[]]\"\n| \"derangement_enum_aux (x#xs) ys = [y#r . y \\<leftarrow> ys, r \\<leftarrow> derangement_enum_aux xs (remove1 y ys), y \\<noteq> x]\"", "fun no_overlap :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> bool\" where\n \"no_overlap _ [] = True\"\n| \"no_overlap [] _ = True\"\n| \"no_overlap (x#xs) (y#ys) = (x \\<noteq> y \\<and> no_overlap xs ys)\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.nth_no_overlap
lemma nth_no_overlap: "length xs = length ys \<Longrightarrow> \<forall> i < length xs. xs ! i \<noteq> ys ! i \<Longrightarrow> no_overlap xs ys"
length ?xs = length ?ys \<Longrightarrow> \<forall>i<length ?xs. ?xs ! i \<noteq> ?ys ! i \<Longrightarrow> no_overlap ?xs ?ys
\<lbrakk>?H1 x_1 = ?H1 x_2; \<forall>y_0<?H1 x_1. ?H2 x_1 y_0 \<noteq> ?H2 x_2 y_0\<rbrakk> \<Longrightarrow> ?H3 x_1 x_2
[ "Derangements_Enum.no_overlap", "List.length", "List.nth" ]
[ "fun no_overlap :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> bool\" where\n \"no_overlap _ [] = True\"\n| \"no_overlap [] _ = True\"\n| \"no_overlap (x#xs) (y#ys) = (x \\<noteq> y \\<and> no_overlap xs ys)\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec (nonexhaustive) nth :: \"'a list => nat => 'a\" (infixl \"!\" 100) where\nnth_Cons: \"(x # xs) ! n = (case n of 0 \\<Rightarrow> x | Suc k \\<Rightarrow> xs ! k)\"\n \\<comment> \\<open>Warning: simpset does not contain this definition, but separate\n theorems for \\<open>n = 0\\<close> and \\<open>n = Suc k\\<close>\\<close>" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.no_overlap_nth
lemma no_overlap_nth: "length xs = length ys \<Longrightarrow> i < length xs \<Longrightarrow> no_overlap xs ys \<Longrightarrow> xs ! i \<noteq> ys ! i"
length ?xs = length ?ys \<Longrightarrow> ?i < length ?xs \<Longrightarrow> no_overlap ?xs ?ys \<Longrightarrow> ?xs ! ?i \<noteq> ?ys ! ?i
\<lbrakk>?H1 x_1 = ?H1 x_2; x_3 < ?H1 x_1; ?H2 x_1 x_2\<rbrakk> \<Longrightarrow> ?H3 x_1 x_3 \<noteq> ?H3 x_2 x_3
[ "Derangements_Enum.no_overlap", "Derangements_Enum.no_overlap_dom", "List.nth", "List.concat", "Derangements_Enum.derangement_enum_dom", "List.list.map", "List.length" ]
[ "fun no_overlap :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> bool\" where\n \"no_overlap _ [] = True\"\n| \"no_overlap [] _ = True\"\n| \"no_overlap (x#xs) (y#ys) = (x \\<noteq> y \\<and> no_overlap xs ys)\"", "primrec (nonexhaustive) nth :: \"'a list => nat => 'a\" (infixl \"!\" 100) where\nnth_Cons: \"(x # xs) ! n = (case n of 0 \\<Rightarrow> x | Suc k \\<Rightarrow> xs ! k)\"\n \\<comment> \\<open>Warning: simpset does not contain this definition, but separate\n theorems for \\<open>n = 0\\<close> and \\<open>n = Suc k\\<close>\\<close>", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.derangement_enum_aux_set
lemma derangement_enum_aux_set: "length xs = length ys \<Longrightarrow> zs \<in> set (derangement_enum_aux xs ys) \<Longrightarrow> set zs = set ys"
length ?xs = length ?ys \<Longrightarrow> ?zs \<in> set (derangement_enum_aux ?xs ?ys) \<Longrightarrow> set ?zs = set ?ys
\<lbrakk>?H1 x_1 = ?H1 x_2; x_3 \<in> ?H2 (?H3 x_1 x_2)\<rbrakk> \<Longrightarrow> ?H4 x_3 = ?H4 x_2
[ "List.length", "Derangements_Enum.derangement_enum_aux", "List.list.set", "Derangements_Enum.no_overlap_dom" ]
[ "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "fun derangement_enum_aux :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> 'a list list\" where\n \"derangement_enum_aux [] ys = [[]]\"\n| \"derangement_enum_aux (x#xs) ys = [y#r . y \\<leftarrow> ys, r \\<leftarrow> derangement_enum_aux xs (remove1 y ys), y \\<noteq> x]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.derangement_enum_aux_not_in
lemma derangement_enum_aux_not_in: "y \<notin> set ys \<Longrightarrow> zs \<in> set (derangement_enum_aux xs ys) \<Longrightarrow> y \<notin> set zs"
?y \<notin> set ?ys \<Longrightarrow> ?zs \<in> set (derangement_enum_aux ?xs ?ys) \<Longrightarrow> ?y \<notin> set ?zs
\<lbrakk>?H1 x_1 (?H2 x_2); x_3 \<in> ?H3 (?H4 x_4 x_2)\<rbrakk> \<Longrightarrow> ?H1 x_1 (?H2 x_3)
[ "Derangements_Enum.derangement_enum_aux", "Set.not_member", "List.list.set", "List.nth" ]
[ "fun derangement_enum_aux :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> 'a list list\" where\n \"derangement_enum_aux [] ys = [[]]\"\n| \"derangement_enum_aux (x#xs) ys = [y#r . y \\<leftarrow> ys, r \\<leftarrow> derangement_enum_aux xs (remove1 y ys), y \\<noteq> x]\"", "abbreviation not_member\n where \"not_member x A \\<equiv> \\<not> (x \\<in> A)\" \\<comment> \\<open>non-membership\\<close>", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec (nonexhaustive) nth :: \"'a list => nat => 'a\" (infixl \"!\" 100) where\nnth_Cons: \"(x # xs) ! n = (case n of 0 \\<Rightarrow> x | Suc k \\<Rightarrow> xs ! k)\"\n \\<comment> \\<open>Warning: simpset does not contain this definition, but separate\n theorems for \\<open>n = 0\\<close> and \\<open>n = Suc k\\<close>\\<close>" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.derangement_enum_aux_in
lemma derangement_enum_aux_in: "y \<in> set zs \<Longrightarrow> zs \<in> set (derangement_enum_aux xs ys) \<Longrightarrow> y \<in> set ys"
?y \<in> set ?zs \<Longrightarrow> ?zs \<in> set (derangement_enum_aux ?xs ?ys) \<Longrightarrow> ?y \<in> set ?ys
\<lbrakk>x_1 \<in> ?H1 x_2; x_2 \<in> ?H2 (?H3 x_3 x_4)\<rbrakk> \<Longrightarrow> x_1 \<in> ?H1 x_4
[ "Derangements_Enum.derangement_enum_aux", "List.list.map", "List.list.set", "List.list.Cons", "List.distinct" ]
[ "fun derangement_enum_aux :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> 'a list list\" where\n \"derangement_enum_aux [] ys = [[]]\"\n| \"derangement_enum_aux (x#xs) ys = [y#r . y \\<leftarrow> ys, r \\<leftarrow> derangement_enum_aux xs (remove1 y ys), y \\<noteq> x]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.derangement_enum_aux_distinct_elem
lemma derangement_enum_aux_distinct_elem: "distinct ys \<Longrightarrow> zs \<in> set (derangement_enum_aux xs ys) \<Longrightarrow> distinct zs"
distinct ?ys \<Longrightarrow> ?zs \<in> set (derangement_enum_aux ?xs ?ys) \<Longrightarrow> distinct ?zs
\<lbrakk>?H1 x_1; x_2 \<in> ?H2 (?H3 x_3 x_1)\<rbrakk> \<Longrightarrow> ?H1 x_2
[ "Set.not_member", "Derangements_Enum.no_overlap", "List.distinct", "List.concat", "Derangements_Enum.derangement_enum_aux", "List.list.set" ]
[ "abbreviation not_member\n where \"not_member x A \\<equiv> \\<not> (x \\<in> A)\" \\<comment> \\<open>non-membership\\<close>", "fun no_overlap :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> bool\" where\n \"no_overlap _ [] = True\"\n| \"no_overlap [] _ = True\"\n| \"no_overlap (x#xs) (y#ys) = (x \\<noteq> y \\<and> no_overlap xs ys)\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "fun derangement_enum_aux :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> 'a list list\" where\n \"derangement_enum_aux [] ys = [[]]\"\n| \"derangement_enum_aux (x#xs) ys = [y#r . y \\<leftarrow> ys, r \\<leftarrow> derangement_enum_aux xs (remove1 y ys), y \\<noteq> x]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.derangement_enum_aux_elem_length
lemma derangement_enum_aux_elem_length: "zs \<in> set (derangement_enum_aux xs ys) \<Longrightarrow> length xs = length zs"
?zs \<in> set (derangement_enum_aux ?xs ?ys) \<Longrightarrow> length ?xs = length ?zs
x_1 \<in> ?H1 (?H2 x_2 x_3) \<Longrightarrow> ?H3 x_2 = ?H3 x_1
[ "Derangements_Enum.derangement_enum_aux", "List.length", "List.distinct", "Derangements_Enum.derangement_enum", "List.list.set" ]
[ "fun derangement_enum_aux :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> 'a list list\" where\n \"derangement_enum_aux [] ys = [[]]\"\n| \"derangement_enum_aux (x#xs) ys = [y#r . y \\<leftarrow> ys, r \\<leftarrow> derangement_enum_aux xs (remove1 y ys), y \\<noteq> x]\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "fun derangement_enum :: \"'a list \\<Rightarrow> 'a list list\" where\n \"derangement_enum xs = derangement_enum_aux xs xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.derangement_enum_aux_no_overlap
lemma derangement_enum_aux_no_overlap: "zs \<in> set (derangement_enum_aux xs ys) \<Longrightarrow> no_overlap xs zs"
?zs \<in> set (derangement_enum_aux ?xs ?ys) \<Longrightarrow> no_overlap ?xs ?zs
x_1 \<in> ?H1 (?H2 x_2 x_3) \<Longrightarrow> ?H3 x_2 x_1
[ "Derangements_Enum.derangement_enum_aux", "Derangements_Enum.derangements", "Derangements_Enum.no_overlap", "List.list.set", "List.list.Cons" ]
[ "fun derangement_enum_aux :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> 'a list list\" where\n \"derangement_enum_aux [] ys = [[]]\"\n| \"derangement_enum_aux (x#xs) ys = [y#r . y \\<leftarrow> ys, r \\<leftarrow> derangement_enum_aux xs (remove1 y ys), y \\<noteq> x]\"", "definition derangements :: \"'a list \\<Rightarrow> 'a list set\" where\n \"derangements xs = {ys. distinct ys \\<and> length xs = length ys \\<and> set xs = set ys \\<and> no_overlap xs ys }\"", "fun no_overlap :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> bool\" where\n \"no_overlap _ [] = True\"\n| \"no_overlap [] _ = True\"\n| \"no_overlap (x#xs) (y#ys) = (x \\<noteq> y \\<and> no_overlap xs ys)\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.derangement_enum_correct
theorem derangement_enum_correct: "distinct xs \<Longrightarrow> derangements xs = set (derangement_enum xs)"
distinct ?xs \<Longrightarrow> derangements ?xs = set (derangement_enum ?xs)
?H1 x_1 \<Longrightarrow> ?H2 x_1 = ?H3 (?H4 x_1)
[ "List.length", "Derangements_Enum.derangement_enum_dom", "Derangements_Enum.derangement_enum", "List.list.Cons", "List.list.set", "List.remove1", "Derangements_Enum.derangements", "List.distinct" ]
[ "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "fun derangement_enum :: \"'a list \\<Rightarrow> 'a list list\" where\n \"derangement_enum xs = derangement_enum_aux xs xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec remove1 :: \"'a \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n\"remove1 x [] = []\" |\n\"remove1 x (y # xs) = (if x = y then xs else y # remove1 x xs)\"", "definition derangements :: \"'a list \\<Rightarrow> 'a list set\" where\n \"derangements xs = {ys. distinct ys \\<and> length xs = length ys \\<and> set xs = set ys \\<and> no_overlap xs ys }\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.derangement_enum_aux_distinct
lemma derangement_enum_aux_distinct: "distinct ys \<Longrightarrow> distinct (derangement_enum_aux xs ys)"
distinct ?ys \<Longrightarrow> distinct (derangement_enum_aux ?xs ?ys)
?H1 x_1 \<Longrightarrow> ?H2 (?H3 x_2 x_1)
[ "List.list.Nil", "Derangements_Enum.derangement_enum_aux", "List.distinct" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun derangement_enum_aux :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> 'a list list\" where\n \"derangement_enum_aux [] ys = [[]]\"\n| \"derangement_enum_aux (x#xs) ys = [y#r . y \\<leftarrow> ys, r \\<leftarrow> derangement_enum_aux xs (remove1 y ys), y \\<noteq> x]\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"" ]
Combinatorial_Enumeration_Algorithms/Derangements_Enum
Derangements_Enum.derangement_enum_distinct
theorem derangement_enum_distinct: "distinct xs \<Longrightarrow> distinct (derangement_enum xs)"
distinct ?xs \<Longrightarrow> distinct (derangement_enum ?xs)
?H1 x_1 \<Longrightarrow> ?H2 (?H3 x_1)
[ "List.distinct", "Derangements_Enum.derangement_enum" ]
[ "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "fun derangement_enum :: \"'a list \\<Rightarrow> 'a list list\" where\n \"derangement_enum xs = derangement_enum_aux xs xs\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.inj2_distinct_concat_map_function_filter
lemma inj2_distinct_concat_map_function_filter: assumes "inj2 f" shows"\<lbrakk>\<forall> x \<in> set xs. distinct (g x); distinct xs\<rbrakk> \<Longrightarrow> distinct [f x y. x \<leftarrow> xs, y \<leftarrow> g x, h x]"
inj2 ?f \<Longrightarrow> \<forall>x\<in>set ?xs. distinct (?g x) \<Longrightarrow> distinct ?xs \<Longrightarrow> distinct (concat (map (\<lambda>x. concat (map (\<lambda>y. if ?h x then [?f x y] else []) (?g x))) ?xs))
\<lbrakk>?H1 x_1; \<forall>y_0\<in>?H2 x_2. ?H3 (x_3 y_0); ?H4 x_2\<rbrakk> \<Longrightarrow> ?H5 (?H6 (?H7 (\<lambda>y_1. ?H6 (?H8 (\<lambda>y_2. if x_4 y_1 then ?H9 (x_1 y_1 y_2) ?H10 else ?H10) (x_3 y_1))) x_2))
[ "List.list.Cons", "List.upt", "Groups_List.monoid_add_class.sum_list", "List.distinct", "List.concat", "Common_Lemmas.inj2", "List.list.set", "Set.empty", "List.list.Nil", "Set.insert", "List.list.map" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec upt :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list\" (\"(1[_..</_'])\") where\nupt_0: \"[i..<0] = []\" |\nupt_Suc: \"[i..<(Suc j)] = (if i \\<le> j then [i..<j] @ [j] else [])\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "abbreviation inj2 :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> bool\" where\n \"inj2 f \\<equiv> inj2_on f UNIV UNIV\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation empty :: \"'a set\" (\"{}\")\n where \"{} \\<equiv> bot\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition insert :: \"'a \\<Rightarrow> 'a set \\<Rightarrow> 'a set\"\n where insert_compr: \"insert a B = {x. x = a \\<or> x \\<in> B}\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.length_concat_map_function_sum_list
lemma length_concat_map_function_sum_list: assumes "\<And> x. x \<in> set xs \<Longrightarrow> length (g x) = h x" shows "length [f x r . x \<leftarrow> xs, r \<leftarrow> g x] = sum_list (map h xs)"
(\<And>x. x \<in> set ?xs \<Longrightarrow> length (?g x) = ?h x) \<Longrightarrow> length (concat (map (\<lambda>x. map (?f x) (?g x)) ?xs)) = sum_list (map ?h ?xs)
(\<And>y_0. y_0 \<in> ?H1 x_1 \<Longrightarrow> ?H2 (x_2 y_0) = x_3 y_0) \<Longrightarrow> ?H3 (?H4 (?H5 (\<lambda>y_1. ?H6 (x_4 y_1) (x_2 y_1)) x_1)) = ?H7 (?H8 x_3 x_1)
[ "List.list.set", "List.length", "List.concat", "Groups_List.monoid_add_class.sum_list", "List.list.map" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.inj2_distinct_concat_map_function
lemma inj2_distinct_concat_map_function: assumes "inj2 f" shows"\<lbrakk>\<forall> x \<in> set xs. distinct (g x); distinct xs\<rbrakk> \<Longrightarrow> distinct [f x y. x \<leftarrow> xs, y \<leftarrow> g x]"
inj2 ?f \<Longrightarrow> \<forall>x\<in>set ?xs. distinct (?g x) \<Longrightarrow> distinct ?xs \<Longrightarrow> distinct (concat (map (\<lambda>x. map (?f x) (?g x)) ?xs))
\<lbrakk>?H1 x_1; \<forall>y_0\<in>?H2 x_2. ?H3 (x_3 y_0); ?H4 x_2\<rbrakk> \<Longrightarrow> ?H5 (?H6 (?H7 (\<lambda>y_1. ?H8 (x_1 y_1) (x_3 y_1)) x_2))
[ "List.list.map", "List.list.set", "Common_Lemmas.inj2", "List.concat", "List.distinct" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation inj2 :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> bool\" where\n \"inj2 f \\<equiv> inj2_on f UNIV UNIV\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.inj2_on_distinct_concat_map
lemma inj2_on_distinct_concat_map: assumes "inj2_on f (set xs) (set ys)" shows "\<lbrakk>distinct ys; distinct xs\<rbrakk> \<Longrightarrow> distinct [f x y. x \<leftarrow> xs, y \<leftarrow> ys]"
inj2_on ?f (set ?xs) (set ?ys) \<Longrightarrow> distinct ?ys \<Longrightarrow> distinct ?xs \<Longrightarrow> distinct (concat (map (\<lambda>x. map (?f x) ?ys) ?xs))
\<lbrakk>?H1 x_1 (?H2 x_2) (?H3 x_3); ?H4 x_3; ?H5 x_2\<rbrakk> \<Longrightarrow> ?H6 (?H7 (?H8 (\<lambda>y_0. ?H9 (x_1 y_0) x_3) x_2))
[ "Set.insert", "List.list.map", "Set_Interval.ord_class.atMost", "List.distinct", "Common_Lemmas.inj2_on", "List.concat", "List.list.set", "List.remove1", "List.replicate" ]
[ "definition insert :: \"'a \\<Rightarrow> 'a set \\<Rightarrow> 'a set\"\n where insert_compr: \"insert a B = {x. x = a \\<or> x \\<in> B}\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "definition inj2_on :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> 'a set \\<Rightarrow> 'b set \\<Rightarrow> bool\" where\n \"inj2_on f A B \\<longleftrightarrow> (\\<forall>x1\\<in>A. \\<forall>x2\\<in>A. \\<forall>y1\\<in>B. \\<forall>y2\\<in>B. f x1 y1 = f x2 y2 \\<longrightarrow> x1 = x2 \\<and> y1 = y2)\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec remove1 :: \"'a \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n\"remove1 x [] = []\" |\n\"remove1 x (y # xs) = (if x = y then xs else y # remove1 x xs)\"", "primrec replicate :: \"nat \\<Rightarrow> 'a \\<Rightarrow> 'a list\" where\nreplicate_0: \"replicate 0 x = []\" |\nreplicate_Suc: \"replicate (Suc n) x = x # replicate n x\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.Cons_Suc_distinct_concat_map_function
lemma Cons_Suc_distinct_concat_map_function: "\<lbrakk>\<forall> x \<in> set xs. distinct (g x) ; distinct xs\<rbrakk> \<Longrightarrow> distinct [Suc x # y. x \<leftarrow> xs, y \<leftarrow> g x]"
\<forall>x\<in>set ?xs. distinct (?g x) \<Longrightarrow> distinct ?xs \<Longrightarrow> distinct (concat (map (\<lambda>x. map ((#) (Suc x)) (?g x)) ?xs))
\<lbrakk>\<forall>y_0\<in>?H1 x_1. ?H2 (x_2 y_0); ?H3 x_1\<rbrakk> \<Longrightarrow> ?H2 (?H4 (?H5 (\<lambda>y_1. ?H6 (?H7 (?H8 y_1)) (x_2 y_1)) x_1))
[ "List.list.Cons", "List.list.set", "Nat.Suc", "List.concat", "List.distinct", "List.list.map" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.inj2_distinct_concat_map
lemma inj2_distinct_concat_map: assumes "inj2 f" shows "\<lbrakk>distinct ys; distinct xs\<rbrakk> \<Longrightarrow> distinct [f x y. x \<leftarrow> xs, y \<leftarrow> ys]"
inj2 ?f \<Longrightarrow> distinct ?ys \<Longrightarrow> distinct ?xs \<Longrightarrow> distinct (concat (map (\<lambda>x. map (?f x) ?ys) ?xs))
\<lbrakk>?H1 x_1; ?H2 x_2; ?H3 x_3\<rbrakk> \<Longrightarrow> ?H4 (?H5 (?H6 (\<lambda>y_0. ?H7 (x_1 y_0) x_2) x_3))
[ "List.list.map", "Common_Lemmas.inj2", "List.concat", "Fun.inj_on", "List.distinct", "List.list.Cons", "Set_Interval.ord_class.atMost" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation inj2 :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> bool\" where\n \"inj2 f \\<equiv> inj2_on f UNIV UNIV\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "definition inj_on :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> 'a set \\<Rightarrow> bool\" \\<comment> \\<open>injective\\<close>\n where \"inj_on f A \\<longleftrightarrow> (\\<forall>x\\<in>A. \\<forall>y\\<in>A. f x = f y \\<longrightarrow> x = y)\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.Cons_distinct_concat_map_function
lemma Cons_distinct_concat_map_function: "\<lbrakk>\<forall> x \<in> set xs. distinct (g x) ; distinct xs\<rbrakk> \<Longrightarrow> distinct [x # y. x \<leftarrow> xs, y \<leftarrow> g x]"
\<forall>x\<in>set ?xs. distinct (?g x) \<Longrightarrow> distinct ?xs \<Longrightarrow> distinct (concat (map (\<lambda>x. map ((#) x) (?g x)) ?xs))
\<lbrakk>\<forall>y_0\<in>?H1 x_1. ?H2 (x_2 y_0); ?H3 x_1\<rbrakk> \<Longrightarrow> ?H2 (?H4 (?H5 (\<lambda>y_1. ?H6 (?H7 y_1) (x_2 y_1)) x_1))
[ "Nat.Suc", "Groups_List.monoid_add_class.sum_list", "List.list.set", "List.list.Cons", "List.concat", "Set_Interval.ord_class.lessThan", "List.list.map", "List.distinct" ]
[ "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.Cons_distinct_concat_map_function_distinct_on_all
lemma Cons_distinct_concat_map_function_distinct_on_all: "\<lbrakk>\<forall> x. distinct (g x) ; distinct xs\<rbrakk> \<Longrightarrow> distinct [x # y. x \<leftarrow> xs, y \<leftarrow> g x]"
\<forall>x. distinct (?g x) \<Longrightarrow> distinct ?xs \<Longrightarrow> distinct (concat (map (\<lambda>x. map ((#) x) (?g x)) ?xs))
\<lbrakk>\<forall>y_0. ?H1 (x_1 y_0); ?H2 x_2\<rbrakk> \<Longrightarrow> ?H1 (?H3 (?H4 (\<lambda>y_1. ?H5 (?H6 y_1) (x_1 y_1)) x_2))
[ "List.list.Cons", "List.distinct", "List.concat", "List.list.map" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.sum_list_extract_last
lemma sum_list_extract_last: "(\<Sum>x\<leftarrow>[0..<Suc n]. f x) = (\<Sum>x\<leftarrow>[0..<n]. f x) + f n"
sum_list (map ?f [0..<Suc ?n]) = sum_list (map ?f [0..<?n]) + ?f ?n
?H1 (?H2 x_1 (?H3 ?H4 (?H5 x_2))) = ?H6 (?H1 (?H2 x_1 (?H3 ?H4 x_2))) (x_1 x_2)
[ "Set_Interval.ord_class.atMost", "List.list.map", "Groups.times_class.times", "Set.not_member", "Nat.Suc", "List.upt", "Groups.zero_class.zero", "Fun.inj", "Groups_List.monoid_add_class.sum_list", "Groups.plus_class.plus" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "class times =\n fixes times :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"*\" 70)", "abbreviation not_member\n where \"not_member x A \\<equiv> \\<not> (x \\<in> A)\" \\<comment> \\<open>non-membership\\<close>", "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"", "primrec upt :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list\" (\"(1[_..</_'])\") where\nupt_0: \"[i..<0] = []\" |\nupt_Suc: \"[i..<(Suc j)] = (if i \\<le> j then [i..<j] @ [j] else [])\"", "class zero =\n fixes zero :: 'a (\"0\")", "abbreviation inj :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> bool\"\n where \"inj f \\<equiv> inj_on f UNIV\"", "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.Node_right_distinct_concat_map
lemma Node_right_distinct_concat_map: "\<lbrakk>distinct ys; distinct xs\<rbrakk> \<Longrightarrow> distinct [Node x e y. x \<leftarrow> xs, y \<leftarrow> ys]"
distinct ?ys \<Longrightarrow> distinct ?xs \<Longrightarrow> distinct (concat (map (\<lambda>x. map (Node x ?e) ?ys) ?xs))
\<lbrakk>?H1 x_1; ?H1 x_2\<rbrakk> \<Longrightarrow> ?H1 (?H2 (?H3 (\<lambda>y_0. ?H4 (?H5 y_0 x_3) x_1) x_2))
[ "Tree.tree.Node", "Set.not_member", "List.length", "List.distinct", "List.concat", "List.list.map" ]
[ "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")", "abbreviation not_member\n where \"not_member x A \\<equiv> \\<not> (x \\<in> A)\" \\<comment> \\<open>non-membership\\<close>", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.Cons_distinct_concat_map
lemma Cons_distinct_concat_map: "\<lbrakk>distinct ys; distinct xs\<rbrakk> \<Longrightarrow> distinct [x#y. x \<leftarrow> xs, y \<leftarrow> ys]"
distinct ?ys \<Longrightarrow> distinct ?xs \<Longrightarrow> distinct (concat (map (\<lambda>x. map ((#) x) ?ys) ?xs))
\<lbrakk>?H1 x_1; ?H2 x_2\<rbrakk> \<Longrightarrow> ?H1 (?H3 (?H4 (\<lambda>y_0. ?H5 (?H6 y_0) x_1) x_2))
[ "List.concat", "Product_Type.Times", "List.distinct", "Groups_List.monoid_add_class.sum_list", "List.list.map", "List.list.Cons", "Fun.inj_on" ]
[ "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "abbreviation Times :: \"'a set \\<Rightarrow> 'b set \\<Rightarrow> ('a \\<times> 'b) set\" (infixr \"\\<times>\" 80)\n where \"A \\<times> B \\<equiv> Sigma A (\\<lambda>_. B)\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition inj_on :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> 'a set \\<Rightarrow> bool\" \\<comment> \\<open>injective\\<close>\n where \"inj_on f A \\<longleftrightarrow> (\\<forall>x\\<in>A. \\<forall>y\\<in>A. f x = f y \\<longrightarrow> x = y)\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.inj2_on_distinct_map
lemma inj2_on_distinct_map: assumes "inj2_on f {x} (set xs)" shows "distinct xs = distinct (map (f x) xs)"
inj2_on ?f {?x} (set ?xs) \<Longrightarrow> distinct ?xs = distinct (map (?f ?x) ?xs)
?H1 x_1 (?H2 x_2 ?H3) (?H4 x_3) \<Longrightarrow> ?H5 x_3 = ?H6 (?H7 (x_1 x_2) x_3)
[ "Fun.inj_on", "List.list.Cons", "List.list.map", "Set.empty", "List.list.set", "Common_Lemmas.inj2_on", "List.distinct", "Set.insert", "Groups.zero_class.zero", "Tree.tree.Node" ]
[ "definition inj_on :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> 'a set \\<Rightarrow> bool\" \\<comment> \\<open>injective\\<close>\n where \"inj_on f A \\<longleftrightarrow> (\\<forall>x\\<in>A. \\<forall>y\\<in>A. f x = f y \\<longrightarrow> x = y)\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation empty :: \"'a set\" (\"{}\")\n where \"{} \\<equiv> bot\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition inj2_on :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> 'a set \\<Rightarrow> 'b set \\<Rightarrow> bool\" where\n \"inj2_on f A B \\<longleftrightarrow> (\\<forall>x1\\<in>A. \\<forall>x2\\<in>A. \\<forall>y1\\<in>B. \\<forall>y2\\<in>B. f x1 y1 = f x2 y2 \\<longrightarrow> x1 = x2 \\<and> y1 = y2)\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "definition insert :: \"'a \\<Rightarrow> 'a set \\<Rightarrow> 'a set\"\n where insert_compr: \"insert a B = {x. x = a \\<or> x \\<in> B}\"", "class zero =\n fixes zero :: 'a (\"0\")", "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.length_concat_map
lemma length_concat_map: "length [f x r . x \<leftarrow> xs, r \<leftarrow> ys] = length ys * length xs"
length (concat (map (\<lambda>x. map (?f x) ?ys) ?xs)) = length ?ys * length ?xs
?H1 (?H2 (?H3 (\<lambda>y_0. ?H4 (x_1 y_0) x_2) x_3)) = ?H5 (?H6 x_2) (?H7 x_3)
[ "List.concat", "List.list.map", "List.length", "List.remove1", "Groups.times_class.times", "Fun.inj", "Groups_Big.comm_monoid_add_class.sum" ]
[ "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec remove1 :: \"'a \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n\"remove1 x [] = []\" |\n\"remove1 x (y # xs) = (if x = y then xs else y # remove1 x xs)\"", "class times =\n fixes times :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"*\" 70)", "abbreviation inj :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> bool\"\n where \"inj f \\<equiv> inj_on f UNIV\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.leq_sum_to_sum_list
lemma leq_sum_to_sum_list: "(\<Sum>x \<le> n. f x) = (\<Sum>x\<leftarrow>[0..<Suc n]. f x)"
sum ?f {..?n} = sum_list (map ?f [0..<Suc ?n])
?H1 x_1 (?H2 x_2) = ?H3 (?H4 x_1 (?H5 ?H6 (?H7 x_2)))
[ "List.remove1", "Set.empty", "Groups.zero_class.zero", "List.upt", "Set_Interval.ord_class.atMost", "Groups_List.monoid_add_class.sum_list", "Groups_Big.comm_monoid_add_class.sum", "List.list.map", "Nat.Suc" ]
[ "primrec remove1 :: \"'a \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n\"remove1 x [] = []\" |\n\"remove1 x (y # xs) = (if x = y then xs else y # remove1 x xs)\"", "abbreviation empty :: \"'a set\" (\"{}\")\n where \"{} \\<equiv> bot\"", "class zero =\n fixes zero :: 'a (\"0\")", "primrec upt :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list\" (\"(1[_..</_'])\") where\nupt_0: \"[i..<0] = []\" |\nupt_Suc: \"[i..<(Suc j)] = (if i \\<le> j then [i..<j] @ [j] else [])\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.less_sum_to_sum_list
lemma less_sum_to_sum_list: "(\<Sum>x < n. f x) = (\<Sum>x\<leftarrow>[0..< n]. f x)"
sum ?f {..<?n} = sum_list (map ?f [0..<?n])
?H1 x_1 (?H2 x_2) = ?H3 (?H4 x_1 (?H5 ?H6 x_2))
[ "List.count_list", "List.upt", "Set.not_member", "List.list.map", "Groups.zero_class.zero", "Groups_List.monoid_add_class.sum_list", "Groups_Big.comm_monoid_add_class.sum", "Set_Interval.ord_class.lessThan", "Set.insert" ]
[ "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "primrec upt :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list\" (\"(1[_..</_'])\") where\nupt_0: \"[i..<0] = []\" |\nupt_Suc: \"[i..<(Suc j)] = (if i \\<le> j then [i..<j] @ [j] else [])\"", "abbreviation not_member\n where \"not_member x A \\<equiv> \\<not> (x \\<in> A)\" \\<comment> \\<open>non-membership\\<close>", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "class zero =\n fixes zero :: 'a (\"0\")", "definition insert :: \"'a \\<Rightarrow> 'a set \\<Rightarrow> 'a set\"\n where insert_compr: \"insert a B = {x. x = a \\<or> x \\<in> B}\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.Suc_length_remove1
lemma Suc_length_remove1: "x \<in> set xs \<Longrightarrow> Suc (length (remove1 x xs)) = length xs"
?x \<in> set ?xs \<Longrightarrow> Suc (length (remove1 ?x ?xs)) = length ?xs
x_1 \<in> ?H1 x_2 \<Longrightarrow> ?H2 (?H3 (?H4 x_1 x_2)) = ?H3 x_2
[ "List.length", "Set.not_member", "Groups.zero_class.zero", "List.remove1", "Set_Interval.ord_class.atMost", "Nat.Suc", "Product_Type.Unity", "List.list.set" ]
[ "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "abbreviation not_member\n where \"not_member x A \\<equiv> \\<not> (x \\<in> A)\" \\<comment> \\<open>non-membership\\<close>", "class zero =\n fixes zero :: 'a (\"0\")", "primrec remove1 :: \"'a \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n\"remove1 x [] = []\" |\n\"remove1 x (y # xs) = (if x = y then xs else y # remove1 x xs)\"", "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"", "definition Unity :: unit (\"'(')\")\n where \"() = Abs_unit True\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.inj2_distinct_map
lemma inj2_distinct_map: assumes "inj2 f" shows "distinct xs = distinct (map (f x) xs)"
inj2 ?f \<Longrightarrow> distinct ?xs = distinct (map (?f ?x) ?xs)
?H1 x_1 \<Longrightarrow> ?H2 x_2 = ?H3 (?H4 (x_1 x_3) x_2)
[ "Common_Lemmas.inj2", "List.distinct", "Groups.times_class.times", "List.list.map" ]
[ "abbreviation inj2 :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> bool\" where\n \"inj2 f \\<equiv> inj2_on f UNIV UNIV\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "class times =\n fixes times :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"*\" 70)", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.count_list_full_elem
lemma count_list_full_elem: "count_list xs y = length xs \<longleftrightarrow> (\<forall>x \<in> set xs. x = y)"
(count_list ?xs ?y = length ?xs) = (\<forall>x\<in>set ?xs. x = ?y)
(?H1 x_1 x_2 = ?H2 x_1) = (\<forall>y_0\<in>?H3 x_1. y_0 = x_2)
[ "Set.insert", "List.length", "List.count_list", "List.list.set", "Groups.plus_class.plus" ]
[ "definition insert :: \"'a \\<Rightarrow> 'a set \\<Rightarrow> 'a set\"\n where insert_compr: \"insert a B = {x. x = a \\<or> x \\<in> B}\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.count_list_length_replicate
lemma count_list_length_replicate: "count_list xs y = length xs \<longleftrightarrow> xs = replicate (length xs) y"
(count_list ?xs ?y = length ?xs) = (?xs = replicate (length ?xs) ?y)
(?H1 x_1 x_2 = ?H2 x_1) = (x_1 = ?H3 (?H2 x_1) x_2)
[ "Tree.tree.Node", "List.length", "List.count_list", "List.replicate", "Common_Lemmas.inj2" ]
[ "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "primrec replicate :: \"nat \\<Rightarrow> 'a \\<Rightarrow> 'a list\" where\nreplicate_0: \"replicate 0 x = []\" |\nreplicate_Suc: \"replicate (Suc n) x = x # replicate n x\"", "abbreviation inj2 :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> bool\" where\n \"inj2 f \\<equiv> inj2_on f UNIV UNIV\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.inj2_inj_second_flipped
lemma inj2_inj_second_flipped: "inj2 f \<Longrightarrow> inj (\<lambda>x. f x y)"
inj2 ?f \<Longrightarrow> inj (\<lambda>x. ?f x ?y)
?H1 x_1 \<Longrightarrow> ?H2 (\<lambda>y_0. x_1 y_0 x_2)
[ "Set_Interval.ord_class.atMost", "Common_Lemmas.inj2_on", "Groups.zero_class.zero", "Fun.inj", "Common_Lemmas.inj2" ]
[ "definition inj2_on :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> 'a set \\<Rightarrow> 'b set \\<Rightarrow> bool\" where\n \"inj2_on f A B \\<longleftrightarrow> (\\<forall>x1\\<in>A. \\<forall>x2\\<in>A. \\<forall>y1\\<in>B. \\<forall>y2\\<in>B. f x1 y1 = f x2 y2 \\<longrightarrow> x1 = x2 \\<and> y1 = y2)\"", "class zero =\n fixes zero :: 'a (\"0\")", "abbreviation inj :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> bool\"\n where \"inj f \\<equiv> inj_on f UNIV\"", "abbreviation inj2 :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> bool\" where\n \"inj2 f \\<equiv> inj2_on f UNIV UNIV\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.inj2_curried
lemma inj2_curried: "inj2_on (curry f) A B \<longleftrightarrow> inj_on f (A\<times>B)"
inj2_on (curry ?f) ?A ?B = inj_on ?f (?A \<times> ?B)
?H1 (?H2 x_1) x_2 x_3 = ?H3 x_1 (?H4 x_2 x_3)
[ "List.list.map", "Common_Lemmas.inj2_on", "Groups.plus_class.plus", "Fun.inj_on", "Set.empty", "Product_Type.Times", "Product_Type.curry" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition inj2_on :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> 'a set \\<Rightarrow> 'b set \\<Rightarrow> bool\" where\n \"inj2_on f A B \\<longleftrightarrow> (\\<forall>x1\\<in>A. \\<forall>x2\\<in>A. \\<forall>y1\\<in>B. \\<forall>y2\\<in>B. f x1 y1 = f x2 y2 \\<longrightarrow> x1 = x2 \\<and> y1 = y2)\"", "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)", "definition inj_on :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> 'a set \\<Rightarrow> bool\" \\<comment> \\<open>injective\\<close>\n where \"inj_on f A \\<longleftrightarrow> (\\<forall>x\\<in>A. \\<forall>y\\<in>A. f x = f y \\<longrightarrow> x = y)\"", "abbreviation empty :: \"'a set\" (\"{}\")\n where \"{} \\<equiv> bot\"", "abbreviation Times :: \"'a set \\<Rightarrow> 'b set \\<Rightarrow> ('a \\<times> 'b) set\" (infixr \"\\<times>\" 80)\n where \"A \\<times> B \\<equiv> Sigma A (\\<lambda>_. B)\"", "definition curry :: \"('a \\<times> 'b \\<Rightarrow> 'c) \\<Rightarrow> 'a \\<Rightarrow> 'b \\<Rightarrow> 'c\"\n where \"curry = (\\<lambda>c x y. c (x, y))\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.count_list_zero_not_elem
lemma count_list_zero_not_elem: "count_list xs x = 0 \<longleftrightarrow> x \<notin> set xs"
(count_list ?xs ?x = 0) = (?x \<notin> set ?xs)
(?H1 x_1 x_2 = ?H2) = ?H3 x_2 (?H4 x_1)
[ "List.list.set", "Product_Type.curry", "List.count_list", "Set.not_member", "Groups.zero_class.zero", "Fun.inj", "List.remove1" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition curry :: \"('a \\<times> 'b \\<Rightarrow> 'c) \\<Rightarrow> 'a \\<Rightarrow> 'b \\<Rightarrow> 'c\"\n where \"curry = (\\<lambda>c x y. c (x, y))\"", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "abbreviation not_member\n where \"not_member x A \\<equiv> \\<not> (x \\<in> A)\" \\<comment> \\<open>non-membership\\<close>", "class zero =\n fixes zero :: 'a (\"0\")", "abbreviation inj :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> bool\"\n where \"inj f \\<equiv> inj_on f UNIV\"", "primrec remove1 :: \"'a \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n\"remove1 x [] = []\" |\n\"remove1 x (y # xs) = (if x = y then xs else y # remove1 x xs)\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.Node_left_distinct_map
lemma Node_left_distinct_map: "distinct xs = distinct (map (\<lambda>l. \<langle>l, (), r\<rangle>) xs)"
distinct ?xs = distinct (map (\<lambda>l. \<langle>l, (), ?r\<rangle>) ?xs)
?H1 x_1 = ?H1 (?H2 (\<lambda>y_0. ?H3 y_0 ?H4 x_2) x_1)
[ "List.count_list", "Tree.tree.Node", "Product_Type.Unity", "List.list.Cons", "List.distinct", "List.list.map", "Set_Interval.ord_class.atMost" ]
[ "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")", "definition Unity :: unit (\"'(')\")\n where \"() = Abs_unit True\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.inj2_inj_second
lemma inj2_inj_second: "inj2 f \<Longrightarrow> inj (f x)"
inj2 ?f \<Longrightarrow> inj (?f ?x)
?H1 x_1 \<Longrightarrow> ?H2 (x_1 x_2)
[ "Common_Lemmas.inj2", "Groups.plus_class.plus", "Fun.inj", "List.list.Cons" ]
[ "abbreviation inj2 :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> bool\" where\n \"inj2 f \\<equiv> inj2_on f UNIV UNIV\"", "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)", "abbreviation inj :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> bool\"\n where \"inj f \\<equiv> inj_on f UNIV\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.inj2_on_all
lemma inj2_on_all: "inj2 f \<Longrightarrow> inj2_on f A B"
inj2 ?f \<Longrightarrow> inj2_on ?f ?A ?B
?H1 x_1 \<Longrightarrow> ?H2 x_1 x_2 x_3
[ "Groups.plus_class.plus", "Common_Lemmas.inj2_on", "List.upt", "Common_Lemmas.inj2", "Set.insert" ]
[ "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)", "definition inj2_on :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> 'a set \\<Rightarrow> 'b set \\<Rightarrow> bool\" where\n \"inj2_on f A B \\<longleftrightarrow> (\\<forall>x1\\<in>A. \\<forall>x2\\<in>A. \\<forall>y1\\<in>B. \\<forall>y2\\<in>B. f x1 y1 = f x2 y2 \\<longrightarrow> x1 = x2 \\<and> y1 = y2)\"", "primrec upt :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list\" (\"(1[_..</_'])\") where\nupt_0: \"[i..<0] = []\" |\nupt_Suc: \"[i..<(Suc j)] = (if i \\<le> j then [i..<j] @ [j] else [])\"", "abbreviation inj2 :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> bool\" where\n \"inj2 f \\<equiv> inj2_on f UNIV UNIV\"", "definition insert :: \"'a \\<Rightarrow> 'a set \\<Rightarrow> 'a set\"\n where insert_compr: \"insert a B = {x. x = a \\<or> x \\<in> B}\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.count_list_True_False
lemma count_list_True_False: "count_list xs True + count_list xs False = length xs"
count_list ?xs True + count_list ?xs False = length ?xs
?H1 (?H2 x_1 True) (?H2 x_1 False) = ?H3 x_1
[ "List.length", "List.count_list", "List.distinct", "Groups.plus_class.plus" ]
[ "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.inj2_inj_first
lemma inj2_inj_first: "inj2 f \<Longrightarrow> inj f"
inj2 ?f \<Longrightarrow> inj ?f
?H1 x_1 \<Longrightarrow> ?H2 x_1
[ "Set_Interval.ord_class.atMost", "Fun.inj", "Common_Lemmas.inj2", "Product_Type.Times" ]
[ "abbreviation inj :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> bool\"\n where \"inj f \\<equiv> inj_on f UNIV\"", "abbreviation inj2 :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> bool\" where\n \"inj2 f \\<equiv> inj2_on f UNIV UNIV\"", "abbreviation Times :: \"'a set \\<Rightarrow> 'b set \\<Rightarrow> ('a \\<times> 'b) set\" (infixr \"\\<times>\" 80)\n where \"A \\<times> B \\<equiv> Sigma A (\\<lambda>_. B)\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.Node_right_inj2
lemma Node_right_inj2: "inj2 (\<lambda>l r. Node l e r)"
inj2 (\<lambda>l. Node l ?e)
?H1 (\<lambda>y_0. ?H2 y_0 x_1)
[ "Tree.tree.Node", "Groups_Big.comm_monoid_add_class.sum", "Common_Lemmas.inj2", "List.list.Cons" ]
[ "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")", "abbreviation inj2 :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> bool\" where\n \"inj2 f \\<equiv> inj2_on f UNIV UNIV\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.Node_left_inj2
lemma Node_left_inj2: "inj2 (\<lambda>r l. Node l e r)"
inj2 (\<lambda>r l. \<langle>l, ?e, r\<rangle>)
?H1 (\<lambda>y_0 y_1. ?H2 y_1 x_1 y_0)
[ "Tree.tree.Node", "Common_Lemmas.inj2", "Groups.plus_class.plus", "Fun.inj" ]
[ "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")", "abbreviation inj2 :: \"('a \\<Rightarrow> 'b \\<Rightarrow> 'c) \\<Rightarrow> bool\" where\n \"inj2 f \\<equiv> inj2_on f UNIV UNIV\"", "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)", "abbreviation inj :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> bool\"\n where \"inj f \\<equiv> inj_on f UNIV\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.count_list_replicate
lemma count_list_replicate: "count_list (replicate x y) y = x"
count_list (replicate ?x ?y) ?y = ?x
?H1 (?H2 x_1 x_2) x_2 = x_1
[ "List.replicate", "List.count_list", "List.list.Nil" ]
[ "primrec replicate :: \"nat \\<Rightarrow> 'a \\<Rightarrow> 'a list\" where\nreplicate_0: \"replicate 0 x = []\" |\nreplicate_Suc: \"replicate (Suc n) x = x # replicate n x\"", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Common_Lemmas
Common_Lemmas.distinct_concat_Nil
lemma distinct_concat_Nil: "distinct (concat (map (\<lambda>y. []) xs))"
distinct (concat (map (\<lambda>y. []) ?xs))
?H1 (?H2 (?H3 (\<lambda>y_0. ?H4) x_1))
[ "Set.insert", "List.list.Nil", "Fun.inj_on", "List.concat", "List.distinct", "List.list.map", "Groups.plus_class.plus", "Groups.zero_class.zero" ]
[ "definition insert :: \"'a \\<Rightarrow> 'a set \\<Rightarrow> 'a set\"\n where insert_compr: \"insert a B = {x. x = a \\<or> x \\<in> B}\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition inj_on :: \"('a \\<Rightarrow> 'b) \\<Rightarrow> 'a set \\<Rightarrow> bool\" \\<comment> \\<open>injective\\<close>\n where \"inj_on f A \\<longleftrightarrow> (\\<forall>x\\<in>A. \\<forall>y\\<in>A. f x = f y \\<longrightarrow> x = y)\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)", "class zero =\n fixes zero :: 'a (\"0\")" ]
Combinatorial_Enumeration_Algorithms/Powerset
Powerset.distinct_concat_aux
lemma distinct_concat_aux: "distinct xs \<Longrightarrow> distinct (concat (map (\<lambda>xs. [False # xs, True # xs]) xs))"
distinct ?xs \<Longrightarrow> distinct (concat (map (\<lambda>xs. [False # xs, True # xs]) ?xs))
?H1 x_1 \<Longrightarrow> ?H1 (?H2 (?H3 (\<lambda>y_0. ?H4 (?H5 False y_0) (?H4 (?H5 True y_0) ?H6)) x_1))
[ "List.list.Nil", "Set.Pow", "List.distinct", "List.list.Cons", "Filter_Bool_List.filter_bool_list", "List.list.map", "List.length", "List.concat", "Set.Collect" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition Pow :: \"'a set \\<Rightarrow> 'a set set\"\n where Pow_def: \"Pow A = {B. B \\<subseteq> A}\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun filter_bool_list :: \"bool list \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n \"filter_bool_list [] _ = []\"\n| \"filter_bool_list _ [] = []\"\n| \"filter_bool_list (b#bs) (x#xs) =\n (if b then x#(filter_bool_list bs xs) else (filter_bool_list bs xs))\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"" ]
Combinatorial_Enumeration_Algorithms/Powerset
Powerset.powerset_enum_distinct_elem
theorem powerset_enum_distinct_elem: "distinct xs \<Longrightarrow> ys \<in> set (powerset_enum xs) \<Longrightarrow> distinct ys"
distinct ?xs \<Longrightarrow> ?ys \<in> set (powerset_enum ?xs) \<Longrightarrow> distinct ?ys
\<lbrakk>?H1 x_1; x_2 \<in> ?H2 (?H3 x_1)\<rbrakk> \<Longrightarrow> ?H1 x_2
[ "Powerset.all_bool_lists_dom", "List.list.set", "Powerset.powerset_enum", "List.distinct", "List.list.map", "Powerset.all_bool_lists2" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun powerset_enum where\n \"powerset_enum xs = [(filter_bool_list x xs) . x \\<leftarrow> all_bool_lists (length xs)]\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun all_bool_lists2 :: \"nat \\<Rightarrow> bool list list\" where\n \"all_bool_lists2 n = n_sequence_enum [True, False] n\"" ]
Combinatorial_Enumeration_Algorithms/Powerset
Powerset.all_bool_lists_correct
lemma all_bool_lists_correct: "set (all_bool_lists x) = {xs. length xs = x}"
set (all_bool_lists ?x) = {xs. length xs = ?x}
?H1 (?H2 x_1) = ?H3 (\<lambda>y_0. ?H4 y_0 = x_1)
[ "Set.Collect", "Powerset.all_bool_lists", "Powerset.all_bool_lists2", "List.length", "List.list.set" ]
[ "fun all_bool_lists :: \"nat \\<Rightarrow> bool list list\" where\n \"all_bool_lists 0 = [[]]\"\n| \"all_bool_lists (Suc x) = concat [[False#xs, True#xs] . xs \\<leftarrow> all_bool_lists x]\"", "fun all_bool_lists2 :: \"nat \\<Rightarrow> bool list list\" where\n \"all_bool_lists2 n = n_sequence_enum [True, False] n\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Powerset
Powerset.powerset_enum_correct
theorem powerset_enum_correct: "set (map set (powerset_enum xs)) = Pow (set xs)"
set (map set (powerset_enum ?xs)) = Pow (set ?xs)
?H1 (?H2 ?H3 (?H4 x_1)) = ?H5 (?H3 x_1)
[ "Set.Pow", "Filter_Bool_List.filter_bool_list", "Powerset.powerset_enum_dom", "List.list.set", "List.list.map", "List.list.Nil", "Powerset.powerset_enum" ]
[ "definition Pow :: \"'a set \\<Rightarrow> 'a set set\"\n where Pow_def: \"Pow A = {B. B \\<subseteq> A}\"", "fun filter_bool_list :: \"bool list \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n \"filter_bool_list [] _ = []\"\n| \"filter_bool_list _ [] = []\"\n| \"filter_bool_list (b#bs) (x#xs) =\n (if b then x#(filter_bool_list bs xs) else (filter_bool_list bs xs))\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun powerset_enum where\n \"powerset_enum xs = [(filter_bool_list x xs) . x \\<leftarrow> all_bool_lists (length xs)]\"" ]
Combinatorial_Enumeration_Algorithms/Powerset
Powerset.powerset_enum_distinct
theorem powerset_enum_distinct: "distinct xs \<Longrightarrow> distinct (powerset_enum xs)"
distinct ?xs \<Longrightarrow> distinct (powerset_enum ?xs)
?H1 x_1 \<Longrightarrow> ?H2 (?H3 x_1)
[ "List.list.Cons", "Powerset.powerset_enum", "List.concat", "Powerset.all_bool_lists", "List.distinct", "List.list.Nil" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun powerset_enum where\n \"powerset_enum xs = [(filter_bool_list x xs) . x \\<leftarrow> all_bool_lists (length xs)]\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "fun all_bool_lists :: \"nat \\<Rightarrow> bool list list\" where\n \"all_bool_lists 0 = [[]]\"\n| \"all_bool_lists (Suc x) = concat [[False#xs, True#xs] . xs \\<leftarrow> all_bool_lists x]\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Powerset
Powerset.all_bool_lists2_correct
lemma all_bool_lists2_correct: "set (all_bool_lists n) = set (all_bool_lists2 n)"
set (all_bool_lists ?n) = set (all_bool_lists2 ?n)
?H1 (?H2 x_1) = ?H1 (?H3 x_1)
[ "List.length", "List.list.set", "Powerset.all_bool_lists2", "Powerset.all_bool_lists" ]
[ "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun all_bool_lists2 :: \"nat \\<Rightarrow> bool list list\" where\n \"all_bool_lists2 n = n_sequence_enum [True, False] n\"", "fun all_bool_lists :: \"nat \\<Rightarrow> bool list list\" where\n \"all_bool_lists 0 = [[]]\"\n| \"all_bool_lists (Suc x) = concat [[False#xs, True#xs] . xs \\<leftarrow> all_bool_lists x]\"" ]
Combinatorial_Enumeration_Algorithms/Powerset
Powerset.all_bool_lists2_distinct
lemma all_bool_lists2_distinct: "distinct (all_bool_lists2 n)"
distinct (all_bool_lists2 ?n)
?H1 (?H2 x_1)
[ "n_Sequences.n_sequence_enum", "Filter_Bool_List.filter_bool_list", "List.distinct", "List.concat", "Powerset.all_bool_lists2" ]
[ "fun n_sequence_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_sequence_enum xs 0 = [[]]\"\n| \"n_sequence_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_sequence_enum xs n]\"", "fun filter_bool_list :: \"bool list \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n \"filter_bool_list [] _ = []\"\n| \"filter_bool_list _ [] = []\"\n| \"filter_bool_list (b#bs) (x#xs) =\n (if b then x#(filter_bool_list bs xs) else (filter_bool_list bs xs))\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "fun all_bool_lists2 :: \"nat \\<Rightarrow> bool list list\" where\n \"all_bool_lists2 n = n_sequence_enum [True, False] n\"" ]
Combinatorial_Enumeration_Algorithms/Powerset
Powerset.distinct_all_bool_lists
lemma distinct_all_bool_lists : "distinct (all_bool_lists x)"
distinct (all_bool_lists ?x)
?H1 (?H2 x_1)
[ "Powerset.all_bool_lists", "List.distinct", "Filter_Bool_List.filter_bool_list", "List.length", "Powerset.all_bool_lists2" ]
[ "fun all_bool_lists :: \"nat \\<Rightarrow> bool list list\" where\n \"all_bool_lists 0 = [[]]\"\n| \"all_bool_lists (Suc x) = concat [[False#xs, True#xs] . xs \\<leftarrow> all_bool_lists x]\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "fun filter_bool_list :: \"bool list \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n \"filter_bool_list [] _ = []\"\n| \"filter_bool_list _ [] = []\"\n| \"filter_bool_list (b#bs) (x#xs) =\n (if b then x#(filter_bool_list bs xs) else (filter_bool_list bs xs))\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "fun all_bool_lists2 :: \"nat \\<Rightarrow> bool list list\" where\n \"all_bool_lists2 n = n_sequence_enum [True, False] n\"" ]
Combinatorial_Enumeration_Algorithms/n_Permutations
n_Permutations.n_permutation_enum_elem_distinct
lemma n_permutation_enum_elem_distinct: "distinct xs \<Longrightarrow> ys \<in> set (n_permutation_enum xs n) \<Longrightarrow> distinct ys"
distinct ?xs \<Longrightarrow> ?ys \<in> set (n_permutation_enum ?xs ?n) \<Longrightarrow> distinct ?ys
\<lbrakk>?H1 x_1; x_2 \<in> ?H2 (?H3 x_1 x_3)\<rbrakk> \<Longrightarrow> ?H1 x_2
[ "Groups.zero_class.zero", "List.list.set", "List.list.Nil", "List.distinct", "n_Permutations.n_permutation_enum" ]
[ "class zero =\n fixes zero :: 'a (\"0\")", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "fun n_permutation_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_permutation_enum xs 0 = [[]]\"\n| \"n_permutation_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_permutation_enum (remove1 x xs) n]\"" ]
Combinatorial_Enumeration_Algorithms/n_Permutations
n_Permutations.n_permutation_enum_correct2
lemma n_permutation_enum_correct2: "ys \<in> n_permutations (set xs) n \<Longrightarrow> ys \<in> set (n_permutation_enum xs n)"
?ys \<in> n_permutations (set ?xs) ?n \<Longrightarrow> ?ys \<in> set (n_permutation_enum ?xs ?n)
x_1 \<in> ?H1 (?H2 x_2) x_3 \<Longrightarrow> x_1 \<in> ?H3 (?H4 x_2 x_3)
[ "List.remdups", "n_Permutations.n_permutations", "List.length", "List.list.set", "n_Permutations.n_permutation_enum" ]
[ "primrec remdups :: \"'a list \\<Rightarrow> 'a list\" where\n\"remdups [] = []\" |\n\"remdups (x # xs) = (if x \\<in> set xs then remdups xs else x # remdups xs)\"", "definition n_permutations :: \"'a set \\<Rightarrow> nat \\<Rightarrow> 'a list set\" where\n \"n_permutations A n = {xs. set xs \\<subseteq> A \\<and> distinct xs \\<and> length xs = n}\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun n_permutation_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_permutation_enum xs 0 = [[]]\"\n| \"n_permutation_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_permutation_enum (remove1 x xs) n]\"" ]
Combinatorial_Enumeration_Algorithms/n_Permutations
n_Permutations.n_multiset_permutation_enum_correct1
lemma n_multiset_permutation_enum_correct1: "mset ys \<subseteq># mset xs \<Longrightarrow> ys \<in> set (n_permutation_enum xs (length ys))"
mset ?ys \<subseteq># mset ?xs \<Longrightarrow> ?ys \<in> set (n_permutation_enum ?xs (length ?ys))
?H1 (?H2 x_1) (?H2 x_2) \<Longrightarrow> x_1 \<in> ?H3 (?H4 x_2 (?H5 x_1))
[ "Multiset.mset", "Multiset.subseteq_mset", "n_Permutations.n_permutation_enum", "List.list.Nil", "List.list.set", "List.length" ]
[ "primrec mset :: \"'a list \\<Rightarrow> 'a multiset\" where\n \"mset [] = {#}\" |\n \"mset (a # x) = add_mset a (mset x)\"", "definition subseteq_mset :: \"'a multiset \\<Rightarrow> 'a multiset \\<Rightarrow> bool\" (infix \"\\<subseteq>#\" 50)\n where \"A \\<subseteq># B \\<longleftrightarrow> (\\<forall>a. count A a \\<le> count B a)\"", "fun n_permutation_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_permutation_enum xs 0 = [[]]\"\n| \"n_permutation_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_permutation_enum (remove1 x xs) n]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"" ]
Combinatorial_Enumeration_Algorithms/n_Permutations
n_Permutations.n_permutation_enum_subset
lemma n_permutation_enum_subset: "ys \<in> set (n_permutation_enum xs n) \<Longrightarrow> set ys \<subseteq> set xs "
?ys \<in> set (n_permutation_enum ?xs ?n) \<Longrightarrow> set ?ys \<subseteq> set ?xs
x_1 \<in> ?H1 (?H2 x_2 x_3) \<Longrightarrow> ?H3 (?H4 x_1) (?H4 x_2)
[ "n_Permutations.n_permutation_enum", "List.list.set", "List.list.Nil", "Set.subset_eq", "n_Permutations.n_multiset_permutations", "List.remove1" ]
[ "fun n_permutation_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_permutation_enum xs 0 = [[]]\"\n| \"n_permutation_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_permutation_enum (remove1 x xs) n]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation subset_eq :: \"'a set \\<Rightarrow> 'a set \\<Rightarrow> bool\"\n where \"subset_eq \\<equiv> less_eq\"", "definition n_multiset_permutations :: \"'a multiset \\<Rightarrow> nat \\<Rightarrow> 'a list set\" where\n \"n_multiset_permutations A n = {xs. mset xs \\<subseteq># A \\<and> length xs = n}\"", "primrec remove1 :: \"'a \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n\"remove1 x [] = []\" |\n\"remove1 x (y # xs) = (if x = y then xs else y # remove1 x xs)\"" ]
Combinatorial_Enumeration_Algorithms/n_Permutations
n_Permutations.n_multiset_permutation_enum_correct2
lemma n_multiset_permutation_enum_correct2: "ys \<in> set (n_permutation_enum xs n) \<Longrightarrow> mset ys \<subseteq># mset xs"
?ys \<in> set (n_permutation_enum ?xs ?n) \<Longrightarrow> mset ?ys \<subseteq># mset ?xs
x_1 \<in> ?H1 (?H2 x_2 x_3) \<Longrightarrow> ?H3 (?H4 x_1) (?H4 x_2)
[ "n_Permutations.n_permutation_enum", "List.list.set", "Multiset.subseteq_mset", "Multiset.mset", "List.length", "List.list.Nil", "Set.subset_eq" ]
[ "fun n_permutation_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_permutation_enum xs 0 = [[]]\"\n| \"n_permutation_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_permutation_enum (remove1 x xs) n]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition subseteq_mset :: \"'a multiset \\<Rightarrow> 'a multiset \\<Rightarrow> bool\" (infix \"\\<subseteq>#\" 50)\n where \"A \\<subseteq># B \\<longleftrightarrow> (\\<forall>a. count A a \\<le> count B a)\"", "primrec mset :: \"'a list \\<Rightarrow> 'a multiset\" where\n \"mset [] = {#}\" |\n \"mset (a # x) = add_mset a (mset x)\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation subset_eq :: \"'a set \\<Rightarrow> 'a set \\<Rightarrow> bool\"\n where \"subset_eq \\<equiv> less_eq\"" ]
Combinatorial_Enumeration_Algorithms/n_Permutations
n_Permutations.n_permutation_enum_correct1
lemma n_permutation_enum_correct1: "distinct xs \<Longrightarrow> set (n_permutation_enum xs n) \<subseteq> n_permutations (set xs) n"
distinct ?xs \<Longrightarrow> set (n_permutation_enum ?xs ?n) \<subseteq> n_permutations (set ?xs) ?n
?H1 x_1 \<Longrightarrow> ?H2 (?H3 (?H4 x_1 x_2)) (?H5 (?H6 x_1) x_2)
[ "List.distinct", "List.list.Nil", "n_Permutations.n_permutations", "Set.subset_eq", "n_Permutations.n_permutation_enum", "List.list.set" ]
[ "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition n_permutations :: \"'a set \\<Rightarrow> nat \\<Rightarrow> 'a list set\" where\n \"n_permutations A n = {xs. set xs \\<subseteq> A \\<and> distinct xs \\<and> length xs = n}\"", "abbreviation subset_eq :: \"'a set \\<Rightarrow> 'a set \\<Rightarrow> bool\"\n where \"subset_eq \\<equiv> less_eq\"", "fun n_permutation_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_permutation_enum xs 0 = [[]]\"\n| \"n_permutation_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_permutation_enum (remove1 x xs) n]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/n_Permutations
n_Permutations.n_permutation_enum_correct
theorem n_permutation_enum_correct: "distinct xs \<Longrightarrow> set (n_permutation_enum xs n) = n_permutations (set xs) n"
distinct ?xs \<Longrightarrow> set (n_permutation_enum ?xs ?n) = n_permutations (set ?xs) ?n
?H1 x_1 \<Longrightarrow> ?H2 (?H3 x_1 x_2) = ?H4 (?H5 x_1) x_2
[ "List.list.set", "List.distinct", "n_Permutations.n_permutations", "n_Permutations.n_permutation_enum" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "definition n_permutations :: \"'a set \\<Rightarrow> nat \\<Rightarrow> 'a list set\" where\n \"n_permutations A n = {xs. set xs \\<subseteq> A \\<and> distinct xs \\<and> length xs = n}\"", "fun n_permutation_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_permutation_enum xs 0 = [[]]\"\n| \"n_permutation_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_permutation_enum (remove1 x xs) n]\"" ]
Combinatorial_Enumeration_Algorithms/n_Permutations
n_Permutations.n_permutation_enum_length
lemma n_permutation_enum_length: "ys \<in> set (n_permutation_enum xs n) \<Longrightarrow> length ys = n"
?ys \<in> set (n_permutation_enum ?xs ?n) \<Longrightarrow> length ?ys = ?n
x_1 \<in> ?H1 (?H2 x_2 x_3) \<Longrightarrow> ?H3 x_1 = x_3
[ "n_Permutations.n_multiset_permutation_enum_dom", "List.length", "n_Permutations.n_multiset_permutations", "List.list.set", "n_Permutations.n_permutation_enum", "Groups.zero_class.zero", "n_Permutations.n_permutation_enum_dom" ]
[ "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "definition n_multiset_permutations :: \"'a multiset \\<Rightarrow> nat \\<Rightarrow> 'a list set\" where\n \"n_multiset_permutations A n = {xs. mset xs \\<subseteq># A \\<and> length xs = n}\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun n_permutation_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_permutation_enum xs 0 = [[]]\"\n| \"n_permutation_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_permutation_enum (remove1 x xs) n]\"", "class zero =\n fixes zero :: 'a (\"0\")" ]
Combinatorial_Enumeration_Algorithms/n_Permutations
n_Permutations.n_multiset_permutation_enum_correct
lemma n_multiset_permutation_enum_correct: "set (n_multiset_permutation_enum xs n) = n_multiset_permutations (mset xs) n"
set (n_multiset_permutation_enum ?xs ?n) = n_multiset_permutations (mset ?xs) ?n
?H1 (?H2 x_1 x_2) = ?H3 (?H4 x_1) x_2
[ "Multiset.mset", "List.list.set", "n_Permutations.n_permutations", "n_Permutations.n_multiset_permutation_enum", "n_Permutations.n_multiset_permutations" ]
[ "primrec mset :: \"'a list \\<Rightarrow> 'a multiset\" where\n \"mset [] = {#}\" |\n \"mset (a # x) = add_mset a (mset x)\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition n_permutations :: \"'a set \\<Rightarrow> nat \\<Rightarrow> 'a list set\" where\n \"n_permutations A n = {xs. set xs \\<subseteq> A \\<and> distinct xs \\<and> length xs = n}\"", "fun n_multiset_permutation_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_multiset_permutation_enum xs n = remdups (n_permutation_enum xs n)\"", "definition n_multiset_permutations :: \"'a multiset \\<Rightarrow> nat \\<Rightarrow> 'a list set\" where\n \"n_multiset_permutations A n = {xs. mset xs \\<subseteq># A \\<and> length xs = n}\"" ]
Combinatorial_Enumeration_Algorithms/n_Permutations
n_Permutations.n_permutation_distinct
theorem n_permutation_distinct: "distinct xs \<Longrightarrow> distinct (n_permutation_enum xs n)"
distinct ?xs \<Longrightarrow> distinct (n_permutation_enum ?xs ?n)
?H1 x_1 \<Longrightarrow> ?H2 (?H3 x_1 x_2)
[ "n_Permutations.n_permutation_enum", "List.distinct", "Set.subset_eq" ]
[ "fun n_permutation_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_permutation_enum xs 0 = [[]]\"\n| \"n_permutation_enum xs (Suc n) = [x#r . x \\<leftarrow> xs, r \\<leftarrow> n_permutation_enum (remove1 x xs) n]\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "abbreviation subset_eq :: \"'a set \\<Rightarrow> 'a set \\<Rightarrow> bool\"\n where \"subset_eq \\<equiv> less_eq\"" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.concat_map_Node_not_equal
lemma concat_map_Node_not_equal: "xs \<noteq> [] \<Longrightarrow> xs2 \<noteq> [] \<Longrightarrow> ys \<noteq> [] \<Longrightarrow> ys2 \<noteq> [] \<Longrightarrow> \<forall> x\<in> set xs. \<forall> y \<in> set ys . x \<noteq> y \<Longrightarrow> [\<langle>l, (), r\<rangle>. l \<leftarrow> xs2, r \<leftarrow> xs] \<noteq> [\<langle>l, (), r\<rangle>. l \<leftarrow> ys2, r \<leftarrow> ys]"
?xs \<noteq> [] \<Longrightarrow> ?xs2.0 \<noteq> [] \<Longrightarrow> ?ys \<noteq> [] \<Longrightarrow> ?ys2.0 \<noteq> [] \<Longrightarrow> \<forall>x\<in>set ?xs. \<forall>y\<in>set ?ys. x \<noteq> y \<Longrightarrow> concat (map (\<lambda>l. map (Node l ()) ?xs) ?xs2.0) \<noteq> concat (map (\<lambda>l. map (Node l ()) ?ys) ?ys2.0)
\<lbrakk>x_1 \<noteq> ?H1; x_2 \<noteq> ?H1; x_3 \<noteq> ?H1; x_4 \<noteq> ?H1; \<forall>y_0\<in>?H2 x_1. \<forall>y_1\<in>?H2 x_3. y_0 \<noteq> y_1\<rbrakk> \<Longrightarrow> ?H3 (?H4 (\<lambda>y_2. ?H5 (?H6 y_2 ?H7) x_1) x_2) \<noteq> ?H3 (?H4 (\<lambda>y_4. ?H5 (?H6 y_4 ?H7) x_3) x_4)
[ "List.list.Nil", "List.concat", "Groups.minus_class.minus", "List.list.map", "Product_Type.Unity", "Tree.tree.Node", "List.list.set" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "class minus =\n fixes minus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"-\" 65)", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition Unity :: unit (\"'(')\")\n where \"() = Abs_unit True\"", "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.tree_enum_distinct_aux_outer
lemma tree_enum_distinct_aux_outer: assumes "\<forall>i \<le> n. distinct (tree_enum i)" and "distinct xs" and "\<forall> i \<in> set xs. i < n" and "sorted_wrt (<) xs" shows "distinct (map (\<lambda>i. [\<langle>l, (), r\<rangle>. l \<leftarrow> tree_enum i, r \<leftarrow> tree_enum (n-i)]) xs)"
\<forall>i\<le>?n. distinct (tree_enum i) \<Longrightarrow> distinct ?xs \<Longrightarrow> \<forall>i\<in>set ?xs. i < ?n \<Longrightarrow> sorted_wrt (<) ?xs \<Longrightarrow> distinct (map (\<lambda>i. concat (map (\<lambda>l. map (Node l ()) (tree_enum (?n - i))) (tree_enum i))) ?xs)
\<lbrakk>\<forall>y_0\<le>x_1. ?H1 (?H2 y_0); ?H3 x_2; \<forall>y_1\<in>?H4 x_2. y_1 < x_1; ?H5 (<) x_2\<rbrakk> \<Longrightarrow> ?H6 (?H7 (\<lambda>y_2. ?H8 (?H9 (\<lambda>y_3. ?H10 (?H11 y_3 ?H12) (?H2 (?H13 x_1 y_2))) (?H2 y_2))) x_2)
[ "List.concat", "List.list.map", "List.distinct", "Product_Type.Unity", "List.sorted_wrt", "Trees.tree_enum", "Groups.minus_class.minus", "List.list.set", "Tree.tree.Node" ]
[ "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "definition Unity :: unit (\"'(')\")\n where \"() = Abs_unit True\"", "fun sorted_wrt :: \"('a \\<Rightarrow> 'a \\<Rightarrow> bool) \\<Rightarrow> 'a list \\<Rightarrow> bool\" where\n\"sorted_wrt P [] = True\" |\n\"sorted_wrt P (x # ys) = ((\\<forall>y \\<in> set ys. P x y) \\<and> sorted_wrt P ys)\"", "fun tree_enum :: \"nat \\<Rightarrow> unit tree list\" where\n\"tree_enum 0 = [Leaf]\" |\n\"tree_enum (Suc n) = [\\<langle>t1, (), t2\\<rangle>. i \\<leftarrow> [0..<Suc n], t1 \\<leftarrow> tree_enum i, t2 \\<leftarrow> tree_enum (n-i)]\"", "class minus =\n fixes minus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"-\" 65)", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.tree_enum_distinct_aux_left
lemma tree_enum_distinct_aux_left: "\<forall> i < n. distinct (tree_enum i) \<Longrightarrow> distinct ([\<langle>l, (), r\<rangle>. i \<leftarrow> [0..< n], l \<leftarrow> tree_enum i])"
\<forall>i<?n. distinct (tree_enum i) \<Longrightarrow> distinct (concat (map (\<lambda>i. map (\<lambda>l. \<langle>l, (), ?r\<rangle>) (tree_enum i)) [0..<?n]))
\<forall>y_0<x_1. ?H1 (?H2 y_0) \<Longrightarrow> ?H1 (?H3 (?H4 (\<lambda>y_1. ?H5 (\<lambda>y_2. ?H6 y_2 ?H7 x_2) (?H2 y_1)) (?H8 ?H9 x_1)))
[ "List.upt", "Product_Type.Unity", "List.list.map", "List.sorted_wrt", "Trees.trees", "Groups.zero_class.zero", "List.distinct", "List.concat", "Groups_Big.comm_monoid_add_class.sum", "Trees.tree_enum", "Tree.tree.Node", "Trees.tree_enum_dom" ]
[ "primrec upt :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list\" (\"(1[_..</_'])\") where\nupt_0: \"[i..<0] = []\" |\nupt_Suc: \"[i..<(Suc j)] = (if i \\<le> j then [i..<j] @ [j] else [])\"", "definition Unity :: unit (\"'(')\")\n where \"() = Abs_unit True\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun sorted_wrt :: \"('a \\<Rightarrow> 'a \\<Rightarrow> bool) \\<Rightarrow> 'a list \\<Rightarrow> bool\" where\n\"sorted_wrt P [] = True\" |\n\"sorted_wrt P (x # ys) = ((\\<forall>y \\<in> set ys. P x y) \\<and> sorted_wrt P ys)\"", "definition trees :: \"nat \\<Rightarrow> unit tree set\" where\n \"trees n = {t. size t = n}\"", "class zero =\n fixes zero :: 'a (\"0\")", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "fun tree_enum :: \"nat \\<Rightarrow> unit tree list\" where\n\"tree_enum 0 = [Leaf]\" |\n\"tree_enum (Suc n) = [\\<langle>t1, (), t2\\<rangle>. i \\<leftarrow> [0..<Suc n], t1 \\<leftarrow> tree_enum i, t2 \\<leftarrow> tree_enum (n-i)]\"", "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.tree_enum_elem_injective
lemma tree_enum_elem_injective: "n \<noteq> m \<Longrightarrow> x \<in> set (tree_enum n) \<Longrightarrow> y \<in> set (tree_enum m) \<Longrightarrow> x \<noteq> y"
?n \<noteq> ?m \<Longrightarrow> ?x \<in> set (tree_enum ?n) \<Longrightarrow> ?y \<in> set (tree_enum ?m) \<Longrightarrow> ?x \<noteq> ?y
\<lbrakk>x_1 \<noteq> x_2; x_3 \<in> ?H1 (?H2 x_1); x_4 \<in> ?H1 (?H2 x_2)\<rbrakk> \<Longrightarrow> x_3 \<noteq> x_4
[ "Trees.tree_enum", "Nat.Suc", "List.list.set" ]
[ "fun tree_enum :: \"nat \\<Rightarrow> unit tree list\" where\n\"tree_enum 0 = [Leaf]\" |\n\"tree_enum (Suc n) = [\\<langle>t1, (), t2\\<rangle>. i \\<leftarrow> [0..<Suc n], t1 \\<leftarrow> tree_enum i, t2 \\<leftarrow> tree_enum (n-i)]\"", "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.tree_enum_elem_injective2
lemma tree_enum_elem_injective2: "x \<in> set (tree_enum n) \<Longrightarrow> y \<in> set (tree_enum m) \<Longrightarrow> x = y \<Longrightarrow> n = m"
?x \<in> set (tree_enum ?n) \<Longrightarrow> ?y \<in> set (tree_enum ?m) \<Longrightarrow> ?x = ?y \<Longrightarrow> ?n = ?m
\<lbrakk>x_1 \<in> ?H1 (?H2 x_2); x_3 \<in> ?H1 (?H2 x_4); x_1 = x_3\<rbrakk> \<Longrightarrow> x_2 = x_4
[ "List.list.set", "Groups_Big.comm_monoid_add_class.sum", "Trees.tree_enum", "List.upt" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun tree_enum :: \"nat \\<Rightarrow> unit tree list\" where\n\"tree_enum 0 = [Leaf]\" |\n\"tree_enum (Suc n) = [\\<langle>t1, (), t2\\<rangle>. i \\<leftarrow> [0..<Suc n], t1 \\<leftarrow> tree_enum i, t2 \\<leftarrow> tree_enum (n-i)]\"", "primrec upt :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list\" (\"(1[_..</_'])\") where\nupt_0: \"[i..<0] = []\" |\nupt_Suc: \"[i..<(Suc j)] = (if i \\<le> j then [i..<j] @ [j] else [])\"" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.length_tree_enum
lemma length_tree_enum: "length (tree_enum(Suc n)) = (\<Sum>i\<le>n. length(tree_enum i) * length(tree_enum (n - i)))"
length (tree_enum (Suc ?n)) = (\<Sum>i\<le>?n. length (tree_enum i) * length (tree_enum (?n - i)))
?H1 (?H2 (?H3 x_1)) = ?H4 (\<lambda>y_0. ?H5 (?H1 (?H2 y_0)) (?H1 (?H2 (?H6 x_1 y_0)))) (?H7 x_1)
[ "List.length", "Trees.tree_enum", "Groups_Big.comm_monoid_add_class.sum", "List.distinct", "List.concat", "Nat.Suc", "Groups.minus_class.minus", "Tree.tree.Leaf", "Groups.times_class.times", "Set_Interval.ord_class.atMost" ]
[ "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "fun tree_enum :: \"nat \\<Rightarrow> unit tree list\" where\n\"tree_enum 0 = [Leaf]\" |\n\"tree_enum (Suc n) = [\\<langle>t1, (), t2\\<rangle>. i \\<leftarrow> [0..<Suc n], t1 \\<leftarrow> tree_enum i, t2 \\<leftarrow> tree_enum (n-i)]\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"", "class minus =\n fixes minus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"-\" 65)", "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")", "class times =\n fixes times :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"*\" 70)" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.tree_enum_correct1
lemma tree_enum_correct1: "t \<in> set (tree_enum n) \<Longrightarrow> size t = n"
?t \<in> set (tree_enum ?n) \<Longrightarrow> size ?t = ?n
x_1 \<in> ?H1 (?H2 x_2) \<Longrightarrow> ?H3 x_1 = x_2
[ "Nat.size_class.size", "Trees.tree_enum", "List.list.set" ]
[ "class size =\n fixes size :: \"'a \\<Rightarrow> nat\" \\<comment> \\<open>see further theory \\<open>Wellfounded\\<close>\\<close>", "fun tree_enum :: \"nat \\<Rightarrow> unit tree list\" where\n\"tree_enum 0 = [Leaf]\" |\n\"tree_enum (Suc n) = [\\<langle>t1, (), t2\\<rangle>. i \\<leftarrow> [0..<Suc n], t1 \\<leftarrow> tree_enum i, t2 \\<leftarrow> tree_enum (n-i)]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.tree_enum_correct2
lemma tree_enum_correct2: "n = size t \<Longrightarrow> t \<in> set (tree_enum n)"
?n = size ?t \<Longrightarrow> ?t \<in> set (tree_enum ?n)
x_1 = ?H1 x_2 \<Longrightarrow> x_2 \<in> ?H2 (?H3 x_1)
[ "Trees.tree_enum", "Tree.tree.Node", "List.list.set", "Nat.size_class.size", "List.list.map" ]
[ "fun tree_enum :: \"nat \\<Rightarrow> unit tree list\" where\n\"tree_enum 0 = [Leaf]\" |\n\"tree_enum (Suc n) = [\\<langle>t1, (), t2\\<rangle>. i \\<leftarrow> [0..<Suc n], t1 \\<leftarrow> tree_enum i, t2 \\<leftarrow> tree_enum (n-i)]\"", "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "class size =\n fixes size :: \"'a \\<Rightarrow> nat\" \\<comment> \\<open>see further theory \\<open>Wellfounded\\<close>\\<close>", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.tree_enum_Leaf
lemma tree_enum_Leaf: "\<langle>\<rangle> \<in> set (tree_enum n) \<longleftrightarrow> (n = 0)"
(\<langle>\<rangle> \<in> set (tree_enum ?n)) = (?n = 0)
(?H1 \<in> ?H2 (?H3 x_1)) = (x_1 = ?H4)
[ "Trees.tree_enum", "Tree.tree.Leaf", "Groups.zero_class.zero", "Tree.tree.Node", "List.list.set", "List.distinct" ]
[ "fun tree_enum :: \"nat \\<Rightarrow> unit tree list\" where\n\"tree_enum 0 = [Leaf]\" |\n\"tree_enum (Suc n) = [\\<langle>t1, (), t2\\<rangle>. i \\<leftarrow> [0..<Suc n], t1 \\<leftarrow> tree_enum i, t2 \\<leftarrow> tree_enum (n-i)]\"", "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")", "class zero =\n fixes zero :: 'a (\"0\")", "datatype 'a tree =\n Leaf (\"\\<langle>\\<rangle>\") |\n Node \"'a tree\" (\"value\": 'a) \"'a tree\" (\"(1\\<langle>_,/ _,/ _\\<rangle>)\")", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.tree_enum_correct
theorem tree_enum_correct: "set(tree_enum n) = trees n"
set (tree_enum ?n) = trees ?n
?H1 (?H2 x_1) = ?H3 x_1
[ "Trees.tree_enum", "List.list.set", "Trees.trees" ]
[ "fun tree_enum :: \"nat \\<Rightarrow> unit tree list\" where\n\"tree_enum 0 = [Leaf]\" |\n\"tree_enum (Suc n) = [\\<langle>t1, (), t2\\<rangle>. i \\<leftarrow> [0..<Suc n], t1 \\<leftarrow> tree_enum i, t2 \\<leftarrow> tree_enum (n-i)]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition trees :: \"nat \\<Rightarrow> unit tree set\" where\n \"trees n = {t. size t = n}\"" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.tree_enum_not_empty
lemma tree_enum_not_empty: "tree_enum n \<noteq> []"
tree_enum ?n \<noteq> []
?H1 x_1 \<noteq> ?H2
[ "Product_Type.Unity", "Trees.tree_enum", "Trees.trees", "List.list.Nil" ]
[ "definition Unity :: unit (\"'(')\")\n where \"() = Abs_unit True\"", "fun tree_enum :: \"nat \\<Rightarrow> unit tree list\" where\n\"tree_enum 0 = [Leaf]\" |\n\"tree_enum (Suc n) = [\\<langle>t1, (), t2\\<rangle>. i \\<leftarrow> [0..<Suc n], t1 \\<leftarrow> tree_enum i, t2 \\<leftarrow> tree_enum (n-i)]\"", "definition trees :: \"nat \\<Rightarrow> unit tree set\" where\n \"trees n = {t. size t = n}\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Trees
Trees.tree_enum_distinct
theorem tree_enum_distinct: "distinct(tree_enum n)"
distinct (tree_enum ?n)
?H1 (?H2 x_1)
[ "Trees.tree_enum", "Nat.size_class.size", "List.distinct", "List.sorted_wrt" ]
[ "fun tree_enum :: \"nat \\<Rightarrow> unit tree list\" where\n\"tree_enum 0 = [Leaf]\" |\n\"tree_enum (Suc n) = [\\<langle>t1, (), t2\\<rangle>. i \\<leftarrow> [0..<Suc n], t1 \\<leftarrow> tree_enum i, t2 \\<leftarrow> tree_enum (n-i)]\"", "class size =\n fixes size :: \"'a \\<Rightarrow> nat\" \\<comment> \\<open>see further theory \\<open>Wellfounded\\<close>\\<close>", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "fun sorted_wrt :: \"('a \\<Rightarrow> 'a \\<Rightarrow> bool) \\<Rightarrow> 'a list \\<Rightarrow> bool\" where\n\"sorted_wrt P [] = True\" |\n\"sorted_wrt P (x # ys) = ((\\<forall>y \\<in> set ys. P x y) \\<and> sorted_wrt P ys)\"" ]
Combinatorial_Enumeration_Algorithms/Weak_Integer_Compositions
Weak_Integer_Compositions.weak_integer_composition_enum_head
lemma weak_integer_composition_enum_head: assumes "xs \<in> set (weak_integer_composition_enum (sum_list xs) (length xs))" shows "x # xs \<in> set (weak_integer_composition_enum (x + sum_list xs) (Suc (length xs)))"
?xs \<in> set (weak_integer_composition_enum (sum_list ?xs) (length ?xs)) \<Longrightarrow> ?x # ?xs \<in> set (weak_integer_composition_enum (?x + sum_list ?xs) (Suc (length ?xs)))
x_1 \<in> ?H1 (?H2 (?H3 x_1) (?H4 x_1)) \<Longrightarrow> ?H5 x_2 x_1 \<in> ?H1 (?H2 (?H6 x_2 (?H3 x_1)) (?H7 (?H4 x_1)))
[ "List.concat", "List.list.set", "Weak_Integer_Compositions.weak_integer_composition_enum", "List.list.Cons", "Groups.plus_class.plus", "List.length", "Groups_List.monoid_add_class.sum_list", "Nat.Suc" ]
[ "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun weak_integer_composition_enum :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list list\" where\n \"weak_integer_composition_enum i 0 = (if i = 0 then [[]] else [])\"\n| \"weak_integer_composition_enum i (Suc 0) = [[i]]\"\n| \"weak_integer_composition_enum i l =\n [h#r . h \\<leftarrow> [0..< Suc i], r \\<leftarrow> weak_integer_composition_enum (i-h) (l-1)]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"" ]
Combinatorial_Enumeration_Algorithms/Weak_Integer_Compositions
Weak_Integer_Compositions.a_choose_equivalence
lemma a_choose_equivalence: "Suc (\<Sum>x\<leftarrow>[0..<k]. n + (k - x) choose (k - x)) = Suc (n + k) choose k"
Suc (\<Sum>x\<leftarrow>[0..<?k]. ?n + (?k - x) choose (?k - x)) = Suc (?n + ?k) choose ?k
?H1 (?H2 (?H3 (\<lambda>y_0. ?H4 (?H5 x_1 (?H6 x_2 y_0)) (?H6 x_2 y_0)) (?H7 ?H8 x_2))) = ?H4 (?H1 (?H5 x_1 x_2)) x_2
[ "Groups.plus_class.plus", "List.list.map", "List.upt", "Binomial.binomial", "Groups_List.monoid_add_class.sum_list", "Groups.minus_class.minus", "Nat.Suc", "Groups.zero_class.zero" ]
[ "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec upt :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list\" (\"(1[_..</_'])\") where\nupt_0: \"[i..<0] = []\" |\nupt_Suc: \"[i..<(Suc j)] = (if i \\<le> j then [i..<j] @ [j] else [])\"", "definition binomial :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat\" (infixl \"choose\" 65)\n where \"n choose k = card {K\\<in>Pow {0..<n}. card K = k}\"", "class minus =\n fixes minus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"-\" 65)", "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"", "class zero =\n fixes zero :: 'a (\"0\")" ]
Combinatorial_Enumeration_Algorithms/Weak_Integer_Compositions
Weak_Integer_Compositions.weak_integer_composition_enum_length
lemma weak_integer_composition_enum_length: "xs \<in> set (weak_integer_composition_enum i l) \<Longrightarrow> length xs = l"
?xs \<in> set (weak_integer_composition_enum ?i ?l) \<Longrightarrow> length ?xs = ?l
x_1 \<in> ?H1 (?H2 x_2 x_3) \<Longrightarrow> ?H3 x_1 = x_3
[ "Groups.minus_class.minus", "List.distinct", "List.list.map", "List.list.set", "Weak_Integer_Compositions.weak_integer_composition_enum", "List.length", "Nat.Suc" ]
[ "class minus =\n fixes minus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"-\" 65)", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun weak_integer_composition_enum :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list list\" where\n \"weak_integer_composition_enum i 0 = (if i = 0 then [[]] else [])\"\n| \"weak_integer_composition_enum i (Suc 0) = [[i]]\"\n| \"weak_integer_composition_enum i l =\n [h#r . h \\<leftarrow> [0..< Suc i], r \\<leftarrow> weak_integer_composition_enum (i-h) (l-1)]\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"" ]
Combinatorial_Enumeration_Algorithms/Weak_Integer_Compositions
Weak_Integer_Compositions.weak_integer_composition_enum_sum_list
lemma weak_integer_composition_enum_sum_list: "xs \<in> set (weak_integer_composition_enum i l) \<Longrightarrow> sum_list xs = i"
?xs \<in> set (weak_integer_composition_enum ?i ?l) \<Longrightarrow> sum_list ?xs = ?i
x_1 \<in> ?H1 (?H2 x_2 x_3) \<Longrightarrow> ?H3 x_1 = x_2
[ "Weak_Integer_Compositions.weak_integer_composition_enum", "Binomial.binomial", "List.list.Nil", "List.list.set", "List.list.map", "Groups_List.monoid_add_class.sum_list" ]
[ "fun weak_integer_composition_enum :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list list\" where\n \"weak_integer_composition_enum i 0 = (if i = 0 then [[]] else [])\"\n| \"weak_integer_composition_enum i (Suc 0) = [[i]]\"\n| \"weak_integer_composition_enum i l =\n [h#r . h \\<leftarrow> [0..< Suc i], r \\<leftarrow> weak_integer_composition_enum (i-h) (l-1)]\"", "definition binomial :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat\" (infixl \"choose\" 65)\n where \"n choose k = card {K\\<in>Pow {0..<n}. card K = k}\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Weak_Integer_Compositions
Weak_Integer_Compositions.weak_integer_composition_enum_correct_aux
lemma weak_integer_composition_enum_correct_aux: "xs \<in> set (weak_integer_composition_enum (sum_list xs) (length xs))"
?xs \<in> set (weak_integer_composition_enum (sum_list ?xs) (length ?xs))
x_1 \<in> ?H1 (?H2 (?H3 x_1) (?H4 x_1))
[ "Weak_Integer_Compositions.multichoose", "List.list.set", "Binomial.binomial", "Groups_List.monoid_add_class.sum_list", "Weak_Integer_Compositions.weak_integer_composition_enum", "List.length" ]
[ "definition multichoose:: \"nat \\<Rightarrow> nat \\<Rightarrow> nat\" (infixl \"multichoose\" 65) where\n \"n multichoose k = (n + k -1) choose k\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition binomial :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat\" (infixl \"choose\" 65)\n where \"n choose k = card {K\\<in>Pow {0..<n}. card K = k}\"", "fun weak_integer_composition_enum :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list list\" where\n \"weak_integer_composition_enum i 0 = (if i = 0 then [[]] else [])\"\n| \"weak_integer_composition_enum i (Suc 0) = [[i]]\"\n| \"weak_integer_composition_enum i l =\n [h#r . h \\<leftarrow> [0..< Suc i], r \\<leftarrow> weak_integer_composition_enum (i-h) (l-1)]\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"" ]
Combinatorial_Enumeration_Algorithms/Weak_Integer_Compositions
Weak_Integer_Compositions.weak_integer_composition_enum_correct
theorem weak_integer_composition_enum_correct: "set (weak_integer_composition_enum i l) = weak_integer_compositions i l"
set (weak_integer_composition_enum ?i ?l) = weak_integer_compositions ?i ?l
?H1 (?H2 x_1 x_2) = ?H3 x_1 x_2
[ "List.concat", "Groups.one_class.one", "Weak_Integer_Compositions.weak_integer_compositions", "Weak_Integer_Compositions.weak_integer_composition_enum", "List.length", "Groups_List.monoid_add_class.sum_list", "List.list.set" ]
[ "primrec concat:: \"'a list list \\<Rightarrow> 'a list\" where\n\"concat [] = []\" |\n\"concat (x # xs) = x @ concat xs\"", "class one =\n fixes one :: 'a (\"1\")", "definition weak_integer_compositions :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list set\" where\n \"weak_integer_compositions i l = {xs. length xs = l \\<and> sum_list xs = i}\"", "fun weak_integer_composition_enum :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list list\" where\n \"weak_integer_composition_enum i 0 = (if i = 0 then [[]] else [])\"\n| \"weak_integer_composition_enum i (Suc 0) = [[i]]\"\n| \"weak_integer_composition_enum i l =\n [h#r . h \\<leftarrow> [0..< Suc i], r \\<leftarrow> weak_integer_composition_enum (i-h) (l-1)]\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/Weak_Integer_Compositions
Weak_Integer_Compositions.composition_enum_length
lemma composition_enum_length: "length (weak_integer_composition_enum i n) = n multichoose i"
length (weak_integer_composition_enum ?i ?n) = ?n multichoose ?i
?H1 (?H2 x_1 x_2) = ?H3 x_2 x_1
[ "List.length", "Groups.one_class.one", "Weak_Integer_Compositions.weak_integer_composition_enum", "Weak_Integer_Compositions.multichoose" ]
[ "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "class one =\n fixes one :: 'a (\"1\")", "fun weak_integer_composition_enum :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list list\" where\n \"weak_integer_composition_enum i 0 = (if i = 0 then [[]] else [])\"\n| \"weak_integer_composition_enum i (Suc 0) = [[i]]\"\n| \"weak_integer_composition_enum i l =\n [h#r . h \\<leftarrow> [0..< Suc i], r \\<leftarrow> weak_integer_composition_enum (i-h) (l-1)]\"", "definition multichoose:: \"nat \\<Rightarrow> nat \\<Rightarrow> nat\" (infixl \"multichoose\" 65) where\n \"n multichoose k = (n + k -1) choose k\"" ]
Combinatorial_Enumeration_Algorithms/Weak_Integer_Compositions
Weak_Integer_Compositions.weak_integer_compositions_cardinality
theorem weak_integer_compositions_cardinality: "card (weak_integer_compositions n k) = k multichoose n"
card (weak_integer_compositions ?n ?k) = ?k multichoose ?n
?H1 (?H2 x_1 x_2) = ?H3 x_2 x_1
[ "List.list.map", "Weak_Integer_Compositions.weak_integer_compositions", "Weak_Integer_Compositions.multichoose", "Finite_Set.card" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition weak_integer_compositions :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list set\" where\n \"weak_integer_compositions i l = {xs. length xs = l \\<and> sum_list xs = i}\"", "definition multichoose:: \"nat \\<Rightarrow> nat \\<Rightarrow> nat\" (infixl \"multichoose\" 65) where\n \"n multichoose k = (n + k -1) choose k\"" ]
Combinatorial_Enumeration_Algorithms/Weak_Integer_Compositions
Weak_Integer_Compositions.weak_integer_composition_enum_zero
lemma weak_integer_composition_enum_zero: "length (weak_integer_composition_enum 0 (Suc n)) = 1"
length (weak_integer_composition_enum 0 (Suc ?n)) = 1
?H1 (?H2 ?H3 (?H4 x_1)) = ?H5
[ "List.list.set", "Groups.one_class.one", "List.distinct", "Groups.zero_class.zero", "Nat.Suc", "Weak_Integer_Compositions.weak_integer_composition_enum", "List.length" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "class one =\n fixes one :: 'a (\"1\")", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "class zero =\n fixes zero :: 'a (\"0\")", "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"", "fun weak_integer_composition_enum :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list list\" where\n \"weak_integer_composition_enum i 0 = (if i = 0 then [[]] else [])\"\n| \"weak_integer_composition_enum i (Suc 0) = [[i]]\"\n| \"weak_integer_composition_enum i l =\n [h#r . h \\<leftarrow> [0..< Suc i], r \\<leftarrow> weak_integer_composition_enum (i-h) (l-1)]\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"" ]
Combinatorial_Enumeration_Algorithms/Weak_Integer_Compositions
Weak_Integer_Compositions.weak_integer_composition_enum_distinct
theorem weak_integer_composition_enum_distinct: "distinct (weak_integer_composition_enum i l)"
distinct (weak_integer_composition_enum ?i ?l)
?H1 (?H2 x_1 x_2)
[ "Finite_Set.card", "Groups_List.monoid_add_class.sum_list", "List.distinct", "Weak_Integer_Compositions.multichoose", "Weak_Integer_Compositions.weak_integer_composition_enum" ]
[ "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "definition multichoose:: \"nat \\<Rightarrow> nat \\<Rightarrow> nat\" (infixl \"multichoose\" 65) where\n \"n multichoose k = (n + k -1) choose k\"", "fun weak_integer_composition_enum :: \"nat \\<Rightarrow> nat \\<Rightarrow> nat list list\" where\n \"weak_integer_composition_enum i 0 = (if i = 0 then [[]] else [])\"\n| \"weak_integer_composition_enum i (Suc 0) = [[i]]\"\n| \"weak_integer_composition_enum i l =\n [h#r . h \\<leftarrow> [0..< Suc i], r \\<leftarrow> weak_integer_composition_enum (i-h) (l-1)]\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.count_mset_replicate_aux1
lemma count_mset_replicate_aux1: "\<lbrakk>\<not> x < n; mset ys = mset (replicate n True) + mset (replicate (x - n) False)\<rbrakk> \<Longrightarrow> count (mset ys) True = n"
\<not> ?x < ?n \<Longrightarrow> mset ?ys = mset (replicate ?n True) + mset (replicate (?x - ?n) False) \<Longrightarrow> count (mset ?ys) True = ?n
\<lbrakk>\<not> x_1 < x_2; ?H1 x_3 = ?H2 (?H1 (?H3 x_2 True)) (?H1 (?H3 (?H4 x_1 x_2) False))\<rbrakk> \<Longrightarrow> ?H5 (?H1 x_3) True = x_2
[ "List.replicate", "Groups.minus_class.minus", "Set.empty", "Groups.plus_class.plus", "Multiset.multiset.count", "List.count_list", "Multiset.mset", "Set.Collect", "List.distinct" ]
[ "primrec replicate :: \"nat \\<Rightarrow> 'a \\<Rightarrow> 'a list\" where\nreplicate_0: \"replicate 0 x = []\" |\nreplicate_Suc: \"replicate (Suc n) x = x # replicate n x\"", "class minus =\n fixes minus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"-\" 65)", "abbreviation empty :: \"'a set\" (\"{}\")\n where \"{} \\<equiv> bot\"", "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "primrec mset :: \"'a list \\<Rightarrow> 'a multiset\" where\n \"mset [] = {#}\" |\n \"mset (a # x) = add_mset a (mset x)\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.count_mset_replicate_aux2
lemma count_mset_replicate_aux2: assumes "\<not> length xs < count_list xs True" shows "mset xs = mset (replicate (count_list xs True) True) + mset (replicate (length xs - count_list xs True) False)"
\<not> length ?xs < count_list ?xs True \<Longrightarrow> mset ?xs = mset (replicate (count_list ?xs True) True) + mset (replicate (length ?xs - count_list ?xs True) False)
\<not> ?H1 x_1 < ?H2 x_1 True \<Longrightarrow> ?H3 x_1 = ?H4 (?H3 (?H5 (?H2 x_1 True) True)) (?H3 (?H5 (?H6 (?H1 x_1) (?H2 x_1 True)) False))
[ "Groups.plus_class.plus", "List.length", "Multiset.mset", "Groups.minus_class.minus", "List.replicate", "List.count_list" ]
[ "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec mset :: \"'a list \\<Rightarrow> 'a multiset\" where\n \"mset [] = {#}\" |\n \"mset (a # x) = add_mset a (mset x)\"", "class minus =\n fixes minus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"-\" 65)", "primrec replicate :: \"nat \\<Rightarrow> 'a \\<Rightarrow> 'a list\" where\nreplicate_0: \"replicate 0 x = []\" |\nreplicate_Suc: \"replicate (Suc n) x = x # replicate n x\"", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.n_subset_enum_correct_aux1
lemma n_subset_enum_correct_aux1: "\<lbrakk>distinct xs; length ys = length xs\<rbrakk> \<Longrightarrow> set (filter_bool_list ys xs) \<in> n_subsets (set xs) (count_list ys True)"
distinct ?xs \<Longrightarrow> length ?ys = length ?xs \<Longrightarrow> set (filter_bool_list ?ys ?xs) \<in> n_subsets (set ?xs) (count_list ?ys True)
\<lbrakk>?H1 x_1; ?H2 x_2 = ?H3 x_1\<rbrakk> \<Longrightarrow> ?H4 (?H5 x_2 x_1) \<in> ?H6 (?H4 x_1) (?H7 x_2 True)
[ "List.count_list", "n_Subsets.n_subsets", "List.length", "List.distinct", "List.list.set", "Filter_Bool_List.filter_bool_list" ]
[ "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "definition n_subsets :: \"'a set \\<Rightarrow> nat \\<Rightarrow> 'a set set\" where\n \"n_subsets A n = {B. B \\<subseteq> A \\<and> card B = n}\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun filter_bool_list :: \"bool list \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" where\n \"filter_bool_list [] _ = []\"\n| \"filter_bool_list _ [] = []\"\n| \"filter_bool_list (b#bs) (x#xs) =\n (if b then x#(filter_bool_list bs xs) else (filter_bool_list bs xs))\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.n_bool_lists_correct_aux
lemma n_bool_lists_correct_aux: "length xs = x \<Longrightarrow> count_list xs True = n \<Longrightarrow> xs \<in> set (n_bool_lists n x)"
length ?xs = ?x \<Longrightarrow> count_list ?xs True = ?n \<Longrightarrow> ?xs \<in> set (n_bool_lists ?n ?x)
\<lbrakk>?H1 x_1 = x_2; ?H2 x_1 True = x_3\<rbrakk> \<Longrightarrow> x_1 \<in> ?H3 (?H4 x_3 x_2)
[ "n_Subsets.n_bool_lists", "List.length", "List.list.set", "List.count_list" ]
[ "fun n_bool_lists :: \"nat \\<Rightarrow> nat \\<Rightarrow> bool list list\" where\n \"n_bool_lists n 0 = (if n > 0 then [] else [[]])\"\n| \"n_bool_lists n (Suc x) = (if n = 0 then [replicate (Suc x) False]\n else if n = Suc x then [replicate (Suc x) True]\n else if n > x then []\n else [False#xs . xs \\<leftarrow> n_bool_lists n x] @ [True#xs . xs \\<leftarrow> n_bool_lists (n-1) x])\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.n_bool_lists_correct
lemma n_bool_lists_correct: "set (n_bool_lists n x) = {xs. length xs = x \<and> count_list xs True = n}"
set (n_bool_lists ?n ?x) = {xs. length xs = ?x \<and> count_list xs True = ?n}
?H1 (?H2 x_1 x_2) = ?H3 (\<lambda>y_0. ?H4 y_0 = x_2 \<and> ?H5 y_0 True = x_1)
[ "n_Subsets.n_bool_lists", "Set.Collect", "List.list.set", "List.list.Nil", "n_Subsets.n_bool_lists_dom", "List.count_list", "List.length" ]
[ "fun n_bool_lists :: \"nat \\<Rightarrow> nat \\<Rightarrow> bool list list\" where\n \"n_bool_lists n 0 = (if n > 0 then [] else [[]])\"\n| \"n_bool_lists n (Suc x) = (if n = 0 then [replicate (Suc x) False]\n else if n = Suc x then [replicate (Suc x) True]\n else if n > x then []\n else [False#xs . xs \\<leftarrow> n_bool_lists n x] @ [True#xs . xs \\<leftarrow> n_bool_lists (n-1) x])\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.n_subset_enum_correct_aux2
lemma n_subset_enum_correct_aux2: "distinct xs \<Longrightarrow> n_subsets (set xs) n \<subseteq> set (map set (n_subset_enum xs n))"
distinct ?xs \<Longrightarrow> n_subsets (set ?xs) ?n \<subseteq> set (map set (n_subset_enum ?xs ?n))
?H1 x_1 \<Longrightarrow> ?H2 (?H3 (?H4 x_1) x_2) (?H5 (?H6 ?H4 (?H7 x_1 x_2)))
[ "n_Subsets.n_subset_enum", "List.list.set", "List.list.Nil", "Set.subset_eq", "List.list.map", "n_Subsets.n_subsets", "List.distinct" ]
[ "fun n_subset_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_subset_enum xs n = [(filter_bool_list bs xs) . bs \\<leftarrow> (n_bool_lists n (length xs))]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation subset_eq :: \"'a set \\<Rightarrow> 'a set \\<Rightarrow> bool\"\n where \"subset_eq \\<equiv> less_eq\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "definition n_subsets :: \"'a set \\<Rightarrow> nat \\<Rightarrow> 'a set set\" where\n \"n_subsets A n = {B. B \\<subseteq> A \\<and> card B = n}\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.n_subset_enum_correct
theorem n_subset_enum_correct: "distinct xs \<Longrightarrow> set (map set (n_subset_enum xs n)) = n_subsets (set xs) n"
distinct ?xs \<Longrightarrow> set (map set (n_subset_enum ?xs ?n)) = n_subsets (set ?xs) ?n
?H1 x_1 \<Longrightarrow> ?H2 (?H3 ?H4 (?H5 x_1 x_2)) = ?H6 (?H4 x_1) x_2
[ "n_Subsets.n_subset_enum", "List.list.set", "Set.subset_eq", "n_Subsets.n_subsets", "List.distinct", "n_Subsets.n_bool_lists", "Groups.plus_class.plus", "n_Subsets.n_bool_lists2_dom", "List.list.map" ]
[ "fun n_subset_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_subset_enum xs n = [(filter_bool_list bs xs) . bs \\<leftarrow> (n_bool_lists n (length xs))]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation subset_eq :: \"'a set \\<Rightarrow> 'a set \\<Rightarrow> bool\"\n where \"subset_eq \\<equiv> less_eq\"", "definition n_subsets :: \"'a set \\<Rightarrow> nat \\<Rightarrow> 'a set set\" where\n \"n_subsets A n = {B. B \\<subseteq> A \\<and> card B = n}\"", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"", "fun n_bool_lists :: \"nat \\<Rightarrow> nat \\<Rightarrow> bool list list\" where\n \"n_bool_lists n 0 = (if n > 0 then [] else [[]])\"\n| \"n_bool_lists n (Suc x) = (if n = 0 then [replicate (Suc x) False]\n else if n = Suc x then [replicate (Suc x) True]\n else if n > x then []\n else [False#xs . xs \\<leftarrow> n_bool_lists n x] @ [True#xs . xs \\<leftarrow> n_bool_lists (n-1) x])\"", "class plus =\n fixes plus :: \"'a \\<Rightarrow> 'a \\<Rightarrow> 'a\" (infixl \"+\" 65)", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.n_subset_enum_distinct_elem
theorem n_subset_enum_distinct_elem: "distinct xs \<Longrightarrow> ys \<in> set (n_subset_enum xs n) \<Longrightarrow> distinct ys"
distinct ?xs \<Longrightarrow> ?ys \<in> set (n_subset_enum ?xs ?n) \<Longrightarrow> distinct ?ys
\<lbrakk>?H1 x_1; x_2 \<in> ?H2 (?H3 x_1 x_3)\<rbrakk> \<Longrightarrow> ?H1 x_2
[ "List.list.set", "n_Subsets.n_subset_enum", "Groups.one_class.one", "List.distinct" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun n_subset_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_subset_enum xs n = [(filter_bool_list bs xs) . bs \\<leftarrow> (n_bool_lists n (length xs))]\"", "class one =\n fixes one :: 'a (\"1\")", "primrec distinct :: \"'a list \\<Rightarrow> bool\" where\n\"distinct [] \\<longleftrightarrow> True\" |\n\"distinct (x # xs) \\<longleftrightarrow> x \\<notin> set xs \\<and> distinct xs\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.n_bool_lists_True_count
lemma n_bool_lists_True_count: "xs \<in> set (n_bool_lists n x) \<Longrightarrow> count_list xs True = n"
?xs \<in> set (n_bool_lists ?n ?x) \<Longrightarrow> count_list ?xs True = ?n
x_1 \<in> ?H1 (?H2 x_2 x_3) \<Longrightarrow> ?H3 x_1 True = x_2
[ "List.list.set", "n_Subsets.n_bool_lists", "List.count_list" ]
[ "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "fun n_bool_lists :: \"nat \\<Rightarrow> nat \\<Rightarrow> bool list list\" where\n \"n_bool_lists n 0 = (if n > 0 then [] else [[]])\"\n| \"n_bool_lists n (Suc x) = (if n = 0 then [replicate (Suc x) False]\n else if n = Suc x then [replicate (Suc x) True]\n else if n > x then []\n else [False#xs . xs \\<leftarrow> n_bool_lists n x] @ [True#xs . xs \\<leftarrow> n_bool_lists (n-1) x])\"", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.count_mset_count_list
lemma count_mset_count_list: "count (mset ys) T = n \<Longrightarrow> count_list ys T = n"
count (mset ?ys) ?T = ?n \<Longrightarrow> count_list ?ys ?T = ?n
?H1 (?H2 x_1) x_2 = x_3 \<Longrightarrow> ?H3 x_1 x_2 = x_3
[ "Multiset.mset", "List.count_list", "n_Subsets.n_bool_lists2_dom", "n_Subsets.n_subset_enum", "Multiset.multiset.count", "List.list.set", "Set.subset_eq" ]
[ "primrec mset :: \"'a list \\<Rightarrow> 'a multiset\" where\n \"mset [] = {#}\" |\n \"mset (a # x) = add_mset a (mset x)\"", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "fun n_subset_enum :: \"'a list \\<Rightarrow> nat \\<Rightarrow> 'a list list\" where\n \"n_subset_enum xs n = [(filter_bool_list bs xs) . bs \\<leftarrow> (n_bool_lists n (length xs))]\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"", "abbreviation subset_eq :: \"'a set \\<Rightarrow> 'a set \\<Rightarrow> bool\"\n where \"subset_eq \\<equiv> less_eq\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.count_list_count_mset
lemma count_list_count_mset: "count_list ys T = n \<Longrightarrow> count (mset ys) T = n"
count_list ?ys ?T = ?n \<Longrightarrow> count (mset ?ys) ?T = ?n
?H1 x_1 x_2 = x_3 \<Longrightarrow> ?H2 (?H3 x_1) x_2 = x_3
[ "Multiset.multiset.count", "List.count_list", "Multiset.mset" ]
[ "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "primrec mset :: \"'a list \\<Rightarrow> 'a multiset\" where\n \"mset [] = {#}\" |\n \"mset (a # x) = add_mset a (mset x)\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.n_bool_lists_length
lemma n_bool_lists_length: "xs \<in> set (n_bool_lists n x) \<Longrightarrow> length xs = x"
?xs \<in> set (n_bool_lists ?n ?x) \<Longrightarrow> length ?xs = ?x
x_1 \<in> ?H1 (?H2 x_2 x_3) \<Longrightarrow> ?H3 x_1 = x_3
[ "n_Subsets.n_bool_lists", "List.length", "n_Subsets.n_bool_lists_dom", "List.append", "n_Subsets.n_subsets", "List.list.set" ]
[ "fun n_bool_lists :: \"nat \\<Rightarrow> nat \\<Rightarrow> bool list list\" where\n \"n_bool_lists n 0 = (if n > 0 then [] else [[]])\"\n| \"n_bool_lists n (Suc x) = (if n = 0 then [replicate (Suc x) False]\n else if n = Suc x then [replicate (Suc x) True]\n else if n > x then []\n else [False#xs . xs \\<leftarrow> n_bool_lists n x] @ [True#xs . xs \\<leftarrow> n_bool_lists (n-1) x])\"", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"", "primrec append :: \"'a list \\<Rightarrow> 'a list \\<Rightarrow> 'a list\" (infixr \"@\" 65) where\nappend_Nil: \"[] @ ys = ys\" |\nappend_Cons: \"(x#xs) @ ys = x # xs @ ys\"", "definition n_subsets :: \"'a set \\<Rightarrow> nat \\<Rightarrow> 'a set set\" where\n \"n_subsets A n = {B. B \\<subseteq> A \\<and> card B = n}\"", "datatype (set: 'a) list =\n Nil (\"[]\")\n | Cons (hd: 'a) (tl: \"'a list\") (infixr \"#\" 65)\nfor\n map: map\n rel: list_all2\n pred: list_all\nwhere\n \"tl [] = []\"" ]
Combinatorial_Enumeration_Algorithms/n_Subsets
n_Subsets.replicate_True_not_False
lemma replicate_True_not_False: "count_list ys True = 0 \<longleftrightarrow> ys = replicate (length ys) False"
(count_list ?ys True = 0) = (?ys = replicate (length ?ys) False)
(?H1 x_1 True = ?H2) = (x_1 = ?H3 (?H4 x_1) False)
[ "Nat.Suc", "List.count_list", "Multiset.mset", "Multiset_Permutations.permutations_of_multiset", "n_Subsets.n_subsets", "List.replicate", "Groups.zero_class.zero", "List.length" ]
[ "definition Suc :: \"nat \\<Rightarrow> nat\"\n where \"Suc n = Abs_Nat (Suc_Rep (Rep_Nat n))\"", "primrec count_list :: \"'a list \\<Rightarrow> 'a \\<Rightarrow> nat\" where\n\"count_list [] y = 0\" |\n\"count_list (x#xs) y = (if x=y then count_list xs y + 1 else count_list xs y)\"", "primrec mset :: \"'a list \\<Rightarrow> 'a multiset\" where\n \"mset [] = {#}\" |\n \"mset (a # x) = add_mset a (mset x)\"", "definition permutations_of_multiset :: \"'a multiset \\<Rightarrow> 'a list set\" where\n \"permutations_of_multiset A = {xs. mset xs = A}\"", "definition n_subsets :: \"'a set \\<Rightarrow> nat \\<Rightarrow> 'a set set\" where\n \"n_subsets A n = {B. B \\<subseteq> A \\<and> card B = n}\"", "primrec replicate :: \"nat \\<Rightarrow> 'a \\<Rightarrow> 'a list\" where\nreplicate_0: \"replicate 0 x = []\" |\nreplicate_Suc: \"replicate (Suc n) x = x # replicate n x\"", "class zero =\n fixes zero :: 'a (\"0\")", "abbreviation length :: \"'a list \\<Rightarrow> nat\" where\n\"length \\<equiv> size\"" ]
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
2