@@ -874,6 +874,42 @@ public theorem toList_rcc {α : Type u} {β : α → Type v} [Ord α] [TransOrd
874874
875875end Rcc
876876
877+ namespace Const
878+
879+ public structure RccSliceData (α : Type u) (β : Type v) [Ord α] where
880+ treeMap : Impl α (fun _ => β)
881+ range : Rcc α
882+
883+ public abbrev RccSlice α β [Ord α] := Slice (RccSliceData α β)
884+
885+ public instance {α : Type u} {β : Type v} [Ord α] : Rcc.Sliceable (Impl α (fun _ => β)) α (RccSlice α β) where
886+ mkSlice carrier range := ⟨carrier, range⟩
887+
888+ public instance [Ord α] {s : RccSlice α β} : ToIterator s Id (α × β) := by
889+ apply ToIterator.of
890+ . exact (⟨RxcIterator.mk (Zipper.prependMapGE s.1 .treeMap s.1 .range.lower .done) s.1 .range.upper⟩ : Iter ((_ : α) × β)).map fun e => (e.1 , e.2 )
891+
892+ public theorem toList_rcc {α : Type u} {β : Type v} [Ord α] [TransOrd α] (t : Impl α (fun _ => β))
893+ (ordered : t.Ordered) (lowerBound upperBound : α) : t[lowerBound...=upperBound].toList = (Internal.Impl.Const.toList t).filter (fun e => (compare e.fst lowerBound).isGE ∧ (compare e.fst upperBound).isLE) := by
894+ simp only [Rcc.Sliceable.mkSlice, Slice.toList_eq_toList_iter, Slice.iter,
895+ Slice.Internal.iter_eq_toIteratorIter, ToIterator.iter, ToIterator.iterM_eq,
896+ Iter.toIter_toIterM]
897+ rw [Iter.toList_map]
898+ have := @toList_rccIter α (fun _ => β) _ _ t ordered lowerBound upperBound
899+ rw [RccIterator] at this
900+ rw [this]
901+ have eq : (fun (e : (_ : α) × β) => decide ((compare e.fst lowerBound).isGE = true ∧ (compare e.fst upperBound).isLE = true )) =
902+ (fun (e : α × β) => decide ((compare e.fst lowerBound).isGE = true ∧ (compare e.fst upperBound).isLE = true )) ∘ (fun e => (e.1 , e.2 )) := by congr
903+ conv =>
904+ lhs
905+ rhs
906+ rw [eq]
907+ rw [← List.filter_map]
908+ congr
909+ rw [Impl.Const.toList_eq_toListModel_map, Impl.toList_eq_toListModel]
910+
911+ end Const
912+
877913section Rco
878914
879915@[always_inline]
@@ -1023,6 +1059,43 @@ public theorem toList_roo {α : Type u} {β : α → Type v} [Ord α] [TransOrd
10231059
10241060end Roo
10251061
1062+ namespace Const
1063+
1064+ public structure RooSliceData (α : Type u) (β : Type v) [Ord α] where
1065+ treeMap : Impl α (fun _ => β)
1066+ range : Roo α
1067+
1068+ public abbrev RooSlice α β [Ord α] := Slice (RooSliceData α β)
1069+
1070+ public instance {α : Type u} {β : Type v} [Ord α] : Roo.Sliceable (Impl α (fun _ => β)) α (RooSlice α β) where
1071+ mkSlice carrier range := ⟨carrier, range⟩
1072+
1073+ public instance [Ord α] {s : RooSlice α β} : ToIterator s Id (α × β) := by
1074+ apply ToIterator.of
1075+ . exact (⟨RxoIterator.mk (Zipper.prependMapGT s.1 .treeMap s.1 .range.lower .done) s.1 .range.upper⟩ : Iter ((_ : α) × β)).map fun e => (e.1 , e.2 )
1076+
1077+ public theorem toList_roo {α : Type u} {β : Type v} [Ord α] [TransOrd α] (t : Impl α (fun _ => β))
1078+ (ordered : t.Ordered) (lowerBound upperBound : α) : t[lowerBound<...<upperBound].toList = (Internal.Impl.Const.toList t).filter (fun e => (compare e.fst lowerBound).isGT ∧ (compare e.fst upperBound).isLT) := by
1079+ simp only [Roo.Sliceable.mkSlice, Slice.toList_eq_toList_iter, Slice.iter,
1080+ Slice.Internal.iter_eq_toIteratorIter, ToIterator.iter, ToIterator.iterM_eq,
1081+ Iter.toIter_toIterM]
1082+ rw [Iter.toList_map]
1083+ have := @toList_rooIter α (fun _ => β) _ _ t ordered lowerBound upperBound
1084+ rw [RooIterator] at this
1085+ rw [this]
1086+ have eq : (fun (e : (_ : α) × β) => decide ((compare e.fst lowerBound).isGT = true ∧ (compare e.fst upperBound).isLT = true )) =
1087+ (fun (e : α × β) => decide ((compare e.fst lowerBound).isGT = true ∧ (compare e.fst upperBound).isLT = true )) ∘ (fun e => (e.1 , e.2 )) := by congr
1088+ conv =>
1089+ lhs
1090+ rhs
1091+ rw [eq]
1092+ rw [← List.filter_map]
1093+ congr
1094+ rw [Impl.Const.toList_eq_toListModel_map, Impl.toList_eq_toListModel]
1095+
1096+ end Const
1097+
1098+
10261099section Roc
10271100
10281101@[always_inline]
@@ -1080,6 +1153,42 @@ public theorem toList_roc {α : Type u} {β : α → Type v} [Ord α] [TransOrd
10801153
10811154end Roc
10821155
1156+ namespace Const
1157+
1158+ public structure RocSliceData (α : Type u) (β : Type v) [Ord α] where
1159+ treeMap : Impl α (fun _ => β)
1160+ range : Roc α
1161+
1162+ public abbrev RocSlice α β [Ord α] := Slice (RocSliceData α β)
1163+
1164+ public instance {α : Type u} {β : Type v} [Ord α] : Roc.Sliceable (Impl α (fun _ => β)) α (RocSlice α β) where
1165+ mkSlice carrier range := ⟨carrier, range⟩
1166+
1167+ public instance [Ord α] {s : RocSlice α β} : ToIterator s Id (α × β) := by
1168+ apply ToIterator.of
1169+ . exact (⟨RxcIterator.mk (Zipper.prependMapGT s.1 .treeMap s.1 .range.lower .done) s.1 .range.upper⟩ : Iter ((_ : α) × β)).map fun e => (e.1 , e.2 )
1170+
1171+ public theorem toList_roc {α : Type u} {β : Type v} [Ord α] [TransOrd α] (t : Impl α (fun _ => β))
1172+ (ordered : t.Ordered) (lowerBound upperBound : α) : t[lowerBound<...=upperBound].toList = (Internal.Impl.Const.toList t).filter (fun e => (compare e.fst lowerBound).isGT ∧ (compare e.fst upperBound).isLE) := by
1173+ simp only [Roc.Sliceable.mkSlice, Slice.toList_eq_toList_iter, Slice.iter,
1174+ Slice.Internal.iter_eq_toIteratorIter, ToIterator.iter, ToIterator.iterM_eq,
1175+ Iter.toIter_toIterM]
1176+ rw [Iter.toList_map]
1177+ have := @toList_rocIter α (fun _ => β) _ _ t ordered lowerBound upperBound
1178+ rw [RocIterator] at this
1179+ rw [this]
1180+ have eq : (fun (e : (_ : α) × β) => decide ((compare e.fst lowerBound).isGT = true ∧ (compare e.fst upperBound).isLE = true )) =
1181+ (fun (e : α × β) => decide ((compare e.fst lowerBound).isGT = true ∧ (compare e.fst upperBound).isLE = true )) ∘ (fun e => (e.1 , e.2 )) := by congr
1182+ conv =>
1183+ lhs
1184+ rhs
1185+ rw [eq]
1186+ rw [← List.filter_map]
1187+ congr
1188+ rw [Impl.Const.toList_eq_toListModel_map, Impl.toList_eq_toListModel]
1189+
1190+ end Const
1191+
10831192section Rci
10841193
10851194@[always_inline]
@@ -1201,6 +1310,42 @@ public theorem toList_roi {α : Type u} {β : α → Type v} [Ord α] [TransOrd
12011310
12021311end Roi
12031312
1313+ namespace Const
1314+
1315+ public structure RoiSliceData (α : Type u) (β : Type v) [Ord α] where
1316+ treeMap : Impl α (fun _ => β)
1317+ range : Roi α
1318+
1319+ public abbrev RoiSlice α β [Ord α] := Slice (RoiSliceData α β)
1320+
1321+ public instance {α : Type u} {β : Type v} [Ord α] : Roi.Sliceable (Impl α (fun _ => β)) α (RoiSlice α β) where
1322+ mkSlice carrier range := ⟨carrier, range⟩
1323+
1324+ public instance [Ord α] {s : RoiSlice α β} : ToIterator s Id (α × β) := by
1325+ apply ToIterator.of
1326+ . exact (⟨(Zipper.prependMapGT s.1 .treeMap s.1 .range.lower .done)⟩ : Iter ((_ : α) × β)).map fun e => (e.1 , e.2 )
1327+
1328+ public theorem toList_roi {α : Type u} {β : Type v} [Ord α] [TransOrd α] (t : Impl α (fun _ => β))
1329+ (ordered : t.Ordered) (lowerBound : α) : t[lowerBound<...*].toList = (Internal.Impl.Const.toList t).filter (fun e => (compare e.fst lowerBound).isGT) := by
1330+ simp only [Roi.Sliceable.mkSlice, Slice.toList_eq_toList_iter, Slice.iter,
1331+ Slice.Internal.iter_eq_toIteratorIter, ToIterator.iter, ToIterator.iterM_eq,
1332+ Iter.toIter_toIterM]
1333+ rw [Iter.toList_map]
1334+ have := @toList_roiIter α (fun _ => β) _ _ t ordered lowerBound
1335+ rw [RoiIterator] at this
1336+ rw [this]
1337+ have eq : (fun (e : (_ : α) × β) => ((compare e.fst lowerBound).isGT)) = ((fun (e : α × β) => ((compare e.fst lowerBound).isGT)) ∘ (fun e => (e.1 ,e.2 ))) := by congr
1338+ conv =>
1339+ lhs
1340+ rhs
1341+ rw [eq]
1342+ rw [← List.filter_map]
1343+ congr
1344+ rw [Impl.Const.toList_eq_toListModel_map, Impl.toList_eq_toListModel]
1345+
1346+ end Const
1347+
1348+
12041349section Rii
12051350
12061351public def RiiIterator (t : Impl α β) : Iter (α := Zipper α β) ((a : α) × β a) :=
0 commit comments