-
Notifications
You must be signed in to change notification settings - Fork 0
Formalization of Succinctness #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
83 commits
Select commit
Hold shift + click to select a range
1f2d641
Initial syntactic expressiveness experiments
ibbem e7e9afc
Factor out the syntactic expressiveness definitions
ibbem a1215d8
Proof the expressiveness theorem for CCC instead of 2CC
ibbem bee9518
Require ≤Size for <Size
ibbem 2286120
Prove that =Size, ≤Size and <Size behave as expected
ibbem 751b52c
Rename temporary files to have proper names
ibbem a0658c5
Move the size definitions into a separate file
ibbem c6a9a0e
Prove 2CC ≤ ADT to conclude 2CC < ADT
ibbem 49f0193
Prove that L₁ ≤Size L₂ and L₂ ≱Size L₁ cannot both be true
ibbem 74ddc2d
Use more representative variable names
ibbem ae3a768
Use shorter and more explicit notation for proofs
ibbem 46d6503
Prove CCC ≤ NCC
ibbem d1c80b2
Prove 2CC < CCC
ibbem 13bb256
Quantify ≤Size over the artifact type
ibbem 284df1e
Remove unused imports
ibbem 1caa068
Cleanup the 2CC<ADT file
ibbem 762fe1a
Make language arguments implicit
ibbem 2b63e25
Prove 2CC=2CC, NCC=2CC (for N=2) and conclude 2CC=CCC
ibbem 4ef38a3
Prove FST ≱ 2CC
ibbem 4d9da19
Investigate the relationship between ≤Size and compilers
ibbem 3d99014
Prove our FST formalization misses a base feature
ibbem edc4000
Use more specialized versions of ∷-injective
ibbem 0bbea43
Prove OC ≱ 2CC
ibbem 4789f75
Use the artifact example definitions where possible
ibbem 26efb57
Redefine 𝔸 as a record
ibbem a70486c
Implement atom sizes
ibbem e5d7ed4
Take advantage of artifact sizes
ibbem 546d663
Rename `e₁` to `fst` and `e₂` to `2cc`
ibbem 944d137
Factor out 2CC.reflectsVariantSize
ibbem 71fd187
Reuse List.replicate in OC≱2CC
ibbem 7dbfc95
Make OC≱2CC easier to read
ibbem 30ae516
Write 2CC instead of 2CC.2CC in FST≱2CC
ibbem 85b1ae6
Inline big-artifact in FST≱2CC
ibbem ae7f6ab
Use the same approach as OC≱2CC in FST≱2CC
ibbem 8194f01
Apply η-conversion in FST≱2CC
ibbem 875fc41
Simplify FST evaluation in FST≱2CC
ibbem 865509d
FST≱2CC: Only define variants that are needed
ibbem 15aeaee
Make FST≱2CC more readable
ibbem f93af41
FST≱2CC: Simplify `select-applyUpTo-feature`
ibbem c705abd
Factor out findings about fixed artifact lengths of 2CC
ibbem cc33f09
Move size>0 lemmas next to the size definitions
ibbem 9e5b32f
Factor out the inflation constant in OC≱2CC
ibbem a8e15fb
Rename some things
ibbem 762ca77
Create size definitions using reflection
ibbem 90fe544
Create a dead option elimination transformation
ibbem e2db0cf
Rename SyntacticExpressiveness to Succinctness
ibbem e69781f
Refactor the succinctness module structure
ibbem 290d6e6
Add the designed definition
ibbem 5860509
Inline size comparison
ibbem f8db551
Use `SizedLang` in the designed succinctness relation
ibbem 96f0427
Split the relation definitions into separate files
ibbem 8683001
Use the new succinctness definition
ibbem 9ac51ba
Proof that there exists a diagonalization of ℕ
ibbem 4916fbf
Prove that ≤ and ≰ are opposites
ibbem ffb965c
Prove ≤ₛ-weakening
ibbem 5368a8a
Prove more general succinctness transitivity properties
ibbem bdce75f
Add missing size definitions
ibbem e16ef09
Define an OC with a propositional selection language
ibbem c31b2f9
Prove that OC is a subset of PropOC
ibbem 69a2e6f
Prove that PropOC is at least as succinct as OC
ibbem b3c4d3b
Remove annoying module prefixes in 2CC<ADT
ibbem 9297133
Generalize the coarseness of 2CC < ADT
ibbem 5e053cd
Add some more transitivity theorems
ibbem a11219c
Replace ≱ in names with ≰
ibbem 0ac88f7
Generalize the dimension of 2CC ≰ₛ FST
ibbem 4e175e1
Generalize the dimension of 2CC ≰ₛ OC
ibbem b47e7ab
Generalize the dimension of 2CC <ₛ ADT
ibbem 3b113bb
Prove VariantList ≤ₛ ADT
ibbem d38fafb
Prove NADT ≤ₛ VariantList
ibbem 4a07f0d
Prove ADT ≤ₛ NADT
ibbem 1cab421
Prove NADT ≤ₛ ADT
ibbem 3385ba9
Simplify the FixedArtifactLength lemma
ibbem ff6e993
Generalize the coarseness of the relationship between ≰ and ≤
ibbem 0d29667
Prove independence of size definition
ibbem 348054e
Remove a superfluous `--allow-unsolved-metas`
ibbem 81ddeb2
Rename some variables and lemmas in 2CC<ADT
ibbem 4acbaf3
Move OC dead elimination to `Translation`
ibbem d0585cb
Use typical option names for OC dead elimination
ibbem 3b90f96
Add some useful documentation
ibbem c5ce2f8
Rename NoBaseArtifacts into NoCoreFeature
ibbem 5aec4ca
Merge branch 'develop' into thesis_bm
ibbem b0902d2
Remove a lemma that is available in the standard library
ibbem f536bb1
Add my thesis to the README
ibbem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| open import Vatras.Framework.Definitions using (𝔽) | ||
| module Vatras.Lang.2CC.Encode {Dimension : 𝔽} where | ||
|
|
||
| open import Data.List as List using (List; []; _∷_) | ||
|
|
||
| open import Size using (∞) | ||
| open import Data.Bool using (false) | ||
| open import Data.Unit using (⊤; tt) | ||
| open import Data.List.Properties using (map-∘; map-id; map-cong) | ||
| open import Relation.Binary.PropositionalEquality as Eq using (_≡_; refl) | ||
|
|
||
| open import Vatras.Data.EqIndexedSet using (_≅[_][_]_; irrelevant-index-≅) | ||
| open import Vatras.Framework.Variants as V using (Rose; Variant-is-VL; VariantEncoder) | ||
| open import Vatras.Framework.Relation.Function using (_⇔_; to; from) | ||
| open import Vatras.Framework.VariabilityLanguage using (Semantics; Config) | ||
| open import Vatras.Lang.2CC Dimension | ||
|
|
||
| encode : ∀ {i} {A} → Rose i A → 2CC ∞ A | ||
| encode (a V.-< cs >-) = a -< List.map encode cs >- | ||
|
|
||
| confs : ⊤ ⇔ Config 2CCL | ||
| confs = record | ||
| { to = λ where tt _ → false | ||
| ; from = λ _ → tt | ||
| } | ||
|
|
||
| 2cc-encode-idemp : ∀ {A} (v : Rose ∞ A) → (c : Configuration) → ⟦ encode v ⟧ c ≡ v | ||
| 2cc-encode-idemp {A} v@(a V.-< cs >-) c = | ||
| begin | ||
| ⟦ encode v ⟧ c | ||
| ≡⟨⟩ | ||
| a V.-< List.map (λ x → ⟦ x ⟧ c) (List.map encode cs) >- | ||
| ≡⟨ Eq.cong (a V.-<_>-) (map-∘ cs) ⟨ | ||
| a V.-< List.map (λ x → ⟦ encode x ⟧ c) cs >- | ||
| ≡⟨ Eq.cong (a V.-<_>-) (go cs) ⟩ | ||
| v | ||
| ∎ | ||
| where | ||
| open Eq.≡-Reasoning | ||
|
|
||
| go : (cs' : List (Rose ∞ A)) → List.map (λ c' → ⟦ encode c' ⟧ c) cs' ≡ cs' | ||
| go [] = refl | ||
| go (c' ∷ cs') = Eq.cong₂ _∷_ (2cc-encode-idemp c' c) (go cs') | ||
|
|
||
| preserves : ∀ {A} → (v : Rose ∞ A) | ||
| → Semantics (Variant-is-VL (Rose ∞)) v ≅[ to confs ][ from confs ] ⟦ encode v ⟧ | ||
| preserves {A} v = irrelevant-index-≅ v | ||
| (λ { tt → refl }) | ||
| (2cc-encode-idemp v) | ||
| (to confs) | ||
| (from confs) | ||
|
|
||
| encoder : VariantEncoder (Rose ∞) 2CCL | ||
| encoder = record | ||
| { compile = encode | ||
| ; config-compiler = λ _ → confs | ||
| ; preserves = preserves | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| {-| | ||
| This module shows that artifacts of choice calculus expressions have a fixed number of children. | ||
| Afterwards, we introduce some more usable lemmas on top og this insight. | ||
| -} | ||
| open import Vatras.Framework.Definitions using (𝔽; 𝔸; atoms) | ||
| module Vatras.Lang.2CC.FixedArtifactLength (Dimension : 𝔽) (A : 𝔸) where | ||
|
|
||
| open import Data.Bool using (true; false) | ||
| open import Data.Empty using (⊥-elim) | ||
| open import Data.List as List using (List; []; _∷_; _++_) | ||
| import Data.List.Properties as List | ||
| open import Data.List.Relation.Ternary.Interleaving.Propositional using (Interleaving; []; consˡ; consʳ) | ||
| open import Data.List.Relation.Unary.All as All using (All; []; _∷_) | ||
| import Data.List.Relation.Unary.All.Properties | ||
| open import Data.List.Relation.Unary.AllPairs as AllPairs using (AllPairs; []; _∷_) | ||
| open import Data.Nat as ℕ using (ℕ; suc; _+_; _∸_; _*_; _≤_; z≤n; s≤s; _≥_) | ||
| import Data.Nat.Properties as ℕ | ||
| open import Data.Product using (_×_; _,_; proj₂; ∃-syntax) | ||
| open import Function using (_∘_; const) | ||
| open import Relation.Binary.PropositionalEquality as Eq using (refl; _≡_; _≢_) | ||
| open import Size using (Size; ∞) | ||
|
|
||
| import Vatras.Util.List as List | ||
| open import Vatras.Data.EqIndexedSet using (_∈_; _⊆_) | ||
| open import Vatras.Framework.Variants using (Rose; children-equality) | ||
| open import Vatras.Lang.2CC Dimension using (2CC; _⟨_,_⟩; _-<_>-; ⟦_⟧) | ||
| open import Vatras.Lang.2CC.ReflectsVariantSize using (reflectsVariantSize) | ||
| open import Vatras.Succinctness.Sizes using (sizeRose; size2CC) | ||
|
|
||
| _≉_ : Rose ∞ A → Rose ∞ A → Set | ||
| (a₁ Rose.-< cs₁ >-) ≉ (a₂ Rose.-< cs₂ >-) = List.length cs₁ ≢ List.length cs₂ | ||
|
|
||
| {-| | ||
| The key insight of this module: | ||
| Given a choice calculus expression with an artifact at the root, | ||
| all expressed variants must have the same number of children. | ||
| -} | ||
| fixedChildCount : ∀ {i} | ||
| → {a₁ : atoms A} {cs₁ : List (Rose ∞ A)} | ||
| → {a₂ : atoms A} {cs₂ : List (2CC i A)} | ||
| → (a₁ Rose.-< cs₁ >-) ∈ ⟦ a₂ -< cs₂ >- ⟧ | ||
| → List.length cs₁ ≡ List.length cs₂ | ||
| fixedChildCount {cs₁ = cs₁} {cs₂ = cs₂} (c , v≡e) = | ||
| List.length cs₁ | ||
| ≡⟨ Eq.cong List.length (children-equality v≡e) ⟩ | ||
| List.length (List.map (λ e → ⟦ e ⟧ c) cs₂) | ||
| ≡⟨ List.length-map (λ e → ⟦ e ⟧ c) cs₂ ⟩ | ||
| List.length cs₂ | ||
| ∎ | ||
| where | ||
| open Eq.≡-Reasoning | ||
|
|
||
| {-| | ||
| We can partition a list of variants | ||
| on whether we can choose the left or right alternative of a choice | ||
| in order to configure each variant. | ||
| -} | ||
| partition : ∀ {i : Size} | ||
| → (D : Dimension) (c₁ c₂ : 2CC i A) | ||
| → (vs : List (Rose ∞ A)) | ||
| → AllPairs _≉_ vs | ||
| → All (_∈ ⟦ D 2CC.⟨ c₁ , c₂ ⟩ ⟧) vs | ||
| → ∃[ vs₁ ] ∃[ vs₂ ] | ||
| Interleaving vs₁ vs₂ vs | ||
| × All (_∈ ⟦ c₁ ⟧) vs₁ | ||
| × All (_∈ ⟦ c₂ ⟧) vs₂ | ||
| partition D c₁ c₂ [] unique-vs vs⊆e = [] , [] , [] , [] , [] | ||
| partition D c₁ c₂ (v ∷ vs) (v∉vs ∷ unique-vs) ((c , v≡e) ∷ vs⊆e) | ||
| with partition D c₁ c₂ vs unique-vs vs⊆e | ||
| ... | vs₁ , vs₂ , partition , vs₁⊆e , vs₂⊆e | ||
| with c D | ||
| ... | true = v ∷ vs₁ , vs₂ , consˡ partition , (c , v≡e) ∷ vs₁⊆e , vs₂⊆e | ||
| ... | false = vs₁ , v ∷ vs₂ , consʳ partition , vs₁⊆e , (c , v≡e) ∷ vs₂⊆e | ||
|
|
||
| {-| | ||
| Gives a lower bound on the size of a choice calculus expression | ||
| given that it expresses a number of variants with pairwise different child count. | ||
| -} | ||
| sum≤size2CC : ∀ {i : Size} | ||
| → (e : 2CC i A) | ||
| → (vs : List (Rose ∞ A)) | ||
| → AllPairs (_≉_) vs | ||
| → All (_∈ ⟦ e ⟧) vs | ||
| → List.sum (List.map sizeRose vs) ≤ size2CC e | ||
|
pmbittner marked this conversation as resolved.
|
||
| sum≤size2CC (a -< cs >-) [] unique-vs vs⊆e = z≤n | ||
| sum≤size2CC (a -< cs >-) (v ∷ []) unique-vs (v∈e ∷ []) = | ||
| begin | ||
| List.sum (List.map sizeRose (v ∷ [])) | ||
| ≡⟨⟩ | ||
| sizeRose v + 0 | ||
| ≡⟨ ℕ.+-identityʳ (sizeRose v) ⟩ | ||
| sizeRose v | ||
| ≤⟨ reflectsVariantSize v (a -< cs >-) v∈e ⟩ | ||
| size2CC (a -< cs >-) | ||
| ∎ | ||
| where | ||
| open ℕ.≤-Reasoning | ||
| sum≤size2CC (a -< cs >-) ((a₁ Rose.-< cs₁ >-) ∷ (a₂ Rose.-< cs₂ >-) ∷ vs) ((v₁≢v₂ ∷ v₁∉vs) ∷ unique-vs) (v₁∈e ∷ v₂∈e ∷ vs⊆e) = | ||
| ⊥-elim (v₁≢v₂ (Eq.trans (fixedChildCount v₁∈e) (Eq.sym (fixedChildCount v₂∈e)))) | ||
| sum≤size2CC (D ⟨ c₁ , c₂ ⟩) vs unique-vs vs⊆e with partition D c₁ c₂ vs unique-vs vs⊆e | ||
| ... | vs₁ , vs₂ , partition , vs₁⊆c₁ , vs₂⊆c₂ = | ||
| begin | ||
| List.sum (List.map sizeRose vs) | ||
| ≡⟨ List.sum-Interleaving (List.map-Interleaving partition) ⟨ | ||
| List.sum (List.map sizeRose vs₁) + List.sum (List.map sizeRose vs₂) | ||
| ≤⟨ ℕ.+-mono-≤ (sum≤size2CC c₁ vs₁ (List.AllPairs-resp-⊆ (List.Interleaving⇒Sublistˡ partition) unique-vs) vs₁⊆c₁) (sum≤size2CC c₂ vs₂ (List.AllPairs-resp-⊆ (List.Interleaving⇒Sublistʳ partition) unique-vs) vs₂⊆c₂) ⟩ | ||
| size2CC c₁ + size2CC c₂ | ||
| <⟨ ℕ.n<1+n (size2CC c₁ + size2CC c₂) ⟩ | ||
| size2CC (D ⟨ c₁ , c₂ ⟩) | ||
| ∎ | ||
| where | ||
| open ℕ.≤-Reasoning | ||
|
|
||
| {-| | ||
| Gives a lower bound on the size of a choice calculus expression | ||
| given that it expresses a number of variants with pairwise different child count. | ||
| In contrast to `sum≤size2CC`, this lemma is a simplified special case | ||
| which makes use of a lower bound on the variant size. | ||
| -} | ||
| different-children-counts : | ||
| ∀ {i : Size} | ||
| → (n : ℕ) | ||
| → (e : 2CC i A) | ||
| → (vs : List (Rose ∞ A)) | ||
| → All (_∈ ⟦ e ⟧) vs | ||
| → All (λ v → sizeRose v ≥ n) vs | ||
| → AllPairs _≉_ vs | ||
| → size2CC e ≥ List.length vs * n | ||
| different-children-counts n e vs vs⊆e vs≥n unique-vs = | ||
| begin | ||
| List.length vs * n | ||
| ≡⟨ List.sum-replicate (List.length vs) n ⟨ | ||
| List.sum (List.replicate (List.length vs) n) | ||
| ≡⟨ Eq.cong List.sum (List.map-const n vs) ⟨ | ||
| List.sum (List.map (const n) vs) | ||
| ≤⟨ List.sum-map-≤-with∈ vs (λ v v∈vs → All.lookup vs≥n v∈vs) ⟩ | ||
| List.sum (List.map sizeRose vs) | ||
| ≤⟨ sum≤size2CC e vs unique-vs (vs⊆e) ⟩ | ||
| size2CC e | ||
| ∎ | ||
| where | ||
| open ℕ.≤-Reasoning | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.