Eine aufbereitete Darstellung der Quelle

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


Quelle  Check.lean   Sprache: Lean

 

module

public import Mathlib.Tactic.Check

set_option linter.unusedTactic false
set_option linter.unusedVariables false

/-!
Basic check of `#check`
-/


/-- info: x + y : Nat -/
#guard_msgs in
example (x y : Nat) : True := by
  #check x + y
  trivial

theorem bar {a b c : Nat} (h : a = b + c) (hc : c = 0) : a = b := by rwa [hc] at h

-- #check does show implicit arguments (and also typeclass arguments) when present
set_option linter.unusedTactic false in
/-- info: bar {a b c : Nat} (h : a = b + c) (hc : c = 0) : a = b -/
#guard_msgs in
example : True := by
  #check bar
  trivial

/-!
`#check` is ok with metavariables
and `have := e` is not a substitute for `#check`
-/


/-- info: x + ?_ : Nat -/
#guard_msgs in
example (x : Nat) : True := by
  #check x + _
  trivial

/--
error: don't know how to synthesize placeholder
context:
x : Nat
⊢ Nat
---
error: unsolved goals
x : Nat
⊢ True
-/

#guard_msgs in
example (x : Nat) : True := by
  have := x + _


/-!
`#check` cannot be used to accidentally assign metavariables, since it saves the state.
This is in contrasted against `have`.
-/


/--
info: rfl : x = x
---
error: unsolved goals
x : Nat
y : Nat := ?a
⊢ True

case a
x : Nat
⊢ Nat
---
trace: x : Nat
y : Nat := ?a
⊢ True

case a
x : Nat
⊢ Nat
-/

#guard_msgs in
example (x : Nat) : True := by
  let y : Nat := ?a
  #check (by refine rfl : ?a = x)
  trace_state

/--
error: unsolved goals
x : Nat
y : Nat := x
this : x = x
⊢ True
---
trace: x : Nat
y : Nat := x
this : x = x
⊢ True
-/

#guard_msgs in
example (x : Nat) : True := by
  let y : Nat := ?a
  have := (by refine rfl : ?a = x)
  trace_state


/-! The same tests for check' -/

/-- info: x + y : Nat -/
#guard_msgs in
example (x y : Nat) : True := by
  #check' x + y
  trivial

/-
# TODO: handle expressions

/-- info: x : ∀ (y : Nat), i = i -/

#guard_msgs in
example (x : {i : Nat} → (y : Nat) → i = i) : True := by
  #check' x
  trivial

/-- info: foo : ∀ (y : Nat), True -/
#guard_msgs in
def foo {i : Nat} (y : Nat) : True := by
  #check' foo
  trivial

section prop

-- Removes the `{j : Nat}` appearing after the `String`s.

axiom foo' : {i : Nat} → (y : Nat) → String → String → {j : Nat} → i = y + j

/-- info: foo' (y : Nat) (a a✝ : String) : i = y + j -/
#guard_msgs in
#check' foo'

variable (x : {i : Nat} → (y : Nat) → String → String → {j : Nat} → i = y + j)

/-- info: x : ∀ (y : Nat) (a a✝ : String), i = y + j -/
#guard_msgs in
#check' x

variable (x' : {i : Nat} → (y : Nat) → ∀ a b : String, i = y)

/-- info: x' : ∀ (y : Nat) (a b : String), i = y -/
#guard_msgs in
#check' x'

end prop

section arrow

-- Removes the `{j : Nat}` appearing after the `String`s.

axiom F : Nat → Nat → Nat → Type

axiom foo'' : {i : Nat} → (y : Nat) → String → String → {j : Nat} → F i y j

/-- info: foo'' (y : Nat) : String → String → F i y j -/
#guard_msgs in
#check' foo''

variable (x : {i : Nat} → (y : Nat) → String → String → {j : Nat} → F i y j)

/-- info: x : (y : Nat) → String → String → F i y j -/
#guard_msgs in
#check' x

end arrow
-/

/-!
`#check'` is ok with metavariables
and `have := e` is not a substitute for `#check'`
-/


/-- info: x + ?_ : Nat -/
#guard_msgs in
example (x : Nat) : True := by
  #check' x + _
  trivial

/-!
`#check'` cannot be used to accidentally assign metavariables, since it saves the state.
This is in contrasted against `have`.
-/


/--
info: rfl : x = x
---
error: unsolved goals
x : Nat
y : Nat := ?a
⊢ True

case a
x : Nat
⊢ Nat
---
trace: x : Nat
y : Nat := ?a
⊢ True

case a
x : Nat
⊢ Nat
-/

#guard_msgs in
example (x : Nat) : True := by
  let y : Nat := ?a
  #check' (by refine rfl : ?a = x)
  trace_state

-- #check' only shows explicit arguments, no implicit or typeclass arguments
set_option linter.unusedTactic false in
/-- info: bar (h : a = b + c) (hc : c = 0) : a = b -/
#guard_msgs in
example : True := by
  #check' bar
  trivial

Messung
CHZG
9410010097

¤ Dauer der Verarbeitung: 0.19 Sekunden  ¤

*Bot Zugriff







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,077
#Domains=862,084