ladder-calculus/coq/bbencode.v

104 lines
2.2 KiB
Coq
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From Coq Require Import Strings.String.
Require Import terms.
Require Import subst.
Require Import smallstep.
Open Scope ladder_type_scope.
Open Scope ladder_expr_scope.
Definition bb_zero : expr_term := [{
(Λ"α"
λ"s",(%"α"% -> %"α"%)
λ"z",(%"α"%)
%"z"%)
as $""$~$"BBNat"$
}].
Definition bb_one : expr_term := [{
(Λ"α"
λ"s",(%"α"% -> %"α"%)
λ"z",(%"α"%)
(%"s"% %"z"%))
as $""$~$"BBNat"$
}].
Definition bb_two : expr_term := [{
(Λ"α"
λ"s",(%"α"% -> %"α"%)
λ"z",(%"α"%)
(%"s"% (%"s"% %"z"%)))
as $""$~$"BBNat"$
}].
Definition bb_succ : expr_term := [{
λ"n",$""$
~$"BBNat"$
~("β",(%"β'"%->%"β"%)->%"β"%->%"β"%)
((Λ"α"
λ"s",((%"α"%->%"α"%)->%"α"%->%"α"%)
λ"z",%"α"%
(%"s"% ((%"n"% # %"α"%) %"s"% %"z"%)))
as $""$~$"BBNat"$)
}].
Example example_reduction :
(expr_app bb_succ bb_one) -->β* bb_two
.
Proof.
apply Multi_Step with (y:=[{
(λ"n",$""$
~$"BBNat"$
~("β",(%"β'"%->%"β"%)->%"β"%->%"β"%)
((Λ"α"
λ"s",((%"α"%->%"α"%)->%"α"%->%"α"%)
λ"z",%"α"%
(%"s"% ((%"n"% # %"α"%) %"s"% %"z"%)))
as $""$~$"BBNat"$))
(Λ"β"
λ"s",(%"β"% -> %"β"%)
λ"z",(%"β"%)
(%"s"% %"z"%))
as $""$~$"BBNat"$
}]).
Admitted.
(*
apply E_Alpha.
apply E_App2.
apply EAlpha_Rename.
apply Multi_Step with (y:=[{
(Λ"α" ↦
λ"s",((%"α"%->%"α"%)->%"α"%->%"α"%)
λ"z",%"α"% ↦
(%"s"% (
(((Λ"β" ↦
λ"s",(%"β"% -> %"β"%)
λ"z",(%"β"%)
(%"s"% %"z"%)) as $""$~$"BBNat"$)
# %"α"%) %"s"% %"z"%)))
as $""$~$"BBNat"$ }]).
apply E_AppLam.
apply Multi_Step with (y:=[{
(Λ"α" ↦
λ"s",((%"α"%->%"α"%)->%"α"%->%"α"%)
λ"z",%"α"% ↦
(%"s"% (
(((Λ"α'" ↦
λ"s",(%"α'"% -> %"α'"%)
λ"z",(%"α'"%)
(%"s"% %"z"%)) as $""$~$"BBNat"$)
# %"α"%) %"s"% %"z"%)))
as $""$~$"BBNat"$ }]).
}].
Qed.
*)
Compute (expr_app bb_succ bb_zero) -->β bb_one.