Skip to content
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

Theory separation #29

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
37a40a5
generate mm0 file for given list of words
MirceaS Apr 7, 2023
e7ad592
simplified the script slightly
MirceaS Apr 7, 2023
a427b6e
generalised more theorems in 23... and developed mm1 generation part …
MirceaS Apr 11, 2023
ec18cd9
changed a variable name
MirceaS Apr 11, 2023
316404a
generalised more letter theorems
MirceaS Apr 11, 2023
4328c40
generalised derivative of different letters
MirceaS Apr 16, 2023
20795ea
generlaised fp_implies_regex_interior
MirceaS Apr 16, 2023
6cc1017
finished generalising all the theorems in the mm0 code
MirceaS Apr 21, 2023
65f8408
integrated theory generation for ab alphabet & fixed tests
MirceaS Apr 21, 2023
6d0d753
removed comment that is no longer accurate
MirceaS Apr 21, 2023
436d2e1
moved theory of words to its own separate directory
MirceaS Apr 21, 2023
ff1d3ae
sorts + NLML WIP
MirceaS May 3, 2023
cf90e1e
made progress on proving the induction principle for lambda calculus
MirceaS May 8, 2023
b6ea8ff
almost fully proved the induction principle
MirceaS May 12, 2023
85372a4
almost finished proof of induction for lambda calculus
MirceaS May 17, 2023
1338869
reworked proof of the induction principle
MirceaS Jul 2, 2023
1b3782b
wip
MirceaS Mar 6, 2024
e508558
cleanup
MirceaS Mar 6, 2024
11188bb
one lemma left
MirceaS Mar 22, 2024
71e41b7
simplify prop proof
MirceaS Mar 22, 2024
6e073b7
rewitre inference rules added
MirceaS Mar 22, 2024
e5cd005
fully proved induction principle
MirceaS Apr 1, 2024
22a72a6
rename induction principle
MirceaS Apr 1, 2024
a58bbc6
refactor
MirceaS Jun 12, 2024
0979921
definition of subst
MirceaS Jun 12, 2024
75b7721
fixed nl core axioms
MirceaS Jun 24, 2024
138a5d3
add statement for subst induction and use support instead of freshness
MirceaS Jun 26, 2024
0876c3f
proved the first chunk of subst_induction
MirceaS Jul 15, 2024
2921270
finished main proof but with some gaps
MirceaS Jul 15, 2024
b0ea5c7
almost finished proof
MirceaS Jul 16, 2024
baa8142
simplified all induction principle lemmas
MirceaS Jul 19, 2024
1f0a304
finished bulk of ev proof
MirceaS Aug 6, 2024
b386a67
finished EV proof
MirceaS Aug 9, 2024
5ebf6d3
finished reproving the vars case
MirceaS Sep 2, 2024
cf142e6
finished proof
MirceaS Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/.build
/words/.build
/words/.mypy_cache
/words/.pytest_cache

# Hypothesis example database. Could we move this to a new directory?
/.hypothesis
words/.hypothesis
1 change: 1 addition & 0 deletions 00-matching-logic.mm0
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ notation ctxApp {box: SVar} (ctx: Pattern box) (psi: Pattern): Pattern =
($app[$:41) psi ($/$:0) box ($]$:0) ctx;

-- Definitions of common logical connectives
infixl app: $@@$ prec 24;
infixr imp: $->$ prec 24;
def not (phi: Pattern): Pattern = $ phi -> bot $;
prefix not: $~$ prec 41;
Expand Down
668 changes: 351 additions & 317 deletions 01-propositional.mm1

Large diffs are not rendered by default.

56 changes: 44 additions & 12 deletions 02-ml-normalization.mm1
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ theorem eFresh_not {x: EVar} (phi: Pattern x)
$ _eFresh x (~ phi) $ =
'(eFresh_imp h eFresh_disjoint);

theorem eFresh_forall_same_var {x: EVar} (phi: Pattern x):
$ _eFresh x (forall x phi) $ =
'(eFresh_not eFresh_exists_same_var);

theorem sFresh_not {X: SVar} (phi: Pattern X)
(h: $ _sFresh X phi $):
$ _sFresh X (~ phi) $ =
Expand Down Expand Up @@ -97,6 +101,11 @@ theorem norm_and_r (phi psi psi2: Pattern)
$ Norm (phi /\ psi) (phi /\ psi2) $ =
'(norm_and norm_refl h);

theorem norm_forall {x: EVar} (phi psi: Pattern x)
(h: $ Norm phi psi $):
$ Norm (forall x phi) (forall x psi) $ =
'(norm_not @ norm_exists @ norm_not h);

theorem eFresh_and {x: EVar} (phi1 phi2: Pattern x)
(h1: $ _eFresh x phi1 $)
(h2: $ _eFresh x phi2 $):
Expand Down Expand Up @@ -173,19 +182,36 @@ theorem exists_framing {x: EVar} (phi1 phi2: Pattern x)
$ (exists x phi1) -> exists x phi2 $ =
'(exists_generalization eFresh_exists_same_var @ syl exists_intro_same_var h);

theorem or_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x):
theorem forall_framing {x: EVar} (phi1 phi2: Pattern x)
(h: $ phi1 -> phi2 $):
$ (forall x phi1) -> forall x phi2 $ =
'(con3 @ exists_framing @ con3 h);

theorem disjoint_forall: $ phi -> forall x phi $ = '(con2 @ exists_generalization_disjoint id);

theorem or_exists_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $):
$ (phi1 \/ exists x phi2) <-> exists x (phi1 \/ phi2) $ =
'(ibii
(eori
(syl exists_intro_same_var orl)
(exists_generalization eFresh_exists_same_var @ syl exists_intro_same_var orr))
(exists_generalization (eFresh_or eFresh_disjoint eFresh_exists_same_var) @ eori orl @ orrd exists_intro_same_var));
(exists_generalization (eFresh_or freshness_phi1 eFresh_exists_same_var) @ eori orl @ orrd exists_intro_same_var));

theorem imp_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x):
theorem or_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x):
$ (phi1 \/ exists x phi2) <-> exists x (phi1 \/ phi2) $ =
'(or_exists_fresh eFresh_disjoint);

theorem exists_irrelevance: $ (exists x phi) -> phi $ = '(exists_generalization_disjoint id);

theorem imp_exists_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $):
$ (phi1 -> exists x phi2) <-> exists x (phi1 -> phi2) $ =
'(ibii
(rsyl (imim1 dne) @ rsyl (anl or_exists_disjoint) @ exists_framing @ imim1 notnot1)
(rsyl (exists_framing @ imim1 dne) @ rsyl (anr or_exists_disjoint) @ imim1 notnot1));
(rsyl (imim1 dne) @ rsyl (anl @ or_exists_fresh @ eFresh_not freshness_phi1) @ exists_framing @ imim1 notnot1)
(rsyl (exists_framing @ imim1 dne) @ rsyl (anr @ or_exists_fresh @ eFresh_not freshness_phi1) @ imim1 notnot1));

theorem imp_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x):
$ (phi1 -> exists x phi2) <-> exists x (phi1 -> phi2) $ =
'(imp_exists_fresh eFresh_disjoint);

theorem and_exists {x: EVar} (phi1 phi2: Pattern x):
$ (exists x (phi1 /\ phi2)) -> ((exists x phi1) /\ (exists x phi2)) $ =
Expand All @@ -202,14 +228,23 @@ theorem or_exists_bi {x: EVar} (phi1 phi2: Pattern x):
$ (exists x (phi1 \/ phi2)) <-> ((exists x phi1) \/ (exists x phi2)) $ =
'(ibii or_exists_forwards or_exists_reverse);

theorem and_exists_disjoint_forwards {x: EVar} (phi1: Pattern) (phi2: Pattern x):
theorem and_exists_fresh_forwards {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $):
$ (exists x (phi1 /\ phi2)) -> (phi1 /\ exists x phi2) $ =
'(iand
(rsyl (exists_framing anl) (exists_generalization_disjoint id))
(rsyl (exists_framing anl) (exists_generalization freshness_phi1 id))
(exists_framing anr));
theorem and_exists_disjoint_forwards {x: EVar} (phi1: Pattern) (phi2: Pattern x):
$ (exists x (phi1 /\ phi2)) -> (phi1 /\ exists x phi2) $ =
'(and_exists_fresh_forwards eFresh_disjoint);
theorem and_exists_fresh_reverse {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $):
$ (phi1 /\ exists x phi2) -> (exists x (phi1 /\ phi2)) $ =
'(impcom @ syl (anr @ imp_exists_fresh freshness_phi1) (exists_framing ian2));
theorem and_exists_disjoint_reverse {x: EVar} (phi1: Pattern) (phi2: Pattern x):
$ (phi1 /\ exists x phi2) -> (exists x (phi1 /\ phi2)) $ =
'(impcom @ syl (anr imp_exists_disjoint) (exists_framing ian2));
'(and_exists_fresh_reverse eFresh_disjoint);
theorem and_exists_fresh {x: EVar} (phi1 phi2: Pattern x) (freshness_phi1: $ _eFresh x phi1 $):
$ (exists x (phi1 /\ phi2)) <-> (phi1 /\ exists x phi2) $ =
'(ibii (and_exists_fresh_forwards freshness_phi1) (and_exists_fresh_reverse freshness_phi1));
theorem and_exists_disjoint {x: EVar} (phi1: Pattern) (phi2: Pattern x):
$ (exists x (phi1 /\ phi2)) <-> (phi1 /\ exists x phi2) $ =
'(ibii and_exists_disjoint_forwards and_exists_disjoint_reverse);
Expand Down Expand Up @@ -258,6 +293,7 @@ do {
[$and ,phi1 ,phi2$ '(_eSubst_and ,(propag_e_subst_adv x phi1 wo_x) ,(propag_e_subst_adv x phi2 wo_x))]
[$_ceil ,phi$ '(_eSubst_ceil ,(propag_e_subst_adv x phi wo_x))]
[$_floor ,phi$ '(_eSubst_floor ,(propag_e_subst_adv x phi wo_x))]
[$_in ,y ,phi$ (if (== x y) '(_eSubst_mem_same_var ,(propag_e_subst_adv x phi wo_x)) '(_eSubst_mem ,(propag_e_subst_adv x phi wo_x)))]
[$_subset ,phi1 ,phi2$ '(_eSubst_subset ,(propag_e_subst_adv x phi1 wo_x) ,(propag_e_subst_adv x phi2 wo_x))]
[$equiv ,phi1 ,phi2$ '(_eSubst_equiv ,(propag_e_subst_adv x phi1 wo_x) ,(propag_e_subst_adv x phi2 wo_x))]
[$_eq ,phi1 ,phi2$ '(_eSubst_eq ,(propag_e_subst_adv x phi1 wo_x) ,(propag_e_subst_adv x phi2 wo_x))]
Expand All @@ -269,8 +305,6 @@ do {

[$epsilon$ 'eSubstitution_disjoint]
[$top_letter$ 'eSubstitution_disjoint]
[$a$ 'eSubstitution_disjoint]
[$b$ 'eSubstitution_disjoint]
[$top_word ,Y$ 'eSubstitution_disjoint]
[$concat ,psi1 ,psi2$ '(_eSubst_concat ,(propag_e_subst_adv x psi1 wo_x) ,(propag_e_subst_adv x psi2 wo_x))]
[$nnimp ,phi1 ,phi2$ '(_eSubst_nnimp ,(propag_e_subst_adv x phi1 wo_x) ,(propag_e_subst_adv x phi2 wo_x))]
Expand Down Expand Up @@ -301,8 +335,6 @@ do {

[$epsilon$ 'sSubstitution_disjoint]
[$top_letter$ 'sSubstitution_disjoint]
[$a$ 'sSubstitution_disjoint]
[$b$ 'sSubstitution_disjoint]
[$concat ,psi1 ,psi2$ '(sSubst_concat ,(propag_s_subst_adv X psi1 wo_X) ,(propag_s_subst_adv X psi2 wo_X))]
[$top_word ,Y$ (if (== X Y) 'sSubstitution_in_same_mu 'sSubstitution_disjoint)]
[$kleene ,Y ,psi$ (if (== X Y)
Expand Down
24 changes: 24 additions & 0 deletions 10-theory-definedness.mm0
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,30 @@ infixl _in: $in$ prec 35;

axiom definedness {x: EVar}: $ |^ eVar x ^| $;

--- Functional Patterns
-----------------------

def is_func {.x: EVar} (phi: Pattern): Pattern = $ exists x (eVar x == phi) $;

--- Predicates

def is_pred (phi: Pattern): Pattern = $ (phi == bot) \/ (phi == top) $;

--- Domain Quantifiers
----------------------

def exists_in {x: EVar} (phi psi: Pattern x): Pattern = $ exists x ((eVar x C= phi) /\ psi) $;
notation exists_in {x: EVar} (phi psi: Pattern x): Pattern = ($E$:0) x ($:$:0) phi ($.$:0) psi;

def forall_in {x: EVar} (phi psi: Pattern x): Pattern = $ forall x ((eVar x C= phi) -> psi) $;
notation forall_in {x: EVar} (phi psi: Pattern x): Pattern = ($A$:0) x ($:$:0) phi ($.$:0) psi;


def is_sorted_pred (phi psi: Pattern): Pattern = $ (psi == bot) \/ (psi == phi) $;

def is_sorted_func {.x: EVar} (phi psi: Pattern): Pattern = $ E x : phi . eVar x == psi $;


--- Contextual Implications
---------------------------

Expand Down
4 changes: 2 additions & 2 deletions 11-definedness-normalization.mm1
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ theorem propag_bot {box: SVar} (ctx: Pattern box):
'(syl (! singleton_same_var _ x _ _ (eVar x)) @ iand (framing absurdum) (framing absurdum));

theorem propag_or_def (phi1 phi2: Pattern):
$ |^ phi1 \/ phi2 ^| -> |^ phi1 ^| \/ |^ phi2 ^| $ =
'(norm (norm_imp defNorm (norm_or defNorm defNorm)) (! propag_or x));
$ |^ phi1 \/ phi2 ^| <-> |^ phi1 ^| \/ |^ phi2 ^| $ =
'(ibii (norm (norm_imp defNorm (norm_or defNorm defNorm)) (! propag_or x)) @ eori (framing_def orl) (framing_def orr));
Loading