Created
January 30, 2018 12:52
-
-
Save mgttlinger/ea0654dcf71b8937a7c67231e0c625f9 to your computer and use it in GitHub Desktop.
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
Module MatchContext. | |
Inductive D := | |
| d_a : D | |
| d_b : D -> D -> D. | |
Fixpoint cmpl d := match d with | |
| d_a => 1 | |
| d_b x x0 => S (cmpl x + cmpl x0) | |
end. | |
Record T d := {a : d; b : d}. | |
Import ListNotations. | |
Require Import Omega. | |
Local Obligation Tactic := Tactics.program_simpl; autounfold; try solve [simpl; omega]; try solve [repeat split; congruence]. | |
Program Fixpoint rule_transform (ed : T D) {measure (cmpl (a _ ed) + cmpl (b _ ed))} : (list (T D)) := | |
let av := a _ ed in | |
let bv := b _ ed in | |
match (av, bv) return list (T D) with | |
| (d_b a1 a2, d_b b1 b2) => | |
rule_transform {|a:=a1;b:=b1|} (* even here it generates an obligation where the relation of the sides is lost despite there not being any higher order functions involved that need to be unfolded *) | |
| (a, b) => ([ed]) | |
end. | |
Next Obligation. Abort. (* Unprovable because context is missing*) | |
Admit Obligations. | |
Program Fixpoint rule_transform' (ed : T D) {measure (cmpl (a _ ed) + cmpl (b _ ed))} : (list (T D)) := | |
let av := a _ ed in | |
let bv := b _ ed in | |
match (av, bv) with | |
| (d_b a1 a2, d_b b1 b2) => | |
rule_transform' {|a:=a1;b:=b1|} (* Here we get the context although the statement itself hasn't changed *) | |
| (a, b) => ([ed]) | |
end. | |
(* works *) | |
End MatchContext. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment