Flexary Operators for Formalized Mathematics Fulya Horozal Florian Rabe Michael Kohlhase Jacobs University, Bremen, Germany Mathematical Knowledge Management Conferences on Intelligent Computer Mathematics July 07, 2014 Coimbra, Portugal 1
Motivation Flexary Operators ◮ flexary = flexible arity compare unary, binary, etc. ◮ Many operators naturally flexary pervade mathematics ◮ associative operators a 1 + . . . + a n = +( a 1 , . . . , a n ) ◮ collection constructors { a 1 , . . . , a n } = set ( a 1 , . . . , a n ) ◮ vector, matrix, polynomial constructors ◮ Not commonly supported in content representation languages surprising 2
Motivation Flexary Binders ◮ Binder = operator that binds some variables in a scope ◮ Arity = number of bound variables ◮ Flexary binders very common actually, hard to find a fixed-arity binder ◮ Define: binder B is associative if Bx , y . E = Bx . By . E ◮ Most binders not only flexary but also associative ◮ associative: ∀ , ∃ � ◮ associative up to currying: , λ ◮ not associative (but still naturally flexary): ∃ 1 ◮ Support for flexary binders equally desirable 3
Motivation Standard Solution (1) Use (some incarnation of) lists a 1 + . . . + a n = +( list ( a 1 , . . . , a n )) But ◮ awkward even more so for a mathematician ◮ introduces foundational dependency what if there are no lists in my language? 4
Motivation Standard Solution (2) Use notations ◮ only fixed arity in content ◮ parser and printer adapted to mimic flexible arity a 1 + . . . + a n parsed as +( a 1 , . . . , +( a n − 1 , a n ) . . . ) But ◮ flexary representation often more natural ◮ requires choice between right- and left-associative notations no-canonical choice for non-associative flexary operators ◮ requires domain=codomain cannot make the { . . . } operator right-associative ◮ no flexary reasoning would be nice to quantify over the number of arguments 5
Motivation Ellipses ◮ Flexary operators naturally lead to ellipses ◮ Sequential ellipsis [ a i ] n define as a 1 , . . . , a n i =1 example: +[ a i ] n i =1 = +( a 1 , . . . , a n ) ◮ No standardized formalization dot-dot-dot notation fine on paper 6
Motivation Ellipses ◮ Flexary operators naturally lead to ellipses ◮ Sequential ellipsis [ a i ] n define as a 1 , . . . , a n i =1 example: +[ a i ] n i =1 = +( a 1 , . . . , a n ) ◮ No standardized formalization dot-dot-dot notation fine on paper ◮ Nested ellipsis f 1 ( . . . f n ( x ) . . . ) special case of sequential ellipsis via flexary function composition: f 1 ( . . . f n ( x ) . . . ) = ◦ [ f i ] n i =1 ( x ) 6
Motivation Where to Formalize Flexible Arities? ◮ Theory level: not good ◮ amounts to creating a theory of lists ◮ must be imported into any theory with flexary operators e.g., monoids ◮ Logic level: better but ◮ logics becomes more complicated ◮ flexible arities logic-independent feature ◮ Logical framework level our approach ◮ once-and-for-all formalization ◮ corresponds to mathematical practice flexible arity and ellipses are assumed at the meta-level 7
Motivation Overview 1. Define logical framework LFS extends Edinburgh Logical Framework (LF) with ◮ sequences ◮ ellipses ◮ flexible arities 2. Use LFS to define flexary logics ◮ flexary connectives ◮ flexary quantifiers ◮ with corresponding flexary inference rules concretely: flexary FOL, flexary λ -calculus 3. Use flexary logics to formalize mathematical examples 8
A Flexary Logical Framework LF with Sequences (LFS) ◮ LF = dependently-typed λ -calculus ◮ LF primitives ◮ terms, types, and kinds ◮ Π-types, λ , and application ◮ typing judgment ⊢ E : E ′ ◮ Very simple, but just right as logical framework ◮ New primitives in LFS ◮ term, type, and kind sequences ◮ natural numbers needed for indices in ellispes ◮ sequence ellipsis [ E ( i )] n i =1 ◮ flexary function composition needed for nested ellipses 9
A Flexary Logical Framework LFS Syntax LF Grammar ::= type | Π x : E . E | λ x : E . E | E E E olive 10
A Flexary Logical Framework LFS Syntax LFS Grammar type n | Π x : E . E | λ x : E . E | E E E , n ::= · | E , E | E n ◮ Empty sequence · ◮ Concatenation E , E ′ ◮ Index E n n -th element of E olive 10
A Flexary Logical Framework LFS Syntax LFS Grammar type n | Π x : E . E | λ x : E . E | E E E , n ::= · | E , E | E n | [ E ] n x =1 | ◦ E ◮ Empty sequence · ◮ Concatenation E , E ′ ◮ Index E n n -th element of E ◮ Sequence ellipses [ E ( x )] n reduces to E (1) , . . . , E ( n ) x =1 ◮ Flexary function composition ◦ f ◦ ( f 1 , . . . , f n ) s reduces to f 1 ( . . . ( f n s ) . . . ) olive 10
A Flexary Logical Framework Flexary Interpretation of LF Primitives ◮ LF primitives retained but now flexary ◮ Flexary application = sequence arguments f ( E , E ′ ) = ( f E ) E ′ f · = f ◮ Flexary binding = sequence variables λ x : · . E = E [ x / · ] λ x 1 : E . λ x 2 : E ′ . F [ x / ( x 1 , x 2 )] λ x : ( E , E ′ ) . F = accordingly for Π ◮ LF typing rules can be reused without change 11
A Flexary Logical Framework Type System: Natural Numbers Axiomatized as LF declarations : nat type ≤ : nat → nat → type 0 : nat 1 : nat + : nat → nat → nat with appropriate axioms 12
A Flexary Logical Framework Type System: Introduction of Sequences Kind sequences Σ ⊢ n : nat : type Σ ⊢ type n Kind Type sequences Σ ⊢ U : type m Σ ⊢ V : type n ⊢ Σ Sig Σ ⊢ · : type 0 Σ ⊢ U , V : type m + n Term sequences Σ ⊢ S : U : type m Σ ⊢ T : V : type n ⊢ Σ Sig Σ ⊢ · : · : type 0 Σ ⊢ S , T : U , V : type m + n 13
A Flexary Logical Framework Type System: Elimination of Sequences Term sequences Σ ⊢ x ∗ : 1 ≤ x : type Σ ⊢ S : U : type n Σ ⊢ x ∗ : x ≤ n : type Σ ⊢ S x : U x : type accordingly for type sequences Static bound checking: ◮ Only valid indices within bounds well-typed ◮ 2 implicit arguments for 1 ≤ x and x ≤ n 14
A Flexary Logical Framework Type System: Ellipses Ellipsis for sequence of terms Σ , x : nat , x ∗ :1 ≤ x , x ∗ : x ≤ n ⊢ S : U : type Σ ⊢ n : nat : type Σ ⊢ [ S ] n x =1 : [ U ] n x =1 : type n accordingly for sequence of types Static bound checking: ◮ Actually binds 3 variables ◮ Bounds 1 ≤ x and x ≤ n passed as assumptions 15
A Flexary Logical Framework Flexary Function Composition Σ ⊢ U : type n +1 Σ ⊢ F : [ U i +1 → U i ] n i =1 Σ ⊢ ◦ F : U n +1 → U 1 Example: Folding If S : A , . . . , A : type n and f : A → A → A and a : A then i : nat ⊢ λ x : A . f x S i : A → A and we define foldl S f a = ( ◦ [ λ x : A . f x S i ] n i =1 ) a (here U i = A for 1 ≤ i ≤ n + 1) 16
Flexary Logics Flexary Connectives LFS type form : type of FOL formulas Notation: Write form n for [ form ] n i =1 Binary conjunction ∧ : form → form → form Flexary conjunction ∧ ∗ : Π n : nat . form n → form λ n : nat . λ F : form n . foldl F ∧ true = Thus, ∧ ∗ n F 1 , . . . , F n = ( . . . ( true ∧ F 1 ) . . . ) ∧ F n ∧ ∗ 0 · = true ◮ Flexary proof rules also definable in terms of rules for binary conjunction ◮ Other flexary connectives defined accordingly 17
Flexary Logics Flexary Quantifiers LFS type term : type of FOL terms Unary universal quantifier ∀ : ( term → form ) → form Flexary universal quantifier ∀ ∗ : Π n : nat . ( term n → form ) → form = λ n : nat . λ F : term n → form . ◦ [ λ f : term i → form . λ y : term i − 1 . ∀ λ x : term . f ( y , x ) ] n i =1 F � �� � ( term i → form ) → ( term i − 1 → form ) ◮ Flexary proof rules definable accordingly ◮ Other flexary quantifiers definable accordingly 18
Flexary Mathematics Powers ◮ Signature of monoids in FOL a : type • : a → a → a e : a ◮ Power operator routinely used in informal mathematics often introduced in same paragraph but not definable in FOL ◮ Now: flexary monoid operator definable in flexary FOL • ∗ : Π n : nat . a n → a = λ n . λ x : a n . foldl • x e and thus power operator definable power : a → nat → a = λ x . λ n . • ∗ x n 19
Flexary Mathematics Multirelations ◮ Multi-relations routinely used in informal mathematics e.g., a ∈ b ⊆ c ◮ But cannot be defined as single operators within a fixary logic ◮ In flexary FOL: multirel : Π n : nat . term n +1 → ( term → term → form ) n → form = λ n .λ x . λ r . ∧ ∗ [ r i x i x i +1 ] n i =1 ◮ Example: a ∈ b ⊆ c = multirel ( a , b , c ) ( ∈ , ⊆ ) 20
Conclusion ◮ Sequences and ellipses meta-level operators of informal mathematics ◮ But a challenge for formalized mathematics ◮ Logical framework approach permits clean solution ◮ LFS = LF with sequences and ellipses ◮ flexary logics defined in LFS ◮ natural formalizations in flexary logics ◮ Key properties ◮ flexary operators take natural number argument arity polymorphism ◮ LFS retains semantics of LF primitives no new type constructors, no change to typing rules ◮ length of sequences known to type system static bounds check 21
Recommend
More recommend