feat(frontends/lean): rename 'using' command to 'open'
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
6a6f6ed439
commit
e51c4ad2e9
155 changed files with 312 additions and 336 deletions
|
@ -26,7 +26,7 @@ Here is an example
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
variables a b c d e : nat.
|
||||
axiom Ax1 : a = b.
|
||||
axiom Ax2 : b = c + 1.
|
||||
|
@ -55,7 +55,7 @@ some form of transitivity. It can even combine different relations.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
theorem T2 (a b c : nat) (H1 : a = b) (H2 : b = c + 1) : a ≠ 0
|
||||
:= calc a = b : H1
|
||||
|
|
|
@ -30,7 +30,7 @@ the input value.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
-- defines the double function
|
||||
definition double (x : nat) := x + x
|
||||
#+END_SRC
|
||||
|
@ -62,7 +62,7 @@ The command =import= loads existing libraries and extensions.
|
|||
|
||||
We say =nat.ge= is a hierarchical name comprised of two parts: =nat= and =ge=.
|
||||
|
||||
The command =using= creates aliases based on a given prefix. The
|
||||
The command =open= creates aliases based on a given prefix. The
|
||||
command also imports notation, hints, and other features. We will
|
||||
discuss its other applications later. Regarding aliases,
|
||||
the following command creates aliases for all objects starting with
|
||||
|
@ -70,7 +70,7 @@ the following command creates aliases for all objects starting with
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
check ge -- display the type of nat.ge
|
||||
#+END_SRC
|
||||
|
||||
|
@ -79,11 +79,11 @@ that =n=, =m= and =o= have type =nat=.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
variable n : nat
|
||||
variable m : nat
|
||||
variable o : nat
|
||||
-- The command 'using nat' also imported the notation defined at the namespace 'nat'
|
||||
-- The command 'open nat' also imported the notation defined at the namespace 'nat'
|
||||
check n + m
|
||||
check n ≤ m
|
||||
#+END_SRC
|
||||
|
@ -96,7 +96,7 @@ for =n = n=. In Lean, =refl= is the reflexivity theorem.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
variable n : nat
|
||||
check refl n
|
||||
#+END_SRC
|
||||
|
@ -108,7 +108,7 @@ The following commands postulate two axioms =Ax1= and =Ax2= that state that =n =
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
variables m n o : nat
|
||||
axiom Ax1 : n = m
|
||||
axiom Ax2 : m = o
|
||||
|
@ -146,7 +146,7 @@ example, =symm= is the symmetry theorem.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
theorem nat_trans3 (a b c d : nat) (H1 : a = b) (H2 : c = b) (H3 : c = d) : a = d :=
|
||||
trans (trans H1 (symm H2)) H3
|
||||
|
@ -175,7 +175,7 @@ implicit arguments.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
theorem nat_trans3i {a b c d : nat} (H1 : a = b) (H2 : c = b) (H3 : c = d) : a = d :=
|
||||
trans (trans H1 (symm H2)) H3
|
||||
|
@ -210,7 +210,7 @@ This is useful when debugging non-trivial problems.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
variables a b c : nat
|
||||
axiom H1 : a = b
|
||||
|
@ -361,7 +361,7 @@ examples.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
check fun x : nat, x + 1
|
||||
check fun x y : nat, x + 2 * y
|
||||
|
@ -375,7 +375,7 @@ In all examples above, the type can be inferred automatically.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
check fun x, x + 1
|
||||
check fun x y, x + 2 * y
|
||||
|
@ -392,7 +392,7 @@ function applications
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
check (fun x y, x + 2 * y) 1
|
||||
check (fun x y, x + 2 * y) 1 2
|
||||
check (fun x y, not (x ∧ y)) true false
|
||||
|
@ -420,7 +420,7 @@ are equal using just =refl=. Here is a simple example.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
theorem def_eq_th (a : nat) : ((λ x : nat, x + 1) a) = a + 1 := refl (a+1)
|
||||
#+END_SRC
|
||||
|
@ -652,7 +652,7 @@ Then we instantiate the axiom using function application.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
variable f : nat → nat
|
||||
axiom fzero : ∀ x, f x = 0
|
||||
|
@ -668,7 +668,7 @@ abstraction. In the following example, we create a proof term showing that for a
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
variable f : nat → nat
|
||||
axiom fzero : ∀ x, f x = 0
|
||||
|
@ -693,7 +693,7 @@ for =∃ a : nat, a = w= using
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
theorem nat_trans3i {a b c d : nat} (H1 : a = b) (H2 : c = b) (H3 : c = d) : a = d :=
|
||||
trans (trans H1 (symm H2)) H3
|
||||
|
@ -720,7 +720,7 @@ has different values for the implicit argument =P=.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
check @exists_intro
|
||||
variable g : nat → nat → nat
|
||||
|
@ -751,7 +751,7 @@ of two even numbers is an even number.
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
definition even (a : nat) := ∃ b, a = 2*b
|
||||
theorem EvenPlusEven {a b : nat} (H1 : even a) (H2 : even b) : even (a + b) :=
|
||||
|
@ -772,7 +772,7 @@ With this macro we can write the example above in a more natural way
|
|||
|
||||
#+BEGIN_SRC lean
|
||||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
definition even (a : nat) := ∃ b, a = 2*b
|
||||
theorem EvenPlusEven {a b : nat} (H1 : even a) (H2 : even b) : even (a + b) :=
|
||||
obtain (w1 : nat) (Hw1 : a = 2*w1), from H1,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import logic.core.connectives logic.classes.decidable logic.classes.inhabited
|
||||
|
||||
using eq_ops decidable
|
||||
open eq_ops decidable
|
||||
|
||||
inductive bool : Type :=
|
||||
ff : bool,
|
||||
|
|
|
@ -11,20 +11,13 @@ import ..nat.basic ..nat.order ..nat.sub ..prod ..quotient ..quotient tools.tact
|
|||
import struc.binary
|
||||
import tools.fake_simplifier
|
||||
|
||||
using nat (hiding case)
|
||||
using quotient
|
||||
using subtype
|
||||
using prod
|
||||
using relation
|
||||
using decidable
|
||||
using binary
|
||||
using fake_simplifier
|
||||
using eq_ops
|
||||
open nat (hiding case)
|
||||
open quotient subtype prod relation
|
||||
open decidable binary fake_simplifier
|
||||
open eq_ops
|
||||
|
||||
namespace int
|
||||
|
||||
|
||||
-- ## The defining equivalence relation on ℕ × ℕ
|
||||
|
||||
abbreviation rel (a b : ℕ × ℕ) : Prop := pr1 a + pr2 b = pr2 a + pr1 b
|
||||
|
||||
theorem rel_comp (n m k l : ℕ) : (rel (pair n m) (pair k l)) ↔ (n + l = m + k) :=
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
import .basic
|
||||
|
||||
using nat (hiding case)
|
||||
using decidable
|
||||
using fake_simplifier
|
||||
using int eq_ops
|
||||
open nat (hiding case)
|
||||
open decidable
|
||||
open fake_simplifier
|
||||
open int eq_ops
|
||||
|
||||
namespace int
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ import data.nat
|
|||
import logic tools.helper_tactics
|
||||
-- import if -- for find
|
||||
|
||||
using nat
|
||||
using eq_ops
|
||||
using helper_tactics
|
||||
open nat
|
||||
open eq_ops
|
||||
open helper_tactics
|
||||
|
||||
namespace list
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
import logic data.num tools.tactic struc.binary tools.helper_tactics
|
||||
|
||||
using num tactic binary eq_ops
|
||||
using decidable (hiding induction_on rec_on)
|
||||
using relation -- for subst_iff
|
||||
using helper_tactics
|
||||
open num tactic binary eq_ops
|
||||
open decidable (hiding induction_on rec_on)
|
||||
open relation -- for subst_iff
|
||||
open helper_tactics
|
||||
|
||||
-- Definition of the type
|
||||
-- ----------------------
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
import logic .sub struc.relation data.prod
|
||||
import tools.fake_simplifier
|
||||
|
||||
using nat relation relation.iff_ops prod
|
||||
using fake_simplifier decidable
|
||||
using eq_ops
|
||||
open nat relation relation.iff_ops prod
|
||||
open fake_simplifier decidable
|
||||
open eq_ops
|
||||
|
||||
namespace nat
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
import .basic logic.classes.decidable
|
||||
import tools.fake_simplifier
|
||||
|
||||
using nat eq_ops tactic
|
||||
using fake_simplifier
|
||||
using decidable (decidable inl inr)
|
||||
open nat eq_ops tactic
|
||||
open fake_simplifier
|
||||
open decidable (decidable inl inr)
|
||||
|
||||
namespace nat
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
import data.nat.order
|
||||
import tools.fake_simplifier
|
||||
|
||||
using nat eq_ops tactic
|
||||
using helper_tactics
|
||||
using fake_simplifier
|
||||
open nat eq_ops tactic
|
||||
open helper_tactics
|
||||
open fake_simplifier
|
||||
|
||||
namespace nat
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
-- Author: Leonardo de Moura
|
||||
|
||||
import logic.core.eq logic.classes.inhabited logic.classes.decidable
|
||||
using eq_ops decidable
|
||||
open eq_ops decidable
|
||||
|
||||
namespace option
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
import logic.classes.inhabited logic.core.eq logic.classes.decidable
|
||||
|
||||
using inhabited decidable
|
||||
open inhabited decidable
|
||||
|
||||
inductive prod (A B : Type) : Type :=
|
||||
pair : A → B → prod A B
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
import logic ..prod struc.relation
|
||||
import tools.fake_simplifier
|
||||
|
||||
using prod eq_ops
|
||||
using fake_simplifier
|
||||
open prod eq_ops
|
||||
open fake_simplifier
|
||||
|
||||
namespace quotient
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ import logic tools.tactic ..subtype logic.core.cast struc.relation data.prod
|
|||
import logic.core.instances
|
||||
import .aux
|
||||
|
||||
using relation prod inhabited nonempty tactic eq_ops
|
||||
using subtype relation.iff_ops
|
||||
open relation prod inhabited nonempty tactic eq_ops
|
||||
open subtype relation.iff_ops
|
||||
|
||||
namespace quotient
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import logic.axioms.classical logic.axioms.hilbert logic.axioms.funext
|
|||
|
||||
namespace quotient
|
||||
|
||||
using relation nonempty subtype
|
||||
open relation nonempty subtype
|
||||
|
||||
-- abstract quotient
|
||||
-- -----------------
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
--- Author: Jeremy Avigad, Leonardo de Moura
|
||||
----------------------------------------------------------------------------------------------------
|
||||
import data.bool
|
||||
using eq_ops bool
|
||||
open eq_ops bool
|
||||
|
||||
namespace set
|
||||
definition set (T : Type) :=
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import logic.classes.inhabited logic.core.eq
|
||||
|
||||
using inhabited
|
||||
open inhabited
|
||||
|
||||
inductive sigma {A : Type} (B : A → Type) : Type :=
|
||||
dpair : Πx : A, B x → sigma B
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import data.bool
|
||||
|
||||
using bool inhabited
|
||||
open bool inhabited
|
||||
|
||||
namespace string
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import logic.classes.inhabited logic.core.eq logic.classes.decidable
|
||||
|
||||
using decidable
|
||||
open decidable
|
||||
|
||||
inductive subtype {A : Type} (P : A → Prop) : Type :=
|
||||
tag : Πx : A, P x → subtype P
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
import logic.core.prop logic.classes.inhabited logic.classes.decidable
|
||||
|
||||
using inhabited decidable
|
||||
open inhabited decidable
|
||||
|
||||
namespace sum
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import logic.classes.decidable logic.classes.inhabited
|
||||
|
||||
using decidable
|
||||
open decidable
|
||||
|
||||
namespace unit
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import data.unit data.bool data.nat
|
||||
import data.prod data.sum data.sigma
|
||||
|
||||
using unit bool nat prod sum sigma
|
||||
open unit bool nat prod sum sigma
|
||||
|
||||
inductive fibrant (T : Type) : Type :=
|
||||
fibrant_mk : fibrant T
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
import general_notation struc.function
|
||||
|
||||
using function
|
||||
open function
|
||||
|
||||
-- Path
|
||||
-- ----
|
||||
|
@ -30,7 +30,7 @@ end path
|
|||
|
||||
|
||||
-- TODO: should all this be in namespace path?
|
||||
using path (induction_on)
|
||||
open path (induction_on)
|
||||
|
||||
-- Concatenation and inverse
|
||||
-- -------------------------
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import logic.core.quantifiers logic.core.cast struc.relation
|
||||
|
||||
using eq_ops
|
||||
open eq_ops
|
||||
|
||||
axiom prop_complete (a : Prop) : a = true ∨ a = false
|
||||
|
||||
|
@ -48,7 +48,7 @@ propext
|
|||
(assume H, iff_to_eq H)
|
||||
(assume H, eq_to_iff H)
|
||||
|
||||
using relation
|
||||
open relation
|
||||
theorem iff_congruence [instance] (P : Prop → Prop) : congruence iff iff P :=
|
||||
congruence_mk
|
||||
(take (a b : Prop),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
-- Author: Leonardo de Moura
|
||||
|
||||
import logic.axioms.hilbert logic.axioms.funext
|
||||
using eq_ops nonempty inhabited
|
||||
open eq_ops nonempty inhabited
|
||||
|
||||
-- Diaconescu’s theorem
|
||||
-- Show that Excluded middle follows from
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
import logic.core.eq struc.function
|
||||
using function
|
||||
open function
|
||||
|
||||
-- Function extensionality
|
||||
axiom funext : ∀ {A : Type} {B : A → Type} {f g : Π x, B x} (H : ∀ x, f x = g x), f = g
|
||||
|
|
|
@ -12,7 +12,7 @@ import logic.core.quantifiers
|
|||
import logic.classes.inhabited logic.classes.nonempty
|
||||
import data.subtype data.sum
|
||||
|
||||
using subtype inhabited nonempty
|
||||
open subtype inhabited nonempty
|
||||
|
||||
|
||||
-- the axiom
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import logic.classes.inhabited logic.core.cast
|
||||
|
||||
using inhabited
|
||||
open inhabited
|
||||
|
||||
-- Pi extensionality
|
||||
axiom piext {A : Type} {B B' : A → Type} {H : inhabited (Π x, B x)} :
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
-- ===========================
|
||||
|
||||
import logic.axioms.classical logic.axioms.hilbert logic.classes.decidable
|
||||
using decidable inhabited nonempty
|
||||
open decidable inhabited nonempty
|
||||
|
||||
-- Excluded middle + Hilbert implies every proposition is decidable
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import .inhabited
|
||||
|
||||
using inhabited
|
||||
open inhabited
|
||||
|
||||
namespace nonempty
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import .eq .quantifiers
|
||||
|
||||
using eq_ops
|
||||
open eq_ops
|
||||
|
||||
definition cast {A B : Type} (H : A = B) (a : A) : B :=
|
||||
eq_rec a H
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace eq_ops
|
|||
infixr `⬝` := trans
|
||||
infixr `▸` := subst
|
||||
end eq_ops
|
||||
using eq_ops
|
||||
open eq_ops
|
||||
|
||||
theorem true_ne_false : ¬true = false :=
|
||||
assume H : true = false,
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
|
||||
import ..instances
|
||||
|
||||
using relation
|
||||
|
||||
using relation.general_operations
|
||||
using relation.iff_ops
|
||||
using eq_ops
|
||||
open relation
|
||||
open relation.general_operations
|
||||
open relation.iff_ops
|
||||
open eq_ops
|
||||
|
||||
section
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
import logic.core.instances logic.classes.decidable logic.core.quantifiers logic.core.cast
|
||||
|
||||
using relation decidable relation.iff_ops
|
||||
open relation decidable relation.iff_ops
|
||||
|
||||
theorem or_right_comm (a b c : Prop) : (a ∨ b) ∨ c ↔ (a ∨ c) ∨ b :=
|
||||
calc
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
import logic.classes.decidable tools.tactic
|
||||
using decidable tactic eq_ops
|
||||
open decidable tactic eq_ops
|
||||
|
||||
definition ite (c : Prop) {H : decidable c} {A : Type} (t e : A) : A :=
|
||||
decidable.rec_on H (assume Hc, t) (assume Hnc, e)
|
||||
|
|
|
@ -9,7 +9,7 @@ import logic.core.connectives struc.relation
|
|||
|
||||
namespace relation
|
||||
|
||||
using relation
|
||||
open relation
|
||||
|
||||
-- Congruences for logic
|
||||
-- ---------------------
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import .connectives ..classes.nonempty
|
||||
|
||||
using inhabited nonempty
|
||||
open inhabited nonempty
|
||||
|
||||
inductive Exists {A : Type} (P : A → Prop) : Prop :=
|
||||
exists_intro : ∀ (a : A), P a → Exists P
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
||||
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||
-- Author: Leonardo de Moura
|
||||
|
||||
import logic.core.eq
|
||||
using eq_ops
|
||||
open eq_ops
|
||||
|
||||
namespace binary
|
||||
section
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import logic.axioms.classical logic.axioms.prop_decidable logic.classes.decidable
|
||||
import logic.core.identities
|
||||
|
||||
using decidable
|
||||
open decidable
|
||||
|
||||
-- Well-founded relation definition
|
||||
-- We are essentially saying that a relation R is well-founded
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import .tactic
|
||||
using tactic
|
||||
open tactic
|
||||
|
||||
namespace fake_simplifier
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
import .tactic
|
||||
|
||||
using tactic
|
||||
open tactic
|
||||
|
||||
namespace helper_tactics
|
||||
definition apply_refl := apply @refl
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
----------------------------------------------------------------------------------------------------
|
||||
|
||||
import data.string data.num
|
||||
using string
|
||||
using num
|
||||
open string
|
||||
open num
|
||||
|
||||
namespace tactic
|
||||
-- This is just a trick to embed the 'tactic language' as a
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
'("import" "abbreviation" "opaque_hint" "tactic_hint" "definition" "renaming"
|
||||
"inline" "hiding" "exposing" "parameter" "parameters" "begin" "proof" "qed" "conjecture"
|
||||
"hypothesis" "lemma" "corollary" "variable" "variables" "print" "theorem"
|
||||
"axiom" "inductive" "with" "structure" "universe" "alias" "help" "environment"
|
||||
"context" "open" "axiom" "inductive" "with" "structure" "universe" "alias" "help" "environment"
|
||||
"options" "precedence" "postfix" "prefix" "calc_trans" "calc_subst" "calc_refl"
|
||||
"infix" "infixl" "infixr" "notation" "eval" "check" "exit" "coercion" "end"
|
||||
"private" "using" "namespace" "builtin" "including" "instance" "class" "section"
|
||||
|
@ -60,10 +60,6 @@
|
|||
;; Constants
|
||||
(,(rx (or "#" "@" "->" "∼" "↔" "/" "==" "=" ":=" "<->" "/\\" "\\/" "∧" "∨" "≠" "<" ">" "≤" "≥" "¬" "<=" ">=" "⁻¹" "⬝" "▸" "+" "*" "-" "/")) . 'font-lock-constant-face)
|
||||
(,(rx (or "λ" "→" "∃" "∀" ":=")) . 'font-lock-constant-face )
|
||||
(,(rx symbol-start
|
||||
(or "\\b.*_tac" "Cond" "or_else" "then" "try" "when" "assumption" "apply" "back" "beta" "done" "exact")
|
||||
symbol-end)
|
||||
. 'font-lock-constant-face)
|
||||
;; universe/inductive/theorem... "names"
|
||||
(,(rx symbol-start
|
||||
(group (or "universe" "inductive" "theorem" "axiom" "lemma" "hypothesis"
|
||||
|
@ -76,7 +72,12 @@
|
|||
;; place holder
|
||||
(,(rx symbol-start "_" symbol-end) . 'font-lock-preprocessor-face)
|
||||
;; modifiers
|
||||
(,(rx (or "\[protected\]" "\[private\]" "\[instance\]" "\[coercion\]" "\[inline\]")) . 'font-lock-doc-face)
|
||||
(,(rx (or "\[notation\]" "\[protected\]" "\[private\]" "\[instance\]" "\[coercion\]" "\[inline\]")) . 'font-lock-doc-face)
|
||||
;; tactics
|
||||
(,(rx symbol-start
|
||||
(or "\\b.*_tac" "Cond" "or_else" "then" "try" "when" "assumption" "apply" "back" "beta" "done" "exact" "repeat")
|
||||
symbol-end)
|
||||
. 'font-lock-constant-face)
|
||||
;; sorry
|
||||
(,(rx symbol-start "sorry" symbol-end) . 'font-lock-warning-face)
|
||||
;; ? query
|
||||
|
|
|
@ -166,9 +166,9 @@ static name parse_class(parser & p) {
|
|||
else if (p.curr_is_keyword() || p.curr_is_command())
|
||||
n = p.get_token_info().value();
|
||||
else
|
||||
throw parser_error("invalid 'using' command, identifier or symbol expected", p.pos());
|
||||
throw parser_error("invalid 'open' command, identifier or symbol expected", p.pos());
|
||||
p.next();
|
||||
p.check_token_next(g_rbracket, "invalid 'using' command, ']' expected");
|
||||
p.check_token_next(g_rbracket, "invalid 'open' command, ']' expected");
|
||||
return n;
|
||||
} else {
|
||||
return name();
|
||||
|
@ -178,17 +178,17 @@ static name parse_class(parser & p) {
|
|||
static void check_identifier(parser & p, environment const & env, name const & ns, name const & id) {
|
||||
name full_id = ns + id;
|
||||
if (!env.find(full_id))
|
||||
throw parser_error(sstream() << "invalid 'using' command, unknown declaration '" << full_id << "'", p.pos());
|
||||
throw parser_error(sstream() << "invalid 'open' command, unknown declaration '" << full_id << "'", p.pos());
|
||||
}
|
||||
|
||||
// using [class] id (id ...) (renaming id->id id->id) (hiding id ... id)
|
||||
environment using_cmd(parser & p) {
|
||||
// open [class] id (id ...) (renaming id->id id->id) (hiding id ... id)
|
||||
environment open_cmd(parser & p) {
|
||||
environment env = p.env();
|
||||
while (true) {
|
||||
name cls = parse_class(p);
|
||||
bool decls = cls.is_anonymous() || cls == g_decls || cls == g_declarations;
|
||||
auto pos = p.pos();
|
||||
name ns = p.check_id_next("invalid 'using' command, identifier expected");
|
||||
name ns = p.check_id_next("invalid 'open' command, identifier expected");
|
||||
optional<name> real_ns = to_valid_namespace_name(env, ns);
|
||||
if (!real_ns)
|
||||
throw parser_error(sstream() << "invalid namespace name '" << ns << "'", pos);
|
||||
|
@ -205,8 +205,8 @@ environment using_cmd(parser & p) {
|
|||
while (p.curr_is_identifier()) {
|
||||
name from_id = p.get_name_val();
|
||||
p.next();
|
||||
p.check_token_next(g_arrow, "invalid 'using' command renaming, '->' expected");
|
||||
name to_id = p.check_id_next("invalid 'using' command renaming, identifier expected");
|
||||
p.check_token_next(g_arrow, "invalid 'open' command renaming, '->' expected");
|
||||
name to_id = p.check_id_next("invalid 'open' command renaming, identifier expected");
|
||||
check_identifier(p, env, ns, from_id);
|
||||
exceptions.push_back(from_id);
|
||||
env = add_expr_alias(env, to_id, ns+from_id);
|
||||
|
@ -228,11 +228,11 @@ environment using_cmd(parser & p) {
|
|||
env = add_expr_alias(env, id, ns+id);
|
||||
}
|
||||
} else {
|
||||
throw parser_error("invalid 'using' command option, identifier, 'hiding' or 'renaming' expected", p.pos());
|
||||
throw parser_error("invalid 'open' command option, identifier, 'hiding' or 'renaming' expected", p.pos());
|
||||
}
|
||||
if (found_explicit && !exceptions.empty())
|
||||
throw parser_error("invalid 'using' command option, mixing explicit and implicit 'using' options", p.pos());
|
||||
p.check_token_next(g_rparen, "invalid 'using' command option, ')' expected");
|
||||
throw parser_error("invalid 'open' command option, mixing explicit and implicit 'open' options", p.pos());
|
||||
p.check_token_next(g_rparen, "invalid 'open' command option, ')' expected");
|
||||
}
|
||||
if (!found_explicit)
|
||||
env = add_aliases(env, ns, name(), exceptions.size(), exceptions.data());
|
||||
|
@ -303,7 +303,7 @@ environment erase_cache_cmd(parser & p) {
|
|||
|
||||
cmd_table init_cmd_table() {
|
||||
cmd_table r;
|
||||
add_cmd(r, cmd_info("using", "create aliases for declarations, and use objects defined in other namespaces", using_cmd));
|
||||
add_cmd(r, cmd_info("open", "create aliases for declarations, and use objects defined in other namespaces", open_cmd));
|
||||
add_cmd(r, cmd_info("set_option", "set configuration option", set_option_cmd));
|
||||
add_cmd(r, cmd_info("exit", "exit", exit_cmd));
|
||||
add_cmd(r, cmd_info("print", "print a string", print_cmd));
|
||||
|
|
|
@ -68,7 +68,7 @@ token_table init_token_table() {
|
|||
pair<char const *, unsigned> builtin[] =
|
||||
{{"fun", 0}, {"Pi", 0}, {"let", 0}, {"in", 0}, {"have", 0}, {"show", 0}, {"obtain", 0}, {"by", 0}, {"then", 0},
|
||||
{"from", 0}, {"(", g_max_prec}, {")", 0}, {"{", g_max_prec}, {"}", 0}, {"_", g_max_prec},
|
||||
{"[", g_max_prec}, {"]", 0}, {"⦃", g_max_prec}, {"⦄", 0}, {".{", 0}, {"Type", g_max_prec}, {"Type'", g_max_prec},
|
||||
{"[", g_max_prec}, {"]", 0}, {"⦃", g_max_prec}, {"⦄", 0}, {".{", 0}, {"Type", g_max_prec}, {"Type'", g_max_prec}, {"using", 0},
|
||||
{"|", 0}, {"!", 0}, {"?", 0}, {"with", 0}, {"...", 0}, {",", 0}, {".", 0}, {":", 0}, {"::", 0}, {"calc", 0}, {":=", 0}, {"--", 0}, {"#", 0},
|
||||
{"(*", 0}, {"/-", 0}, {"begin", g_max_prec}, {"proof", g_max_prec}, {"qed", 0}, {"@", g_max_prec}, {"including", 0}, {"sorry", g_max_prec},
|
||||
{"+", g_plus_prec}, {g_cup, g_cup_prec}, {"->", g_arrow_prec}, {nullptr, 0}};
|
||||
|
@ -78,7 +78,7 @@ token_table init_token_table() {
|
|||
"abbreviation", "opaque_hint", "evaluate", "check", "print", "end", "namespace", "section", "import",
|
||||
"abbreviation", "inductive", "record", "renaming", "extends", "structure", "module", "universe",
|
||||
"precedence", "infixl", "infixr", "infix", "postfix", "prefix", "notation", "context",
|
||||
"exit", "set_option", "using", "calc_subst", "calc_refl", "calc_trans", "tactic_hint",
|
||||
"exit", "set_option", "open", "calc_subst", "calc_refl", "calc_trans", "tactic_hint",
|
||||
"add_begin_end_tactic", "set_begin_end_tactic", "instance", "class", "#erase_cache", nullptr};
|
||||
|
||||
pair<char const *, char const *> aliases[] =
|
||||
|
|
|
@ -10,16 +10,15 @@ namespace N2
|
|||
variable foo : val → val → val
|
||||
end N2
|
||||
|
||||
using N2
|
||||
using N1
|
||||
open N2
|
||||
open N1
|
||||
variables a b : num
|
||||
print raw foo a b
|
||||
using N2
|
||||
open N2
|
||||
print raw foo a b
|
||||
using N1
|
||||
open N1
|
||||
print raw foo a b
|
||||
using N1
|
||||
open N1
|
||||
print raw foo a b
|
||||
using N2
|
||||
open N2
|
||||
print raw foo a b
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace N2
|
|||
definition pr {A : Type} (a b : A) := b
|
||||
end N2
|
||||
|
||||
using N1 N2
|
||||
open N1 N2
|
||||
variable N : Type.{1}
|
||||
variables a b : N
|
||||
check @pr
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic logic.axioms.hilbert
|
||||
using inhabited nonempty
|
||||
open inhabited nonempty
|
||||
|
||||
definition v1 : Prop := epsilon (λ x, true)
|
||||
inductive Empty : Type
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic tools.tactic
|
||||
using tactic
|
||||
open tactic
|
||||
|
||||
definition simple := apply trivial
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using bool eq_ops tactic
|
||||
open bool eq_ops tactic
|
||||
|
||||
variables a b c : bool
|
||||
axiom H1 : a = b
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic.axioms.hilbert data.nat.basic
|
||||
using nonempty inhabited nat
|
||||
open nonempty inhabited nat
|
||||
|
||||
theorem int_inhabited [instance] : inhabited nat := inhabited_mk zero
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import data.num
|
||||
using num
|
||||
open num
|
||||
|
||||
variable f : num → num → num → num
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import data.num
|
||||
using num
|
||||
open num
|
||||
|
||||
variable f : num → num → num → num
|
||||
|
||||
|
@ -15,5 +15,3 @@ check
|
|||
d := 10,
|
||||
e := f (f 10 10 d) (f d 10 10) a
|
||||
in f a b (f e d 10)
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import data.num
|
||||
using num
|
||||
open num
|
||||
|
||||
check 10
|
||||
check 20
|
||||
|
|
|
@ -5,6 +5,6 @@ namespace foo
|
|||
definition D := true
|
||||
end foo
|
||||
|
||||
using foo
|
||||
open foo
|
||||
check C
|
||||
check D
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using num
|
||||
open num
|
||||
|
||||
abbreviation Type1 := Type.{1}
|
||||
|
||||
|
@ -88,7 +88,7 @@ namespace monoid
|
|||
definition assoc [inline] {A : Type} (s : monoid_struct A) : is_assoc (mul s)
|
||||
:= monoid_struct_rec (fun mul id a i, a) s
|
||||
|
||||
using semigroup
|
||||
open semigroup
|
||||
definition is_semigroup_struct [inline] [instance] (A : Type) (s : monoid_struct A) : semigroup_struct A
|
||||
:= mk_semigroup_struct (mul s) (assoc s)
|
||||
|
||||
|
@ -104,7 +104,7 @@ end monoid
|
|||
end algebra
|
||||
|
||||
section
|
||||
using algebra algebra.semigroup algebra.monoid
|
||||
open algebra algebra.semigroup algebra.monoid
|
||||
variable M : monoid
|
||||
variables a b c : M
|
||||
check a*b*c*a*b*c*a*b*a*b*c*a
|
||||
|
|
|
@ -10,8 +10,8 @@ namespace N2
|
|||
variable foo : val → val → val
|
||||
end N2
|
||||
|
||||
using N1
|
||||
using N2
|
||||
open N1
|
||||
open N2
|
||||
variables a b : num
|
||||
variables x y : val
|
||||
|
||||
|
@ -35,7 +35,7 @@ definition aux1 := foo a b -- System elaborated it to N1.foo a b
|
|||
theorem T2 : aux1 = N1.foo a b
|
||||
:= refl _
|
||||
|
||||
using N1
|
||||
open N1
|
||||
definition aux2 := foo a b -- Now N1 is in the end of the queue, this is elaborated to N2.foo (f a) (f b)
|
||||
check aux2
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ namespace N2
|
|||
variable foo : val → val → val
|
||||
end N2
|
||||
|
||||
using N1
|
||||
using N2
|
||||
open N1
|
||||
open N2
|
||||
variables a b : num
|
||||
variable f : num → val
|
||||
coercion f
|
||||
|
@ -20,4 +20,3 @@ definition aux2 := foo a b
|
|||
check aux2
|
||||
theorem T3 : aux2 = N1.foo a b
|
||||
:= refl _
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import data.bool
|
||||
using bool
|
||||
open bool
|
||||
|
||||
check ff
|
|
@ -1,5 +1,5 @@
|
|||
import data.num
|
||||
using num
|
||||
open num
|
||||
|
||||
namespace foo
|
||||
variable le : num → num → Prop
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import data.nat.basic
|
||||
using nat
|
||||
open nat
|
||||
|
||||
set_option pp.coercion true
|
||||
|
||||
|
@ -8,7 +8,7 @@ theorem trans {a b c : nat} (H1 : a = b) (H2 : b = c) : a = c :=
|
|||
trans H1 H2
|
||||
end foo
|
||||
|
||||
using foo
|
||||
open foo
|
||||
|
||||
theorem tst (a b : nat) (H0 : b = a) (H : b = 0) : a = 0
|
||||
:= have H1 : a = b, from symm H0,
|
||||
|
@ -17,4 +17,3 @@ theorem tst (a b : nat) (H0 : b = a) (H : b = 0) : a = 0
|
|||
definition f (a b : nat) :=
|
||||
let x := 3 in
|
||||
a + x
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic data.prod
|
||||
using num prod inhabited
|
||||
open num prod inhabited
|
||||
|
||||
definition H : inhabited (Prop × num × (num → num)) := _
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic data.prod
|
||||
using num prod nonempty inhabited
|
||||
open num prod nonempty inhabited
|
||||
|
||||
theorem H {A B : Type} (H1 : inhabited A) : inhabited (Prop × A × (B → num))
|
||||
:= _
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic data.prod
|
||||
using num prod inhabited
|
||||
open num prod inhabited
|
||||
|
||||
section
|
||||
parameter {A : Type}
|
||||
|
|
|
@ -23,36 +23,36 @@ namespace nat
|
|||
end nat
|
||||
|
||||
section
|
||||
using algebra nat
|
||||
open algebra nat
|
||||
variables a b c : nat
|
||||
check a * b * c
|
||||
definition tst1 : nat := a * b * c
|
||||
end
|
||||
|
||||
section
|
||||
using [notation] algebra
|
||||
using nat
|
||||
-- check mul_struct nat << This is an error, we are using only the notation from algebra
|
||||
open [notation] algebra
|
||||
open nat
|
||||
-- check mul_struct nat << This is an error, we are open only the notation from algebra
|
||||
variables a b c : nat
|
||||
check a * b * c
|
||||
definition tst2 : nat := a * b * c
|
||||
end
|
||||
|
||||
section
|
||||
using nat
|
||||
-- check mul_struct nat << This is an error, we are using only the notation from algebra
|
||||
open nat
|
||||
-- check mul_struct nat << This is an error, we are open only the notation from algebra
|
||||
variables a b c : nat
|
||||
check #algebra a*b*c
|
||||
definition tst3 : nat := #algebra a*b*c
|
||||
end
|
||||
|
||||
section
|
||||
using nat
|
||||
open nat
|
||||
set_option pp.implicit true
|
||||
definition add_struct [instance] : algebra.mul_struct nat
|
||||
:= algebra.mk_mul_struct add
|
||||
|
||||
variables a b c : nat
|
||||
check #algebra a*b*c -- << is using add instead of mul
|
||||
check #algebra a*b*c -- << is open add instead of mul
|
||||
definition tst4 : nat := #algebra a*b*c
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic data.prod
|
||||
using prod
|
||||
open prod
|
||||
|
||||
inductive t1 : Type :=
|
||||
mk1 : t1
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using num tactic
|
||||
open num tactic
|
||||
|
||||
inductive inh (A : Type) : Type :=
|
||||
inh_intro : A -> inh A
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic data.prod
|
||||
using num tactic prod
|
||||
open num tactic prod
|
||||
|
||||
inductive inh (A : Type) : Prop :=
|
||||
inh_intro : A -> inh A
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import data.num
|
||||
using num
|
||||
open num
|
||||
|
||||
variables int nat real : Type.{1}
|
||||
variable nat_add : nat → nat → nat
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
definition tst1 : Prop := zero = 0
|
||||
definition tst2 : nat := 0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
inductive list (T : Type) : Type :=
|
||||
nil {} : list T,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
--- Author: Jeremy Avigad
|
||||
----------------------------------------------------------------------------------------------------
|
||||
import logic.core.connectives struc.function
|
||||
using function
|
||||
open function
|
||||
|
||||
namespace congr
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic data.unit
|
||||
using bool unit decidable
|
||||
open bool unit decidable
|
||||
|
||||
variables a b c : bool
|
||||
variables u v : unit
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
precedence `+`:65
|
||||
|
||||
namespace nat
|
||||
|
@ -8,7 +7,7 @@ namespace nat
|
|||
end nat
|
||||
|
||||
namespace int
|
||||
using nat (nat)
|
||||
open nat (nat)
|
||||
variable int : Type.{1}
|
||||
variable add : int → int → int
|
||||
infixl + := add
|
||||
|
@ -17,8 +16,8 @@ namespace int
|
|||
end int
|
||||
|
||||
section
|
||||
using nat
|
||||
using int
|
||||
open nat
|
||||
open int
|
||||
|
||||
variables n m : nat
|
||||
variables i j : int
|
||||
|
@ -36,7 +35,7 @@ section
|
|||
|
||||
-- Moving 'nat' to the 'front'
|
||||
print ">>> Moving nat notation to the 'front'"
|
||||
using nat
|
||||
open nat
|
||||
print raw i + n
|
||||
check n + m
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace nat
|
|||
end nat
|
||||
|
||||
namespace int
|
||||
using nat (nat)
|
||||
open nat (nat)
|
||||
variable int : Type.{1}
|
||||
variable add : int → int → int
|
||||
infixl + := add
|
||||
|
@ -16,18 +16,18 @@ namespace int
|
|||
end int
|
||||
|
||||
section
|
||||
-- Using "only" the notation and declarations from the namespaces nat and int
|
||||
using [notation] nat
|
||||
using [notation] int
|
||||
using [decls] nat
|
||||
using [decls] int
|
||||
-- Open "only" the notation and declarations from the namespaces nat and int
|
||||
open [notation] nat
|
||||
open [notation] int
|
||||
open [decls] nat
|
||||
open [decls] int
|
||||
|
||||
variables n m : nat
|
||||
variables i j : int
|
||||
check n + m
|
||||
check i + j
|
||||
|
||||
-- The following check does not work, since we are not using the coercions
|
||||
-- The following check does not work, since we are not open the coercions
|
||||
-- check n + i
|
||||
|
||||
-- Here is a possible trick for this kind of configuration
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace nat
|
|||
end nat
|
||||
|
||||
namespace int
|
||||
using nat (nat)
|
||||
open nat (nat)
|
||||
variable int : Type.{1}
|
||||
variable add : int → int → int
|
||||
infixl + := add
|
||||
|
@ -19,17 +19,17 @@ variables n m : nat.nat
|
|||
variables i j : int.int
|
||||
|
||||
section
|
||||
using [notation] nat
|
||||
using [notation] int
|
||||
using [decls] nat
|
||||
using [decls] int
|
||||
open [notation] nat
|
||||
open [notation] int
|
||||
open [decls] nat
|
||||
open [decls] int
|
||||
check n+m
|
||||
check i+j
|
||||
-- check i+n -- Error
|
||||
end
|
||||
|
||||
namespace int
|
||||
using [decls] nat (nat)
|
||||
open [decls] nat (nat)
|
||||
-- Here is a possible trick for this kind of configuration
|
||||
definition add_ni (a : nat) (b : int) := (of_nat a) + b
|
||||
definition add_in (a : int) (b : nat) := a + (of_nat b)
|
||||
|
@ -38,18 +38,18 @@ namespace int
|
|||
end int
|
||||
|
||||
section
|
||||
using [notation] nat
|
||||
using [notation] int
|
||||
using [declarations] nat
|
||||
using [declarations] int
|
||||
open [notation] nat
|
||||
open [notation] int
|
||||
open [declarations] nat
|
||||
open [declarations] int
|
||||
check n+m
|
||||
check i+n
|
||||
check n+i
|
||||
end
|
||||
|
||||
section
|
||||
using nat
|
||||
using int
|
||||
open nat
|
||||
open int
|
||||
check n+m
|
||||
check i+n
|
||||
end
|
|
@ -7,7 +7,7 @@ namespace nat
|
|||
end nat
|
||||
|
||||
namespace int
|
||||
using nat (nat)
|
||||
open nat (nat)
|
||||
variable int : Type.{1}
|
||||
variable add : int → int → int
|
||||
infixl + := add
|
||||
|
@ -17,10 +17,9 @@ namespace int
|
|||
end coercions
|
||||
end int
|
||||
|
||||
using nat
|
||||
using int
|
||||
open nat
|
||||
open int
|
||||
variables n m : nat
|
||||
check n+m -- coercion nat -> int is not available
|
||||
using int.coercions
|
||||
open int.coercions
|
||||
check n+m -- coercion nat -> int is available
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
precedence `+`:65
|
||||
|
||||
namespace nat
|
||||
|
@ -8,7 +7,7 @@ namespace nat
|
|||
end nat
|
||||
|
||||
namespace int
|
||||
using nat (nat)
|
||||
open nat (nat)
|
||||
variable int : Type.{1}
|
||||
variable add : int → int → int
|
||||
infixl + := add
|
||||
|
@ -16,8 +15,8 @@ namespace int
|
|||
coercion of_nat
|
||||
end int
|
||||
|
||||
using int
|
||||
using nat
|
||||
open int
|
||||
open nat
|
||||
|
||||
variables n m : nat
|
||||
variables i j : int
|
||||
|
@ -29,5 +28,3 @@ check i + n + n + n + n + n + n + n + n + n + n + n +
|
|||
n + n + n + n + n + n + n + n + n + n + n + n +
|
||||
n + n + n + n + n + n + n + n + n + n + n + n +
|
||||
n + n + n + n + n + n + n + n + n + n + n + n
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
precedence `+`:65
|
||||
|
||||
namespace nat
|
||||
|
@ -8,7 +7,7 @@ namespace nat
|
|||
end nat
|
||||
|
||||
namespace int
|
||||
using nat (nat)
|
||||
open nat (nat)
|
||||
variable int : Type.{1}
|
||||
variable add : int → int → int
|
||||
infixl + := add
|
||||
|
@ -16,8 +15,8 @@ namespace int
|
|||
coercion of_nat
|
||||
end int
|
||||
|
||||
using nat
|
||||
using int
|
||||
open nat
|
||||
open int
|
||||
|
||||
variables n m : nat
|
||||
variables i j : int
|
||||
|
@ -34,6 +33,6 @@ check #nat n + m
|
|||
|
||||
-- Moving 'nat' to the 'front'
|
||||
print ">>> Moving nat notation to the 'front'"
|
||||
using nat
|
||||
open nat
|
||||
print raw i + n
|
||||
check n + m
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace nat
|
|||
end nat
|
||||
|
||||
namespace int
|
||||
using nat (nat)
|
||||
open nat (nat)
|
||||
variable int : Type.{1}
|
||||
variable add : int → int → int
|
||||
infixl + := add
|
||||
|
@ -15,18 +15,18 @@ namespace int
|
|||
coercion of_nat
|
||||
end int
|
||||
|
||||
-- Using "only" the notation and declarations from the namespaces nat and int
|
||||
using [notation] nat
|
||||
using [notation] int
|
||||
using [decls] nat
|
||||
using [decls] int
|
||||
-- Open "only" the notation and declarations from the namespaces nat and int
|
||||
open [notation] nat
|
||||
open [notation] int
|
||||
open [decls] nat
|
||||
open [decls] int
|
||||
|
||||
variables n m : nat
|
||||
variables i j : int
|
||||
check n + m
|
||||
check i + j
|
||||
|
||||
-- The following check does not work, since we are not using the coercions
|
||||
-- The following check does not work, since we are not open the coercions
|
||||
-- check n + i
|
||||
|
||||
-- Here is a possible trick for this kind of configuration
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace nat
|
|||
end nat
|
||||
|
||||
namespace int
|
||||
using nat (nat)
|
||||
open nat (nat)
|
||||
variable int : Type.{1}
|
||||
variable add : int → int → int
|
||||
infixl + := add
|
||||
|
@ -18,9 +18,9 @@ namespace int_coercions
|
|||
coercion int.of_nat
|
||||
end int_coercions
|
||||
|
||||
-- Using "only" the notation and declarations from the namespaces nat and int
|
||||
using nat
|
||||
using int
|
||||
-- Open "only" the notation and declarations from the namespaces nat and int
|
||||
open nat
|
||||
open int
|
||||
|
||||
variables n m : nat
|
||||
variables i j : int
|
||||
|
@ -29,10 +29,9 @@ check i + j
|
|||
|
||||
section
|
||||
-- Temporarily use the int_coercions
|
||||
using int_coercions
|
||||
open int_coercions
|
||||
check n + i
|
||||
end
|
||||
|
||||
-- The following one is an error
|
||||
-- check n + i
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import logic struc.function
|
||||
|
||||
using function
|
||||
open function
|
||||
|
||||
namespace congruence
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using num
|
||||
open num
|
||||
variable p : num → num → num → Prop
|
||||
axiom H1 : ∃ x y z, p x y z
|
||||
axiom H2 : ∀ {x y z : num}, p x y z → p x x x
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using num tactic
|
||||
open num tactic
|
||||
variable p : num → num → num → Prop
|
||||
axiom H1 : ∃ x y z, p x y z
|
||||
axiom H2 : ∀ {x y z : num}, p x y z → p x x x
|
||||
|
|
|
@ -2,7 +2,7 @@ import logic
|
|||
namespace foo
|
||||
variable x : num.num
|
||||
check x
|
||||
using num
|
||||
open num
|
||||
check x
|
||||
set_option pp.full_names true
|
||||
check x
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic struc.function
|
||||
using function num bool
|
||||
open function num bool
|
||||
|
||||
|
||||
variable f : num → bool
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using tactic
|
||||
open tactic
|
||||
|
||||
theorem T {a b c d : Prop} (H : a) (H : b) (H : c) (H : d) : a
|
||||
:= by state; assumption
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using num
|
||||
open num
|
||||
|
||||
section
|
||||
parameter {A : Type}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using num
|
||||
open num
|
||||
|
||||
section
|
||||
parameter {A : Type}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using tactic
|
||||
open tactic
|
||||
variables a b c d : Prop
|
||||
axiom Ha : a
|
||||
axiom Hb : b
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using tactic
|
||||
open tactic
|
||||
|
||||
inductive list (A : Type) : Type :=
|
||||
nil {} : list A,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
-- Basic properties of lists.
|
||||
|
||||
import data.nat
|
||||
using nat eq_ops
|
||||
open nat eq_ops
|
||||
inductive list (T : Type) : Type :=
|
||||
nil {} : list T,
|
||||
cons : T → list T → list T
|
||||
|
|
|
@ -15,10 +15,8 @@ end bla
|
|||
|
||||
variable g : N → N → N
|
||||
|
||||
using foo
|
||||
using bla
|
||||
open foo
|
||||
open bla
|
||||
print raw a + b -- + is overloaded, it creates a choice
|
||||
print raw #foo a + b -- + is not overloaded, we are parsing inside #foo
|
||||
print raw g (#foo a + b) (#bla a + b) -- mixing both
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
definition two1 : nat := 2
|
||||
definition two2 : nat := succ (succ (zero))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import data.nat
|
||||
using nat
|
||||
open nat
|
||||
|
||||
definition two1 : nat := 2
|
||||
definition two2 : nat := succ (succ (zero))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using decidable
|
||||
open decidable
|
||||
|
||||
inductive nat : Type :=
|
||||
zero : nat,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using num eq_ops
|
||||
open num eq_ops
|
||||
|
||||
inductive nat : Type :=
|
||||
zero : nat,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using num eq_ops
|
||||
open num eq_ops
|
||||
|
||||
inductive nat : Type :=
|
||||
zero : nat,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using num eq_ops
|
||||
open num eq_ops
|
||||
|
||||
inductive nat : Type :=
|
||||
zero : nat,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import logic
|
||||
using num eq_ops
|
||||
open num eq_ops
|
||||
|
||||
inductive nat : Type :=
|
||||
zero : nat,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue