File: .lake/packages/lean4/src/lean/Lean/Util/Diff.lean

full_name: Lean.Diff.Action.insert
code: /--
An action in an edit script to transform one source sequence into a target sequence.
-/
inductive Action where
  /-- Insert the item into the source -/
  | insert
  /-- Delete the item from the source -/
  | delete
  /-- Leave the item in the source -/
  | skip
deriving Repr, BEq, Hashable, Repr
goal: Lean.Diff.Action

full_name: Lean.Diff.instReprAction
code: /--
An action in an edit script to transform one source sequence into a target sequence.
-/
inductive Action where
  /-- Insert the item into the source -/
  | insert
  /-- Delete the item from the source -/
  | delete
  /-- Leave the item in the source -/
  | skip
deriving Repr, BEq, Hashable, Repr
goal: Repr Lean.Diff.Action

full_name: Lean.Diff.Action
code: /--
An action in an edit script to transform one source sequence into a target sequence.
-/
inductive Action where
  /-- Insert the item into the source -/
  | insert
  /-- Delete the item from the source -/
  | delete
  /-- Leave the item in the source -/
  | skip
deriving Repr, BEq, Hashable, Repr
goal: Type

full_name: Lean.Diff.Action.delete
code: /--
An action in an edit script to transform one source sequence into a target sequence.
-/
inductive Action where
  /-- Insert the item into the source -/
  | insert
  /-- Delete the item from the source -/
  | delete
  /-- Leave the item in the source -/
  | skip
deriving Repr, BEq, Hashable, Repr
goal: Lean.Diff.Action

full_name: Lean.Diff.Action.skip
code: /--
An action in an edit script to transform one source sequence into a target sequence.
-/
inductive Action where
  /-- Insert the item into the source -/
  | insert
  /-- Delete the item from the source -/
  | delete
  /-- Leave the item in the source -/
  | skip
deriving Repr, BEq, Hashable, Repr
goal: Lean.Diff.Action

full_name: Lean.Diff.instHashableAction
code: /--
An action in an edit script to transform one source sequence into a target sequence.
-/
inductive Action where
  /-- Insert the item into the source -/
  | insert
  /-- Delete the item from the source -/
  | delete
  /-- Leave the item in the source -/
  | skip
deriving Repr, BEq, Hashable, Repr
goal: Hashable Lean.Diff.Action

full_name: Lean.Diff.instBEqAction
code: BEq
goal: BEq Lean.Diff.Action

full_name: Lean.Diff.instToStringAction
code: instance : ToString Action 
goal: ToString Lean.Diff.Action

full_name: Lean.Diff.Action.linePrefix
code: /--
Determines a prefix to show on a given line when printing diff results.

For `delete`, the prefix is `"-"`, for `insert`, it is `"+"`, and for `skip` it is `" "`.
-/
def Action.linePrefix : (action : Action) → String
  
goal: String

full_name: Lean.Diff.Histogram.Entry
code: /--
A histogram entry consists of the number of times the element occurs in the left and right input
arrays along with an index at which the element can be found, if applicable.
-/
structure Histogram.Entry (α : Type u) (lsize rsize : Nat) where
  /-- How many times the element occurs in the left array -/
  leftCount : Nat
  /-- An index of the element in the left array, if applicable -/
  leftIndex : Option (Fin lsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  leftWF : leftCount = 0 ↔ leftIndex = none
  /-- How many times the element occurs in the right array -/
  rightCount : Nat
  /-- An index of the element in the right array, if applicable -/
  rightIndex : Option (Fin rsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  rightWF : rightCount = 0 ↔ rightIndex = none
goal: Type

full_name: Lean.Diff.Histogram.Entry.rightCount
code: /--
A histogram entry consists of the number of times the element occurs in the left and right input
arrays along with an index at which the element can be found, if applicable.
-/
structure Histogram.Entry (α : Type u) (lsize rsize : Nat) where
  /-- How many times the element occurs in the left array -/
  leftCount : Nat
  /-- An index of the element in the left array, if applicable -/
  leftIndex : Option (Fin lsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  leftWF : leftCount = 0 ↔ leftIndex = none
  /-- How many times the element occurs in the right array -/
  rightCount : Nat
  /-- An index of the element in the right array, if applicable -/
  rightIndex : Option (Fin rsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  rightWF : rightCount = 0 ↔ rightIndex = none
goal: Nat

full_name: Lean.Diff.Histogram.Entry.leftWF
code: /--
A histogram entry consists of the number of times the element occurs in the left and right input
arrays along with an index at which the element can be found, if applicable.
-/
structure Histogram.Entry (α : Type u) (lsize rsize : Nat) where
  /-- How many times the element occurs in the left array -/
  leftCount : Nat
  /-- An index of the element in the left array, if applicable -/
  leftIndex : Option (Fin lsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  leftWF : leftCount = 0 ↔ leftIndex = none
  /-- How many times the element occurs in the right array -/
  rightCount : Nat
  /-- An index of the element in the right array, if applicable -/
  rightIndex : Option (Fin rsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  rightWF : rightCount = 0 ↔ rightIndex = none
goal: self.leftCount = 0 ↔ self.leftIndex = none

full_name: Lean.Diff.Histogram.Entry.rightIndex
code: /--
A histogram entry consists of the number of times the element occurs in the left and right input
arrays along with an index at which the element can be found, if applicable.
-/
structure Histogram.Entry (α : Type u) (lsize rsize : Nat) where
  /-- How many times the element occurs in the left array -/
  leftCount : Nat
  /-- An index of the element in the left array, if applicable -/
  leftIndex : Option (Fin lsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  leftWF : leftCount = 0 ↔ leftIndex = none
  /-- How many times the element occurs in the right array -/
  rightCount : Nat
  /-- An index of the element in the right array, if applicable -/
  rightIndex : Option (Fin rsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  rightWF : rightCount = 0 ↔ rightIndex = none
goal: Option (Fin rsize)

full_name: Lean.Diff.Histogram.Entry.leftIndex
code: /--
A histogram entry consists of the number of times the element occurs in the left and right input
arrays along with an index at which the element can be found, if applicable.
-/
structure Histogram.Entry (α : Type u) (lsize rsize : Nat) where
  /-- How many times the element occurs in the left array -/
  leftCount : Nat
  /-- An index of the element in the left array, if applicable -/
  leftIndex : Option (Fin lsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  leftWF : leftCount = 0 ↔ leftIndex = none
  /-- How many times the element occurs in the right array -/
  rightCount : Nat
  /-- An index of the element in the right array, if applicable -/
  rightIndex : Option (Fin rsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  rightWF : rightCount = 0 ↔ rightIndex = none
goal: Option (Fin lsize)

full_name: Lean.Diff.Histogram.Entry.rightWF
code: /--
A histogram entry consists of the number of times the element occurs in the left and right input
arrays along with an index at which the element can be found, if applicable.
-/
structure Histogram.Entry (α : Type u) (lsize rsize : Nat) where
  /-- How many times the element occurs in the left array -/
  leftCount : Nat
  /-- An index of the element in the left array, if applicable -/
  leftIndex : Option (Fin lsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  leftWF : leftCount = 0 ↔ leftIndex = none
  /-- How many times the element occurs in the right array -/
  rightCount : Nat
  /-- An index of the element in the right array, if applicable -/
  rightIndex : Option (Fin rsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  rightWF : rightCount = 0 ↔ rightIndex = none
goal: self.rightCount = 0 ↔ self.rightIndex = none

full_name: Lean.Diff.Histogram.Entry.leftCount
code: /--
A histogram entry consists of the number of times the element occurs in the left and right input
arrays along with an index at which the element can be found, if applicable.
-/
structure Histogram.Entry (α : Type u) (lsize rsize : Nat) where
  /-- How many times the element occurs in the left array -/
  leftCount : Nat
  /-- An index of the element in the left array, if applicable -/
  leftIndex : Option (Fin lsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  leftWF : leftCount = 0 ↔ leftIndex = none
  /-- How many times the element occurs in the right array -/
  rightCount : Nat
  /-- An index of the element in the right array, if applicable -/
  rightIndex : Option (Fin rsize)
  /-- Invariant: the count is non-zero iff there is a saved index -/
  rightWF : rightCount = 0 ↔ rightIndex = none
goal: Nat

full_name: Lean.Diff.Histogram
code: /-- A histogram for arrays maps each element to a count and, if applicable, an index.-/
def Histogram (α : Type u) (lsize rsize : Nat) [BEq α] [Hashable α] 
goal: Type u

full_name: Lean.Diff.Histogram.addLeft
code: /-- Add an element from the left array to a histogram -/
def Histogram.addLeft (histogram : Histogram α lsize rsize) (index : Fin lsize) (val : α)
    : Histogram α lsize rsize 
goal: Lean.Diff.Histogram α lsize rsize

full_name: Lean.Diff.Histogram.addRight
code: /-- Add an element from the right array to a histogram -/
def Histogram.addRight (histogram : Histogram α lsize rsize) (index : Fin rsize) (val : α)
    : Histogram α lsize rsize 
goal: Lean.Diff.Histogram α lsize rsize

full_name: Lean.Diff.matchPrefix.go
code: /-- Given two `Subarray`s, find their common prefix and return their differing suffixes -/
def matchPrefix (left right : Subarray α) : Array α × Subarray α × Subarray α 
goal: Array α × Subarray α × Subarray α

full_name: Lean.Diff.matchPrefix
code: /-- Given two `Subarray`s, find their common prefix and return their differing suffixes -/
def matchPrefix (left right : Subarray α) : Array α × Subarray α × Subarray α 
goal: Array α × Subarray α × Subarray α

full_name: Lean.Diff.matchSuffix.go
code: /-- Given two `Subarray`s, find their common suffix and return their differing prefixes -/
def matchSuffix (left right : Subarray α) : Subarray α × Subarray α × Array α 
goal: Subarray α × Subarray α × Array α

full_name: Lean.Diff.matchSuffix
code: /-- Given two `Subarray`s, find their common suffix and return their differing prefixes -/
def matchSuffix (left right : Subarray α) : Subarray α × Subarray α × Array α 
goal: Subarray α × Subarray α × Array α

full_name: Lean.Diff.lcs
code: /--
Finds the least common subsequence of two arrays using a variant of jgit's histogram diff algorithm.

Unlike jgit's implementation, this one does not perform a cutoff on histogram bucket sizes, nor does
it fall back to the Myers diff algorithm. This means that it has quadratic worst-case complexity.
Empirically, however, even quadratic cases of this implementation can handle hundreds of megabytes
in a second or so, and it is intended to be used for short strings like error messages. Be
cautious when applying it to larger workloads.
-/
partial def lcs (left right : Subarray α) : Array α 
goal: Array α

full_name: Lean.Diff.diff
code: /--
Computes an edit script to transform `left` into `right`.
-/
def diff [Inhabited α] (original edited : Array α) : Array (Action × α) 
goal: Array (Lean.Diff.Action × α)

full_name: Lean.Diff.linesToString
code: /-- Shows a line-by-line edit script with markers for added and removed lines. -/
def linesToString [ToString α] (lines : Array (Action × α)) : String 
goal: String