representing isabelle in lf
play

Representing Isabelle in LF Florian Rabe Jacobs University Bremen - PowerPoint PPT Presentation

Representing Isabelle in LF Florian Rabe Jacobs University Bremen 1 Slogans Type classes are wrong: Type classes should be theories, instances should be morphisms. The Isabelle module system is too complicated: You do not need


  1. Representing Isabelle in LF Florian Rabe Jacobs University Bremen 1

  2. Slogans ◮ Type classes are wrong: Type classes should be theories, instances should be morphisms. ◮ The Isabelle module system is too complicated: You do not need theories, locales, and type classes. ◮ The LF module system is good: ◮ LF = judgments as types, proofs as terms ◮ LF module system = inference systems as signatures, relations as morphisms ◮ simple, elegant, expressive 2

  3. Background ◮ Long term goal: ◮ comprehensive framework to represent, integrate, translate, reason about logics ◮ apply to all commonly used logics, generate large content base digital library of logics ◮ cover model and proof theory ◮ provide tool support: validation, browsing, editing, storage, ... ◮ State: ◮ successful progress based on modular Twelf twelf-mod branch of Twelf ◮ fast-growing library https://trac.omdoc.org/LATIN/ ◮ besides logics: set theory, λ -cube, Mizar, Isabelle /HOL, . . . 3

  4. Overview ◮ Designed representation of Isabelle in LF an outsider’s account of Isabelle ◮ includes type classes, locales, theories, excludes Isar ◮ yields concise formal definition of Isabelle ◮ complements Isabelle documentation ◮ Next steps require inside support ◮ better statement and proof of adequacy ◮ implementation 4

  5. Isabelle theory T imports T ∗ begin thycont end theory ::= ::= ( locale | sublocale | interpretation | thycont class | instantiation | thysymbol ) ∗ | locale L = ( i : instance ) ∗ for locsymbol ∗ + locsymbol ∗ ::= locale sublocale L < instance proof ∗ sublocale ::= interpretation instance proof ∗ interpretation ::= L where namedinst ∗ instance ::= class C = C ∗ + locsymbol ∗ class ::= instantiation type :: ( C ∗ ) C begin locsymbol ∗ proof ∗ end instantiation ::= ::= consts con | defs def | axioms ax | lemma lem thysymbol | typedecl typedecl | types types ::= fixes con | defines def | assumes ax | lemma lem locysymbol con ::= c :: type a : c x ∗ ≡ term ::= def ax ::= a : form ::= a : form proof lem ( α ∗ ) t name typedecl ::= ( α ∗ ) t = type types ::= namedinst ::= c = term α :: C | ( type ∗ ) t | type ⇒ type | prop ::= type x | c | term term | λ ( x :: type ) ∗ . term term ::= ⇒ form | � ( x :: type ) ∗ . form | term ≡ term ::= form = form proof ::= a primitive Pure inference as described in the manual 5

  6. Representing the Primitives sig Pure = { tp : type . ⇒ : tp → tp → tp . infix right 0 ⇒ . tm : tp → type . prefix 0 tm . λ : ( tm A → tm B ) → tm ( A ⇒ B ). @ : tm ( A ⇒ B ) → tm A → tm B . infix left 1000 @. : tp . prop � : ( tm A → tm prop ) → tm prop . = ⇒ : tm prop → tm prop → tm prop . infix right 1 = ⇒ . ≡ : tm A → tm A → tm prop . infix none 2 ≡ . ⊢ : tm prop → type . prefix 0 ⊢ . � I : ( x : tm A ⊢ ( B x )) → ⊢ � ([ x ] B x ). � E : ⊢ � ([ x ] B x ) → { x : tm A } ⊢ ( B x ). = ⇒ I : ( ⊢ A → ⊢ B ) → ⊢ A = ⇒ B . = ⇒ E : ⊢ A = ⇒ B → ⊢ A → ⊢ B . refl : ⊢ X ≡ X . subs : { F : tm A → tm B } ⊢ X ≡ Y → ⊢ F X ≡ F Y . exten : { x : tm A } ⊢ ( F x ) ≡ ( G x ) → ⊢ λ F ≡ λ G . beta : ⊢ ( λ [ x : tm A ] F x ) @ X ≡ F X . eta : ⊢ λ ([ x : tm A ] F @ x ) ≡ F . sig Type = { this : tp . } . } . 6

  7. Representing Simple Expressions Expression Isabelle LF type operator ( α 1 , . . . , α n ) t t : tp → . . . → tp → tp type variable α : tp α constant c :: τ c : tm � τ � variable x :: τ x : tm � τ � assumption/axiom a : ϕ a : ⊢ � ϕ � lemma/theorem a : ϕ P a : ⊢ � ϕ � = � P � Polymorphism: τ , ϕ , P may contain type variables α 1 , . . . , α n Represented as LF binding, e.g., a : { α 1 : tp } . . . { α n : tp } ⊢ � ϕ � = [ α 1 : tp ] . . . [ α n : tp ] � P � 7

  8. Isabelle theory T imports T ∗ begin thycont end ::= theory thycont ::= ( locale | sublocale | interpretation | class | instantiation | thysymbol ) ∗ | locale L = ( i : instance ) ∗ for locsymbol ∗ + locsymbol ∗ locale ::= sublocale L < instance proof ∗ sublocale ::= interpretation instance proof ∗ interpretation ::= L where namedinst ∗ instance ::= class C = C ∗ + locsymbol ∗ class ::= instantiation type :: ( C ∗ ) C begin locsymbol ∗ proof ∗ end instantiation ::= thysymbol ::= consts con | axioms ax | lemma lem | typedecl typedecl ::= fixes con | assumes ax | lemma lem locysymbol con ::= c :: type ::= a : form ax lem ::= a : form proof ( α ∗ ) t name typedecl ::= namedinst ::= c = term 8

  9. Isabelle theory T imports T ∗ begin thycont end ::= theory thycont ::= ( locale | sublocale | interpretation | class | instantiation | thysymbol ) ∗ | locale L = ( i : instance ) ∗ for locsymbol ∗ + locsymbol ∗ locale ::= sublocale L < instance proof ∗ sublocale ::= interpretation instance proof ∗ interpretation ::= L where namedinst ∗ instance ::= class C = C ∗ + locsymbol ∗ class ::= instantiation type :: ( C ∗ ) C begin locsymbol ∗ proof ∗ end instantiation ::= thysymbol ::= consts con | axioms ax | lemma lem | typedecl typedecl ::= fixes con | assumes ax | lemma lem locysymbol con ::= c :: type ::= a : form ax lem ::= a : form proof ( α ∗ ) t name typedecl ::= namedinst ::= c = term 3 scoping constructs 9

  10. Isabelle theory T imports T ∗ begin thycont end ::= theory thycont ::= ( locale | sublocale | interpretation | class | instantiation | thysymbol ) ∗ | locale L = ( i : instance ) ∗ for locsymbol ∗ + locsymbol ∗ locale ::= sublocale L < instance proof ∗ sublocale ::= interpretation instance proof ∗ interpretation ::= L where namedinst ∗ instance ::= class C = C ∗ + locsymbol ∗ class ::= instantiation type :: ( C ∗ ) C begin locsymbol ∗ proof ∗ end instantiation ::= thysymbol ::= consts con | axioms ax | lemma lem | typedecl typedecl ::= fixes con | assumes ax | lemma lem locysymbol con ::= c :: type ::= a : form ax lem ::= a : form proof ( α ∗ ) t name typedecl ::= namedinst ::= c = term 3 scoping constructs with one import declaration each 10

  11. Isabelle theory T imports T ∗ begin thycont end ::= theory thycont ::= ( locale | sublocale | interpretation | class | instantiation | thysymbol ) ∗ | locale L = ( i : instance ) ∗ for locsymbol ∗ + locsymbol ∗ locale ::= sublocale L < instance proof ∗ sublocale ::= interpretation instance proof ∗ interpretation ::= L where namedinst ∗ instance ::= class C = C ∗ + locsymbol ∗ class ::= instantiation type :: ( C ∗ ) C begin locsymbol ∗ proof ∗ end instantiation ::= thysymbol ::= consts con | axioms ax | lemma lem | typedecl typedecl ::= fixes con | assumes ax | lemma lem locysymbol con ::= c :: type ::= a : form ax lem ::= a : form proof ( α ∗ ) t name typedecl ::= namedinst ::= c = term 3 scoping constructs with one import declaration each 3 constructs to relate scopes 11

  12. LF Signatures Σ ::= · | Σ , sig T = { Σ } | Σ , view v : S → T = µ | Σ , include S | Σ , struct s : S = { σ } | Σ , c : A | Σ , a : K Morphisms σ ::= · | σ, struct s := µ | σ, c := t | σ, a := A µ ::= { σ } | v | incl | s | id | µ µ Kinds K ::= type | { x : A } K Type families A ::= a | [ x : A ] A | A t | { x : A } A Terms t ::= c | x | [ x : A ] t | t t ◮ Signatures scope declarations: signatures, morphisms, constants, type families ◮ Morphisms relate signatures: ◮ view : explicit morphism ◮ include : inclusion into current signature ◮ struct : named import into current signature 12

  13. Morphisms ◮ A morphisms relates two signatures ◮ Morphism from S to T ◮ maps S constants to T -terms ◮ maps S type family symbols to T -type families ◮ extends homomorphically to all S -expressions ◮ preserves typing, kinding, definitional equality ◮ view v : S → T = { σ } : maps given explicitly by σ ◮ include S : inclusion from S into current signature ◮ struct s : S = { σ } : named import from S into current signature, maps c to s . c 13

  14. Representing Theories Isabelle: theory T imports T 1 , . . . , T n begin Σ end LF representation: sig T = { include Pure , include T 1 , . . . , include T n , � Σ � } . 14

  15. Representing Modular Declarations Scopes as signatures, relations as morphisms Isabelle LF theory signature locale signature type class signature theory import morphism (inclusion) locale import from L morphism (structure from S ) type class import from C morphism (structure from C ) sublocale L ′ of L morphism (view from L to L ′ ) interpretation of L in T morphism (view from L to T ) instance of type class C morphism out of C type class functor morphism (view) type class functor application morphism composition 15

  16. Type Classes Isabelle: types universal for each declaration class semlat = leq :: α ⇒ α ⇒ prop inf :: β ⇒ β ⇒ β � x : γ � y : γ. leq ( inf x y ) x ax : LF representation: types existential for all declarations sig semlat = { : this tp : tm ( this ⇒ this ⇒ prop ) leq : tm ( this ⇒ this ⇒ this ) inf � � [ x : this ] � [ y : this ] leq ( inf x y ) x � : ⊢ ax } 16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend