Theorem Proving in Lean
Release 3.23.0you want to reason about in the section. In that case, it would make sense to introduce temporary infix notation like ⪯ for r, and we will see in Section 6.6 how to do that. On the other hand, if you want theorem. variable {α : Type*} def is_prefix (l1 : list α) (l2 : list α) : Prop := ∃ t, l1 ++ t = l2 infix ` <+: `:50 := is_prefix attribute [simp] theorem list.is_prefix_refl (l : list α) : l <+: l := ⟨[] new notation. notation `[` a `**` b `]` := a * b + 1 def mul_square (a b : N) := a * a * b * b infix (name := mul_square) `<*>`:50 := mul_square #reduce [2 ** 3] #reduce 2 <*> 3 In this example, the0 码力 | 173 页 | 777.93 KB | 1 年前3
The Lean Reference Manual
Release 3.3.0following commands can be used in Lean to declare tokens and assign a left-binding power: • reserve infix `tok`:n • reserve infixl `tok`:n • reserve infixr `tok`:n • reserve prefix `tok`:n • reserve postfix that will become a new token, n is a natural number. The annotations infix and infixl mean the same thing, and specify that the infix notation should associate to the left. The keywords prefix and postfix and postfix notation, respectively. Instance of the notation can later be assigned as follows: • infix tok := t where t is the desired interpretation, and similarly for the others. Notation can be overloaded0 码力 | 67 页 | 266.23 KB | 1 年前3
The Hitchhiker’s Guide to
Logical Verificationoperators in infix syntax—e.g., x + y. Such notations are also possible in Lean, as syntactic sugar for (+ ) x y. The parentheses around the + sign are necessary to disable the parsing of + as an infix operator parentheses. They can quickly impair readability. In addition, it is important to put spaces around infix operators, to suggest the right precedence; it is all too easy to misread f x ::reverse ys as f (x ys | (x :: x s) ys := x :: append3 x s ys In Lean’s standard library, the append function is an infix operator called + + . We can use it to define a function that reverses a list: def reverse {α : Type}0 码力 | 215 页 | 1.95 MB | 1 年前3
An Introduction to Leanholds. section sort universe u parameters {α : Type u} (r : α → α → Prop) [decidable_rel r] local infix `` : 50 := r def ordered_insert (a : α) : list α → list α | [] := [a] | (b :: l) := if a b then because Lean’s automation is designed to work well with generic functions and facts. Incidentally, when infix notation is defined for a binary operation, Lean’s parser will let you put the notation in parentheses def pow (a : α) : N → α CHAPTER 4. THEOREM PROVING IN LEAN 43 | 0 := 1 | (n + 1) := a * pow n infix `^` := pow theorem pow_zero (a : α) : a^0 = 1 := rfl theorem pow_succ (a : α) (n : N) : a^(succ0 码力 | 48 页 | 191.92 KB | 1 年前3
Programming in Lean
Release 3.4.2because Lean’s automation is designed to work well with generic functions and facts. Incidentally, when infix notation is defined for a binary operation, Lean’s parser will let you put the notation in parentheses what they all have in common. Lean implements the following common notation. First, we have the infix notation ma >>= f for bind ma f. Think of this as saying “take an element a out of the box, and Remember, we are allowed to do that as long as the return type of f is of the form m β. We also have the infix notation, ma >> mb 23 Programming in Lean, Release 3.4.2 for bind ma (λ a, mb). This takes an0 码力 | 51 页 | 220.07 KB | 1 年前3
共 5 条
- 1













