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

full_name: Lean.Widget.showTacticDiff
code: register_builtin_option showTacticDiff : Bool := {
  defValue := true
  descr := "When true, interactive goals for tactics will be decorated with diffing information. "
}
goal: Lean.Option Bool

full_name: Lean.Widget.initFn._@..lake.packages.lean4.src.lean.Lean.Widget.Diff._hyg.6
code: register_builtin_option showTacticDiff : Bool := {
  defValue := true
  descr := "When true, interactive goals for tactics will be decorated with diffing information. "
}
goal: IO (Lean.Option Bool)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Widget.Diff.0.Lean.Widget.ExprDiffTag.delete
code: /-- A marker for a point in the expression where a subexpression has been inserted.

NOTE: in the future we may add other tags.
  -/
private inductive ExprDiffTag where
  | change
  | delete
  | insert
goal: Lean.Widget.ExprDiffTag

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Widget.Diff.0.Lean.Widget.ExprDiffTag
code: /-- A marker for a point in the expression where a subexpression has been inserted.

NOTE: in the future we may add other tags.
  -/
private inductive ExprDiffTag where
  | change
  | delete
  | insert
goal: Type

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Widget.Diff.0.Lean.Widget.ExprDiffTag.insert
code: /-- A marker for a point in the expression where a subexpression has been inserted.

NOTE: in the future we may add other tags.
  -/
private inductive ExprDiffTag where
  | change
  | delete
  | insert
goal: Lean.Widget.ExprDiffTag

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Widget.Diff.0.Lean.Widget.ExprDiffTag.change
code: /-- A marker for a point in the expression where a subexpression has been inserted.

NOTE: in the future we may add other tags.
  -/
private inductive ExprDiffTag where
  | change
  | delete
  | insert
goal: Lean.Widget.ExprDiffTag

full_name: Lean.Widget.ExprDiffTag.toDiffTag
code: def ExprDiffTag.toDiffTag : (useAfter : Bool) → ExprDiffTag → Lean.Widget.DiffTag
  
goal: Lean.Widget.ExprDiffTag → Lean.Widget.DiffTag

full_name: Lean.Widget.ExprDiffTag.toString
code: def ExprDiffTag.toString : ExprDiffTag → String
  
goal: Lean.Widget.ExprDiffTag → String

full_name: Lean.Widget.instToStringExprDiffTag
code: instance : ToString ExprDiffTag 
goal: ToString Lean.Widget.ExprDiffTag

full_name: Lean.Widget.ExprDiff.changesBefore
code: /-- A description of the differences between a pair of expressions `before`, `after : Expr`.
The information can be used to display a 'visual diff' for
either `before`, showing the parts of the expression that are about to change,
or `after` showing which parts of the expression have changed. -/
structure ExprDiff where
  /-- Map from subexpr positions in `e₀` to diff points.-/
  changesBefore : PosMap ExprDiffTag := ∅
  /-- A map from subexpr positions in `e₁` to 'diff points' which are tags
  describing how the expression has changed relative to `before` at the given position.-/
  changesAfter : PosMap ExprDiffTag := ∅
goal: Lean.SubExpr.PosMap Lean.Widget.ExprDiffTag

full_name: Lean.Widget.ExprDiff
code: /-- A description of the differences between a pair of expressions `before`, `after : Expr`.
The information can be used to display a 'visual diff' for
either `before`, showing the parts of the expression that are about to change,
or `after` showing which parts of the expression have changed. -/
structure ExprDiff where
  /-- Map from subexpr positions in `e₀` to diff points.-/
  changesBefore : PosMap ExprDiffTag := ∅
  /-- A map from subexpr positions in `e₁` to 'diff points' which are tags
  describing how the expression has changed relative to `before` at the given position.-/
  changesAfter : PosMap ExprDiffTag := ∅
goal: Type

full_name: Lean.Widget.ExprDiff.changesAfter
code: /-- A description of the differences between a pair of expressions `before`, `after : Expr`.
The information can be used to display a 'visual diff' for
either `before`, showing the parts of the expression that are about to change,
or `after` showing which parts of the expression have changed. -/
structure ExprDiff where
  /-- Map from subexpr positions in `e₀` to diff points.-/
  changesBefore : PosMap ExprDiffTag := ∅
  /-- A map from subexpr positions in `e₁` to 'diff points' which are tags
  describing how the expression has changed relative to `before` at the given position.-/
  changesAfter : PosMap ExprDiffTag := ∅
goal: Lean.SubExpr.PosMap Lean.Widget.ExprDiffTag

full_name: Lean.Widget.instEmptyCollectionExprDiff
code: instance : EmptyCollection ExprDiff 
goal: EmptyCollection Lean.Widget.ExprDiff

full_name: Lean.Widget.instAppendExprDiff
code: instance : Append ExprDiff 
goal: Append Lean.Widget.ExprDiff

full_name: Lean.Widget.instToStringExprDiff
code: instance : ToString ExprDiff 
goal: ToString Lean.Widget.ExprDiff

full_name: Lean.Widget.ExprDiff.insertBeforeChange
code: /-- Add a tag at the given position to the `changesBefore` dict. -/
def ExprDiff.insertBeforeChange (p : Pos) (d : ExprDiffTag := .change) (δ : ExprDiff) : ExprDiff 
goal: Lean.Widget.ExprDiff

full_name: Lean.Widget.ExprDiff.insertAfterChange
code: /-- Add a tag at the given position to the `changesAfter` dict. -/
def ExprDiff.insertAfterChange (p : Pos) (d : ExprDiffTag := .change) (δ : ExprDiff) : ExprDiff 
goal: Lean.Widget.ExprDiff

full_name: Lean.Widget.ExprDiff.withChangePos
code: def ExprDiff.withChangePos (before after : Pos) (d : ExprDiffTag := .change) : ExprDiff 
goal: Lean.Widget.ExprDiff

full_name: Lean.Widget.ExprDiff.withChange
code: /-- Add a tag to the diff at the positions given by `before` and `after`. -/
def ExprDiff.withChange (before after : SubExpr) (d : ExprDiffTag := .change) : ExprDiff 
goal: Lean.Widget.ExprDiff

full_name: Lean.Widget.ExprDiff.isEmpty
code: /-- If true, the expression before and the expression after are identical. -/
def ExprDiff.isEmpty (d : ExprDiff) : Bool 
goal: Bool

full_name: Lean.Widget.exprDiffCore.piDiff
code: /-- Computes a diff between `before` and `after` expressions.

This works by recursively comparing function arguments.

TODO(ed): experiment with a 'greatest common subexpression' design where
  given `e₀`, `e₁`, find the greatest common subexpressions `Xs : Array Expr` and a congruence `F` such that
  `e₀ = F[A₀[..Xs]]` and `e₀ = F[A₁[..Xs]]`. Then, we can have fancy diff highlighting where common subexpressions are not highlighted.

## Diffing binders

Two binding domains are identified if they have the same user name and the same type.
The most common tactic that modifies binders is after an `intros`.
To deal with this case, if `before = (a : α) → β` and `after`, is not a matching binder (ie: not `(a : α) → _`)
then we instantiate the `before` variable in a new context and continue diffing `β` against `after`.

 -/
partial def exprDiffCore (before after : SubExpr) : MetaM ExprDiff 
goal: Lean.MetaM Lean.Widget.ExprDiff

full_name: Lean.Widget.exprDiffCore
code: /-- Computes a diff between `before` and `after` expressions.

This works by recursively comparing function arguments.

TODO(ed): experiment with a 'greatest common subexpression' design where
  given `e₀`, `e₁`, find the greatest common subexpressions `Xs : Array Expr` and a congruence `F` such that
  `e₀ = F[A₀[..Xs]]` and `e₀ = F[A₁[..Xs]]`. Then, we can have fancy diff highlighting where common subexpressions are not highlighted.

## Diffing binders

Two binding domains are identified if they have the same user name and the same type.
The most common tactic that modifies binders is after an `intros`.
To deal with this case, if `before = (a : α) → β` and `after`, is not a matching binder (ie: not `(a : α) → _`)
then we instantiate the `before` variable in a new context and continue diffing `β` against `after`.

 -/
partial def exprDiffCore (before after : SubExpr) : MetaM ExprDiff 
goal: Lean.MetaM Lean.Widget.ExprDiff

full_name: Lean.Widget.exprDiff
code: /-- Computes the diff for `e₀` and `e₁`. If `useAfter` is `false`, `e₀, e₁` are interpreted as `after, before` instead of `before, after`.-/
def exprDiff (e₀ e₁ : Expr) (useAfter := true) : MetaM ExprDiff 
goal: Lean.MetaM Lean.Widget.ExprDiff

full_name: Lean.Widget.addDiffTags
code: /-- Given a `diff` between `before` and `after : Expr`, and the rendered `infoAfter : CodeWithInfos` for `after`,
this function decorates `infoAfter` with tags indicating where the expression has changed.

If `useAfter == false` before and after are swapped. -/
def addDiffTags (useAfter : Bool) (diff : ExprDiff) (info₁ : CodeWithInfos) : MetaM CodeWithInfos 
goal: Lean.MetaM Lean.Widget.CodeWithInfos

full_name: Lean.Widget.diffHypothesesBundle
code: /-- Diffs the given hypothesis bundle against the given local context.

If `useAfter == true`, `ctx₀` is the context _before_ and `h₁` is the bundle _after_.
If `useAfter == false`, these are swapped.
 -/
def diffHypothesesBundle (useAfter : Bool) (ctx₀  : LocalContext) (h₁ : InteractiveHypothesisBundle) : MetaM InteractiveHypothesisBundle 
goal: Lean.MetaM Lean.Widget.InteractiveHypothesisBundle

full_name: Lean.Widget.diffHypothesesBundle.withTypeDiff
code: /-- Diffs the given hypothesis bundle against the given local context.

If `useAfter == true`, `ctx₀` is the context _before_ and `h₁` is the bundle _after_.
If `useAfter == false`, these are swapped.
 -/
def diffHypothesesBundle (useAfter : Bool) (ctx₀  : LocalContext) (h₁ : InteractiveHypothesisBundle) : MetaM InteractiveHypothesisBundle 
goal: Lean.MetaM Lean.Widget.InteractiveHypothesisBundle

full_name: Lean.Widget.diffHypotheses
code: def diffHypotheses (useAfter : Bool) (lctx₀ : LocalContext) (hs₁ : Array InteractiveHypothesisBundle) : MetaM (Array InteractiveHypothesisBundle) 
goal: Lean.MetaM (Array Lean.Widget.InteractiveHypothesisBundle)

full_name: Lean.Widget.diffInteractiveGoal
code: /-- Decorates the given goal `i₁` with a diff by comparing with goal `g₀`.
If `useAfter` is true then `i₁` is _after_ and `g₀` is _before_. Otherwise they are swapped. -/
def diffInteractiveGoal (useAfter : Bool) (g₀ : MVarId) (i₁ : InteractiveGoal) : MetaM InteractiveGoal 
goal: Lean.MetaM Lean.Widget.InteractiveGoal

full_name: Lean.Widget.diffInteractiveGoals
code: /-- Modifies `goalsAfter` with additional information about how it is different to `goalsBefore`.
If `useAfter` is `true` then `igs₁` is the set of interactive goals _after_ the tactic has been applied.
Otherwise `igs₁` is the set of interactive goals _before_. -/
def diffInteractiveGoals (useAfter : Bool) (info : Elab.TacticInfo) (igs₁ : InteractiveGoals) : MetaM InteractiveGoals 
goal: Lean.MetaM Lean.Widget.InteractiveGoals