Skip to content

Commit

Permalink
Fix alias final names
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed Sep 19, 2024
1 parent 42bd0a8 commit e510974
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ entryToScopedIden name e = do
return
ScopedIden
{ _scopedIdenAlias = Just scopedName',
_scopedIdenFinal = helper (e' ^. symbolEntry)
_scopedIdenFinal = e' ^. symbolEntry
}
registerScopedIden si
return si
Expand Down
14 changes: 14 additions & 0 deletions tests/positive/Isabelle/Program.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,17 @@ getMessageFromTrigger' {M H} (t : Trigger M H) : Maybe M :=
message := m })})})
:= just m
| _ := nothing;

-- Syntax aliases

Name : Type := Nat;

syntax alias T := Name;

idT (x : T) : T := x;

t : T := 0;

type RR := mkRR {
x : T
};
51 changes: 33 additions & 18 deletions tests/positive/Isabelle/isabelle/Program.thy
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@ definition id2 :: "'A \<Rightarrow> 'A" where
fun add_one :: "nat list \<Rightarrow> nat list" where
"add_one [] = []" |
(* hello! *)
"add_one (x # xs) = ((x + 1) # add_one xs)"
"add_one (x' # xs) = ((x' + 1) # add_one xs)"

fun sum :: "nat list \<Rightarrow> nat" where
"sum [] = 0" |
"sum (x # xs) = (x + sum xs)"
"sum (x' # xs) = (x' + sum xs)"

fun f :: "nat \<Rightarrow> nat \<Rightarrow> nat \<Rightarrow> nat" where
"f x y z = ((z + 1) * x + y)"
"f x' y z = ((z + 1) * x' + y)"

fun g :: "nat \<Rightarrow> nat \<Rightarrow> bool" where
"g x y = (if x = f x (N.g y) (M_N.g (M_Main.f y)) then False else True)"
"g x' y = (if x' = f x' (N.g y) (M_N.g (M_Main.f y)) then False else True)"

fun inc :: "nat \<Rightarrow> nat" where
"inc x = (Suc x)"
"inc x' = (Suc x')"

(* dec function *)
fun dec :: "nat \<Rightarrow> nat" where
"dec 0 = 0" |
"dec (Suc x) = x"
"dec (Suc x') = x'"

(* dec' function *)
fun dec' :: "nat \<Rightarrow> nat" where
Expand All @@ -45,23 +45,23 @@ fun dec' :: "nat \<Rightarrow> nat" where
(* the zero case *)
(* return zero *)
(* the suc case *)
"dec' x =
(case x of
"dec' x' =
(case x' of
0 \<Rightarrow> 0 |
(Suc y) \<Rightarrow> y)"

fun optmap :: "('A \<Rightarrow> 'A) \<Rightarrow> 'A option \<Rightarrow> 'A option" where
"optmap f' None = None" |
"optmap f' (Some x) = (Some (f' x))"
"optmap f' (Some x') = (Some (f' x'))"

fun pboth :: "('A \<Rightarrow> 'A') \<Rightarrow> ('B \<Rightarrow> 'B') \<Rightarrow> 'A \<times> 'B \<Rightarrow> 'A' \<times> 'B'" where
"pboth f' g' (x, y) = (f' x, g' y)"
"pboth f' g' (x', y) = (f' x', g' y)"

fun bool_fun :: "bool \<Rightarrow> bool \<Rightarrow> bool \<Rightarrow> bool" where
"bool_fun x y z = (x \<and> (y \<or> z))"
"bool_fun x' y z = (x' \<and> (y \<or> z))"

fun bool_fun' :: "bool \<Rightarrow> bool \<Rightarrow> bool \<Rightarrow> bool" where
"bool_fun' x y z = (x \<and> y \<or> z)"
"bool_fun' x' y z = (x' \<and> y \<or> z)"

(* Queues *)
text \<open>
Expand All @@ -71,7 +71,7 @@ datatype 'A Queue
= queue "'A list" "'A list"

fun qfst :: "'A Queue \<Rightarrow> 'A list" where
"qfst (queue x v') = x"
"qfst (queue x' v') = x'"

fun qsnd :: "'A Queue \<Rightarrow> 'A list" where
"qsnd (queue v' v'0) = v'0"
Expand All @@ -85,10 +85,10 @@ fun pop_front :: "'A Queue \<Rightarrow> 'A Queue" where
v' \<Rightarrow> q')"

fun push_back :: "'A Queue \<Rightarrow> 'A \<Rightarrow> 'A Queue" where
"push_back q x =
"push_back q x' =
(case qfst q of
[] \<Rightarrow> queue [x] (qsnd q) |
q' \<Rightarrow> queue q' (x # qsnd q))"
[] \<Rightarrow> queue [x'] (qsnd q) |
q' \<Rightarrow> queue q' (x' # qsnd q))"

text \<open>
Checks if the queue is empty
Expand Down Expand Up @@ -291,11 +291,26 @@ fun getMessageFromTrigger :: "('M, 'H) Trigger \<Rightarrow> 'M option" where
v'1 \<Rightarrow> None)"

fun getMessageFromTrigger' :: "('M, 'H) Trigger \<Rightarrow> 'M option" where
"getMessageFromTrigger' t =
(case t of
"getMessageFromTrigger' t' =
(case t' of
(MessageArrived v') \<Rightarrow>
(case (EnvelopedMessage.packet v') of
(v'0) \<Rightarrow> Some (MessagePacket.message v'0)) |
v'2 \<Rightarrow> None)"

(* Syntax aliases *)
type_synonym Name = nat

fun idT :: "nat \<Rightarrow> Name" where
"idT x' = x'"

definition t :: Name where
"t = 0"

record RR =
x :: nat

fun x :: "RR \<Rightarrow> Name" where
"x (| RR.x = x' |) = x'"

end

0 comments on commit e510974

Please sign in to comment.