Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  ToFun.lean   Sprache: Lean

 

module

public import Mathlib.Analysis.Normed.Ring.Basic
public import Mathlib.Tactic.ToFun

@[expose] public section

set_option pp.unicode.fun true

-- This warns about `Foo.fun_hoge` being the auto-generated name:
-- in particular, there should be a declaration `Foo.fun_hoge` in the environment
-- (and none literally called `_root_.Foo.fun_hoge` --- this was the case prior to a bug fix).
/--
warning: `to_fun` correctly autogenerated the provided name `Foo.fun_hoge`.
You may remove it.
-/

#guard_msgs in
@[to_fun _root_.Foo.fun_hoge]
lemma Foo.hoge (f g : ℝ → ℝ) : f * g = g * f := mul_comm f g
/-- info: Foo.fun_hoge (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in #check Foo.fun_hoge
--/-- info: Foo.fun_hoge (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
--#guard_msgs in #check _root_.Foo.fun_hoge

-- The naming algorithm respects the `_root_` prefix: the generated declaration is named `hoge'_fun`
@[to_fun _root_.hoge'_fun]
lemma Foo.Bar.hoge' (f g : ℝ → ℝ) : f * g = g * f := mul_comm f g
-- Previously, a bug meant such declarations were generated.
/-- error: Unknown identifier `Foo._root_.hoge'_fun` -/
#guard_msgs in #check Foo._root_.hoge'_fun
/-- info: hoge'_fun (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in #check hoge'_fun

-- This also works with losing one namespace level (although there is a neater solution in this case).
@[to_fun _root_.Foo.fun_hoge']
lemma Foo.Bar.hoge'' (f g : ℝ → ℝ) : f * g = g * f := mul_comm f g
/-- info: Foo.fun_hoge' (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in #check Foo.fun_hoge'
/--
warning: `to_fun` correctly autogenerated the provided name `fun_id_eq'`.
You may remove it.
-/

#guard_msgs in
@[to_fun fun_id_eq']
lemma id_eq' {R : Type*} : (@id R) = id := id_eq _

@[to_fun baz]
lemma Foo.bar (f g : ℝ → ℝ) : f * g = g * f := mul_comm f g

/-- info: Foo.baz (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in #check Foo.baz

@[to_fun baz']
lemma _root_.Foo.bar' (f g : ℝ → ℝ) : f * g = g * f := mul_comm f g
/-- info: Foo.baz' (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in #check Foo.baz'

namespace Test

@[to_fun baz]
lemma Foo.bar (f g : ℝ → ℝ) : f * g = g * f := mul_comm f g
/-- info: Test.Foo.baz (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in #check Test.Foo.baz

@[to_fun baz'']
lemma _root_.Foo.bar'' (f g : ℝ → ℝ) : f * g = g * f := mul_comm f g
/-- info: Foo.baz'' (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in #check Foo.baz''

end Test

@[to_fun Bars.baz]
lemma Foo.Bar.baz (f g : ℝ → ℝ) : f * g = g * f := mul_comm f g
/-- info: Foo.Bars.baz (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in #check Foo.Bars.baz

@[to_fun Baz.Bars.baz]
lemma Foo.Bar.baz' (f g : ℝ → ℝ) : f * g = g * f := mul_comm f g
/-- info: Baz.Bars.baz (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in #check Baz.Bars.baz

-- Specifying more components than the original lemma is fine.
@[to_fun Bar.Bars.Bazzz.baz]
lemma Foo.Bar.baz'' (f g : ℝ → ℝ) : f * g = g * f := mul_comm f g
/-- info: Bar.Bars.Bazzz.baz (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in #check Bar.Bars.Bazzz.baz

@[to_fun]
theorem Function.mul_comm (f g : ℝ → ℝ) : f * g = g * f := _root_.mul_comm f g

/-- info: Function.fun_mul_comm (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in
#check Function.fun_mul_comm

/--
warning: `to_fun` correctly autogenerated the provided name `fun_bar`.
You may remove it.
-/

#guard_msgs in
@[to_fun fun_bar]
theorem bar (f g : ℝ → ℝ) : f * g = g * f := _root_.mul_comm f g

/-- Look I am the doc-string of `foo`. -/
@[to_fun]
theorem foo : (1 : Nat → Nat) = 1 := rfl

open Lean in
/--
info: Eta-expanded form of `foo`

---

Look I am the doc-string of `foo`.
-/

#guard_msgs in
run_meta
  let some doc  ← findDocString? (← getEnv) ``fun_foo | throwError "no docstring found"
  logInfo doc


-- Test that it also works when the generated proof is not a `rfl` proof:

@[to_additive (attr := push ← high)]
lemma Pi.mul_def' {ι : Type*} {M : ι → Type*} [∀ i, Mul (M i)] (f g : ∀ i, M i) :
    f * g = fun i ↦ f i * g i := (rfl)

@[to_fun]
theorem Function.mul_comm' (f g : ℝ → ℝ) : f * g = g * f := _root_.mul_comm f g

/-- info: Function.fun_mul_comm' (f g : ℝ → ℝ) : (fun i ↦ f i * g i) = fun i ↦ g i * f i -/
#guard_msgs in
#check Function.fun_mul_comm'

Messung
CHZG
879810095

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,068
#Domains=861,802